diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-16 17:10:04 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-16 17:10:04 +0400 |
commit | 29ecc722479e6b0130b82595db2d9eb2a568cbf1 (patch) | |
tree | 8dfb4aff75aae8072e5affb8caeaeb1f9711974e | |
parent | ac483b5123c55c7bbb42198e2022f896d1b6d176 (diff) |
svn merge ^/trunk/blender -c56755 -c56756 -c56763 -c56766 -c56767 -c56800 -c56816 -c56823 -c56828 -c56830 -c56833 -c56834
-rw-r--r-- | release/scripts/startup/bl_ui/space_node.py | 5 | ||||
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 86 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 40 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_2d.c | 68 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 49 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 11 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 33 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 8 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 15 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 8 |
14 files changed, 183 insertions, 153 deletions
diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index f58679e836d..006fb3d056c 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -77,8 +77,9 @@ class NODE_HT_header(Header): layout.prop(snode_id, "use_nodes") elif snode.tree_type == 'CompositorNodeTree': - layout.prop(snode_id, "use_nodes") - layout.prop(snode_id.render, "use_free_unused_nodes", text="Free Unused") + if snode_id: + layout.prop(snode_id, "use_nodes") + layout.prop(snode_id.render, "use_free_unused_nodes", text="Free Unused") layout.prop(snode, "show_backdrop") if snode.show_backdrop: row = layout.row(align=True) diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 3dc5ec0ebce..f1be219242e 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -74,8 +74,6 @@ void ED_region_visible_rect(struct ARegion *ar, struct rcti *rect); void ED_spacetypes_keymap(struct wmKeyConfig *keyconf); int ED_area_header_switchbutton(const struct bContext *C, struct uiBlock *block, int yco); int ED_area_header_standardbuttons(const struct bContext *C, struct uiBlock *block, int yco); -void ED_area_overdraw(struct bContext *C); -void ED_area_overdraw_flush(struct ScrArea *sa, struct ARegion *ar); /* areas */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 4b5581f84f0..87dc6fd7d66 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -150,25 +150,6 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa) sa->do_refresh = FALSE; } -/* based on screen region draw tags, set draw tags in azones, and future region tabs etc */ -/* only exported for WM */ -void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar) -{ - AZone *az; - - for (az = sa->actionzones.first; az; az = az->next) { - int xs, ys; - - xs = (az->x1 + az->x2) / 2; - ys = (az->y1 + az->y2) / 2; - - /* test if inside */ - if (BLI_rcti_isect_pt(&ar->winrct, xs, ys)) { - az->do_draw = TRUE; - } - } -} - /** * \brief Corner widgets use for dragging and splitting the view. */ @@ -348,49 +329,50 @@ static void region_draw_azone_tria(AZone *az) glDisable(GL_BLEND); } -/* only exported for WM */ -void ED_area_overdraw(bContext *C) +static void region_draw_azones(ScrArea *sa, ARegion *ar) { - wmWindow *win = CTX_wm_window(C); - bScreen *screen = CTX_wm_screen(C); - ScrArea *sa; - - /* Draw AZones, in screenspace */ - wmSubWindowSet(win, screen->mainwin); + AZone *az; + + if (!sa) + return; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glPushMatrix(); + glTranslatef(-ar->winrct.xmin, -ar->winrct.ymin, 0.0f); - for (sa = screen->areabase.first; sa; sa = sa->next) { - AZone *az; - for (az = sa->actionzones.first; az; az = az->next) { - if (az->do_draw) { - if (az->type == AZONE_AREA) { - area_draw_azone(az->x1, az->y1, az->x2, az->y2); - } - else if (az->type == AZONE_REGION) { - - if (az->ar) { - /* only display tab or icons when the region is hidden */ - if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { - if (G.debug_value == 3) - region_draw_azone_icon(az); - else if (G.debug_value == 2) - region_draw_azone_tria(az); - else if (G.debug_value == 1) - region_draw_azone_tab(az); - else - region_draw_azone_tab_plus(az); - } + for (az = sa->actionzones.first; az; az = az->next) { + /* test if action zone is over this region */ + rcti azrct; + BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2); + + if (BLI_rcti_isect(&ar->drawrct, &azrct, NULL)) { + if (az->type == AZONE_AREA) { + area_draw_azone(az->x1, az->y1, az->x2, az->y2); + } + else if (az->type == AZONE_REGION) { + + if (az->ar) { + /* only display tab or icons when the region is hidden */ + if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + if (G.debug_value == 3) + region_draw_azone_icon(az); + else if (G.debug_value == 2) + region_draw_azone_tria(az); + else if (G.debug_value == 1) + region_draw_azone_tab(az); + else + region_draw_azone_tab_plus(az); } } - - az->do_draw = FALSE; } } } + + glPopMatrix(); + glDisable(GL_BLEND); - } /* only exported for WM */ @@ -455,6 +437,8 @@ void ED_region_do_draw(bContext *C, ARegion *ar) ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL); + region_draw_azones(sa, ar); + /* for debugging unneeded area redraws and partial redraw */ #if 0 glEnable(GL_BLEND); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 6547b336119..c29fbeb5a16 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -478,22 +478,6 @@ void paint_brush_exit_tex(Brush *brush) } -static void paint_redraw(const bContext *C, PaintOperation *pop, int final) -{ - if (pop->mode == PAINT_MODE_2D) { - paint_2d_redraw(C, pop->custom_paint, final); - } - else { - if (final) { - /* compositor listener deals with updating */ - WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, NULL); - } - else { - ED_region_tag_redraw(CTX_wm_region(C)); - } - } -} - static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); @@ -547,7 +531,7 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po float mouse[2]; float pressure; - int redraw, eraser; + int eraser; RNA_float_get_array(itemptr, "mouse", mouse); pressure = RNA_float_get(itemptr, "pressure"); @@ -559,10 +543,10 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po BKE_brush_size_set(scene, brush, max_ff(1.0f, startsize * pressure)); if (pop->mode == PAINT_MODE_3D_PROJECT) { - redraw = paint_proj_stroke(C, pop->custom_paint, pop->prevmouse, mouse); + paint_proj_stroke(C, pop->custom_paint, pop->prevmouse, mouse); } else { - redraw = paint_2d_stroke(pop->custom_paint, pop->prevmouse, mouse, eraser); + paint_2d_stroke(pop->custom_paint, pop->prevmouse, mouse, eraser); } pop->prevmouse[0] = mouse[0]; @@ -571,11 +555,18 @@ static void paint_stroke_update_step(bContext *C, struct PaintStroke *stroke, Po /* restore brush values */ BKE_brush_alpha_set(scene, brush, startalpha); BKE_brush_size_set(scene, brush, startsize); +} +static void paint_stroke_redraw(const bContext *C, struct PaintStroke *stroke, bool final) +{ + PaintOperation *pop = paint_stroke_mode_data(stroke); - if (redraw) - paint_redraw(C, pop, 0); - + if (pop->mode == PAINT_MODE_3D_PROJECT) { + paint_proj_redraw(C, pop->custom_paint, final); + } + else { + paint_2d_redraw(C, pop->custom_paint, final); + } } static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke) @@ -584,8 +575,6 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke) ToolSettings *settings = scene->toolsettings; PaintOperation *pop = paint_stroke_mode_data(stroke); - paint_redraw(C, pop, 1); - settings->imapaint.flag &= ~IMAGEPAINT_DRAWING; if (pop->mode == PAINT_MODE_3D_PROJECT) { @@ -629,6 +618,7 @@ static int paint_invoke(bContext *C, wmOperator *op, const wmEvent *event) stroke = op->customdata = paint_stroke_new(C, NULL, paint_stroke_test_start, paint_stroke_update_step, + paint_stroke_redraw, paint_stroke_done, event->type); paint_stroke_set_mode_data(stroke, pop); /* add modal handler */ @@ -663,7 +653,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) ot->cancel = paint_stroke_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Paint Stroke Mode", diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 01850d71a44..456b800ae60 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -145,6 +145,8 @@ typedef struct ImagePaintState { int faceindex; float uv[2]; int do_facesel; + + bool need_redraw; } ImagePaintState; @@ -337,7 +339,7 @@ static void brush_painter_2d_tiled_tex_partial_update(BrushPainter *painter, con brush_painter_2d_do_partial(painter, NULL, x1, y2, x2, ibuf->y, 0, 0, pos); } -static void brush_painter_2d_tex_mapping(ImagePaintState *s, int bufsize, const float pos[2], bool do_stencil, bool do_3D, bool do_view, rctf *mapping) +static void brush_painter_2d_tex_mapping(ImagePaintState *s, int bufsize, const float pos[2], const float mouse[2], bool do_stencil, bool do_3D, bool do_view, bool do_random, rctf *mapping) { float invw = 1.0f / (float)s->canvas->x; float invh = 1.0f / (float)s->canvas->y; @@ -348,7 +350,7 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s, int bufsize, const ipos[0] = (int)floorf((pos[0] - bufsize / 2) + 1.0f); ipos[1] = (int)floorf((pos[1] - bufsize / 2) + 1.0f); - if (do_stencil || do_view) { + if (do_stencil) { /* map from view coordinates of brush to region coordinates */ UI_view2d_to_region_no_clip(s->v2d, ipos[0] * invw, ipos[1] * invh, &xmin, &ymin); UI_view2d_to_region_no_clip(s->v2d, (ipos[0] + bufsize) * invw, (ipos[1] + bufsize) * invh, &xmax, &ymax); @@ -361,13 +363,19 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s, int bufsize, const } else if (do_3D) { /* 3D mapping, just mapping to canvas 0..1 */ - mapping->xmin = ipos[0] * invw; - mapping->ymin = ipos[1] * invh; - mapping->xmax = bufsize * invw / (float)bufsize; - mapping->ymax = bufsize * invh / (float)bufsize; + mapping->xmin = 2.0f * (ipos[0] * invw - 0.5f); + mapping->ymin = 2.0f * (ipos[1] * invh - 0.5f); + mapping->xmax = 2.0f * invw; + mapping->ymax = 2.0f * invh; + } + else if (do_view || do_random) { + /* view mapping */ + mapping->xmin = mouse[0] - bufsize * 0.5f + 0.5f; + mapping->ymin = mouse[1] - bufsize * 0.5f + 0.5f; + mapping->xmax = 1.0f; + mapping->ymax = 1.0f; } - else { - /* other mapping */ + else /* if (do_tiled) */ { mapping->xmin = -bufsize * 0.5f + 0.5f; mapping->ymin = -bufsize * 0.5f + 0.5f; mapping->xmax = 1.0f; @@ -375,7 +383,7 @@ static void brush_painter_2d_tex_mapping(ImagePaintState *s, int bufsize, const } } -static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *painter, const float pos[2], bool use_color_correction) +static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *painter, const float pos[2], const float mouse[2], bool use_color_correction) { const Scene *scene = painter->scene; UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; @@ -398,7 +406,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *pai rotation += ups->brush_rotation; } - brush_painter_2d_tex_mapping(s, size, pos, do_stencil, do_3D, do_view, &painter->mapping); + brush_painter_2d_tex_mapping(s, size, pos, mouse, do_stencil, do_3D, do_view, do_random, &painter->mapping); painter->pool = BKE_image_pool_new(); @@ -805,17 +813,16 @@ static void paint_2d_canvas_free(ImagePaintState *s) image_undo_remove_masks(); } -int paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser) +void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser) { float newuv[2], olduv[2]; - int redraw = 0; ImagePaintState *s = ps; BrushPainter *painter = s->painter; ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, s->sima ? &s->sima->iuser : NULL, NULL); const bool is_data = (ibuf && ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA); if (!ibuf) - return 0; + return; s->blend = s->brush->blend; if (eraser) @@ -850,21 +857,12 @@ int paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int */ brush_painter_2d_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0); - brush_painter_2d_refresh_cache(s, painter, newuv, is_data == false); - - if (paint_2d_op(s, painter->cache.ibuf, olduv, newuv)) { - imapaint_image_update(s->sima, s->image, ibuf, false); - BKE_image_release_ibuf(s->image, ibuf, NULL); - redraw |= 1; - } - else { - BKE_image_release_ibuf(s->image, ibuf, NULL); - } + brush_painter_2d_refresh_cache(s, painter, newuv, mval, is_data == false); - if (redraw) - imapaint_clear_partial_redraw(); + if (paint_2d_op(s, painter->cache.ibuf, olduv, newuv)) + s->need_redraw = true; - return redraw; + BKE_image_release_ibuf(s->image, ibuf, NULL); } void *paint_2d_new_stroke(bContext *C, wmOperator *op) @@ -904,10 +902,24 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op) return s; } -void paint_2d_redraw(const bContext *C, void *ps, int final) +void paint_2d_redraw(const bContext *C, void *ps, bool final) { ImagePaintState *s = ps; + if (s->need_redraw) { + ImBuf *ibuf = BKE_image_acquire_ibuf(s->image, s->sima ? &s->sima->iuser : NULL, NULL); + + imapaint_image_update(s->sima, s->image, ibuf, false); + imapaint_clear_partial_redraw(); + + BKE_image_release_ibuf(s->image, ibuf, NULL); + + s->need_redraw = false; + } + else if (!final) { + return; + } + if (final) { if (s->image && !(s->sima && s->sima->lock)) GPU_free_image(s->image); @@ -919,7 +931,7 @@ void paint_2d_redraw(const bContext *C, void *ps, int final) if (!s->sima || !s->sima->lock) ED_region_tag_redraw(CTX_wm_region(C)); else - WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, s->image); + WM_event_add_notifier(C, NC_IMAGE | NA_PAINTING, s->image); } } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index f0be444a8ac..02c9760232e 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -264,12 +264,14 @@ typedef struct ProjPaintState { Image *reproject_image; ImBuf *reproject_ibuf; - /* threads */ int thread_tot; int bucketMin[2]; int bucketMax[2]; int context_bucket_x, context_bucket_y; /* must lock threads while accessing these */ + + /* redraw */ + bool need_redraw; } ProjPaintState; typedef union pixelPointer { @@ -4048,10 +4050,10 @@ static int project_paint_op(void *state, const float lastpos[2], const float pos } -int paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const float pos[2]) +void paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const float pos[2]) { ProjPaintState *ps = pps; - int a, redraw; + int a; /* clone gets special treatment here to avoid going through image initialization */ if (ps->tool == PAINT_TOOL_CLONE && ps->mode == BRUSH_STROKE_INVERT) { @@ -4063,22 +4065,21 @@ int paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const flo view3d_operator_needs_opengl(C); if (!ED_view3d_autodist(scene, ps->ar, v3d, mval_i, cursor, false)) - return 0; + return; ED_region_tag_redraw(ps->ar); - return 0; + return; } - for (a = 0; a < ps->image_tot; a++) - partial_redraw_array_init(ps->projImages[a].partRedrawRect); - - redraw = project_paint_op(ps, prev_pos, pos) ? 1 : 0; - - if (project_image_refresh_tagged(ps)) - return redraw; + /* continue adding to existing partial redraw rects until redraw */ + if (!ps->need_redraw) { + for (a = 0; a < ps->image_tot; a++) + partial_redraw_array_init(ps->projImages[a].partRedrawRect); + } - return 0; + if (project_paint_op(ps, prev_pos, pos)) + ps->need_redraw = true; } @@ -4199,6 +4200,28 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m return ps; } +void paint_proj_redraw(const bContext *C, void *pps, bool final) +{ + ProjPaintState *ps = pps; + + if (ps->need_redraw) { + project_image_refresh_tagged(ps); + + ps->need_redraw = false; + } + else if (!final) { + return; + } + + if (final) { + /* compositor listener deals with updating */ + WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, NULL); + } + else { + ED_region_tag_redraw(CTX_wm_region(C)); + } +} + void paint_proj_stroke_done(void *pps) { ProjPaintState *ps = pps; diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index a4230439737..81c33338b5c 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -60,11 +60,13 @@ enum PaintMode; typedef int (*StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2]); typedef int (*StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2]); typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr); +typedef void (*StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final); typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, - StrokeUpdateStep update_step, StrokeDone done, int event_type); + StrokeUpdateStep update_step, StrokeRedraw redraw, + StrokeDone done, int event_type); void paint_stroke_data_free(struct wmOperator *op); bool paint_space_stroke_enabled(struct Brush *br, enum PaintMode mode); @@ -139,11 +141,12 @@ void imapaint_dirty_region(struct Image *ima, struct ImBuf *ibuf, int x, int y, void imapaint_region_tiles(struct ImBuf *ibuf, int x, int y, int w, int h, int *tx, int *ty, int *tw, int *th); int get_imapaint_zoom(struct bContext *C, float *zoomx, float *zoomy); void *paint_2d_new_stroke(struct bContext *, struct wmOperator *); -void paint_2d_redraw(const bContext *C, void *ps, int final); +void paint_2d_redraw(const bContext *C, void *ps, bool final); void paint_2d_stroke_done(void *ps); -int paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser); +void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser); void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, const float mouse[2], int mode); -int paint_proj_stroke(struct bContext *C, void *ps, const float prevmval_i[2], const float mval_i[2]); +void paint_proj_stroke(struct bContext *C, void *ps, const float prevmval_i[2], const float mval_i[2]); +void paint_proj_redraw(const bContext *C, void *pps, bool final); void paint_proj_stroke_done(void *ps); void paint_brush_init_tex(struct Brush *brush); void paint_brush_exit_tex(struct Brush *brush); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 95cbc4b78b4..d3cb53c94fc 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -101,6 +101,7 @@ typedef struct PaintStroke { StrokeGetLocation get_location; StrokeTestStart test_start; StrokeUpdateStep update_step; + StrokeRedraw redraw; StrokeDone done; } PaintStroke; @@ -327,6 +328,10 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const wmEve stroke->update_step(C, stroke, &itemptr); + /* don't record this for now, it takes up a lot of memory when doing long + * strokes with small brush size, and operators have register disabled */ + RNA_collection_clear(op->ptr, "stroke"); + /* always redraw region if brush is shown */ if (ar && (paint->flags & PAINT_SHOW_BRUSH)) WM_paint_cursor_tag_redraw(window, ar); @@ -425,6 +430,7 @@ PaintStroke *paint_stroke_new(bContext *C, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, + StrokeRedraw redraw, StrokeDone done, int event_type) { PaintStroke *stroke = MEM_callocN(sizeof(PaintStroke), "PaintStroke"); @@ -437,6 +443,7 @@ PaintStroke *paint_stroke_new(bContext *C, stroke->get_location = get_location; stroke->test_start = test_start; stroke->update_step = update_step; + stroke->redraw = redraw; stroke->done = done; stroke->event_type = event_type; /* for modal, return event */ @@ -456,8 +463,13 @@ static void stroke_done(struct bContext *C, struct wmOperator *op) { struct PaintStroke *stroke = op->customdata; - if (stroke->stroke_started && stroke->done) - stroke->done(C, stroke); + if (stroke->stroke_started) { + if (stroke->redraw) + stroke->redraw(C, stroke, true); + + if (stroke->done) + stroke->done(C, stroke); + } if (stroke->timer) { WM_event_remove_timer( @@ -611,6 +623,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) float mouse[2]; int first = 0; float zoomx, zoomy; + bool redraw = false; paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1]); paint_stroke_sample_average(stroke, &sample_average); @@ -661,17 +674,14 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) if (stroke->stroke_started) { if (paint_smooth_stroke(stroke, mouse, &sample_average, mode)) { if (paint_space_stroke_enabled(stroke->brush, mode)) { - if (!paint_space_stroke(C, op, event, mouse)) { - //ED_region_tag_redraw(ar); - } + if (paint_space_stroke(C, op, event, mouse)) + redraw = true; } else { paint_brush_stroke_add_step(C, op, event, mouse); + redraw = true; } } - else { - ; //ED_region_tag_redraw(ar); - } } } @@ -684,7 +694,14 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) !(stroke->brush->flag & BRUSH_SMOOTH_STROKE)) { paint_brush_stroke_add_step(C, op, event, mouse); + redraw = true; } + + /* do updates for redraw. if event is inbetween mousemove there are more + * coming, so postpone potentially slow redraw updates until all are done */ + if (event->type != INBETWEEN_MOUSEMOVE) + if (redraw && stroke->redraw) + stroke->redraw(C, stroke, false); return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 034110a29be..74912dc5d8c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2561,7 +2561,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) int retval; op->customdata = paint_stroke_new(C, NULL, wpaint_stroke_test_start, - wpaint_stroke_update_step, + wpaint_stroke_update_step, NULL, wpaint_stroke_done, event->type); /* add modal handler */ @@ -2597,7 +2597,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) ot->cancel = wpaint_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } @@ -3091,7 +3091,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) int retval; op->customdata = paint_stroke_new(C, NULL, vpaint_stroke_test_start, - vpaint_stroke_update_step, + vpaint_stroke_update_step, NULL, vpaint_stroke_done, event->type); /* add modal handler */ @@ -3126,7 +3126,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) ot->cancel = vpaint_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 27ee7cdb886..d3bd0d5f43c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4400,7 +4400,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent stroke = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, - sculpt_stroke_update_step, + sculpt_stroke_update_step, NULL, sculpt_stroke_done, event->type); op->customdata = stroke; @@ -4429,7 +4429,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, - sculpt_stroke_update_step, sculpt_stroke_done, 0); + sculpt_stroke_update_step, NULL, sculpt_stroke_done, 0); /* frees op->customdata */ paint_stroke_exec(C, op); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index af404773f93..8b05e508b65 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -347,8 +347,10 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_TEXTURE: case NC_IMAGE: - ED_area_tag_redraw(sa); - sbuts->preview = 1; + if (wmn->action != NA_PAINTING) { + ED_area_tag_redraw(sa); + sbuts->preview = 1; + } break; case NC_SPACE: if (wmn->data == ND_SPACE_PROPERTIES) diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 30564d52343..679c1632eb1 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -454,9 +454,11 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_IMAGE: if (wmn->reference == sima->image || !wmn->reference) { - image_scopes_tag_refresh(sa); - ED_area_tag_refresh(sa); - ED_area_tag_redraw(sa); + if (wmn->action != NA_PAINTING) { + image_scopes_tag_refresh(sa); + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + } } break; case NC_SPACE: @@ -737,6 +739,10 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; + case NC_IMAGE: + if (wmn->action == NA_PAINTING) + ED_region_tag_redraw(ar); + break; } } @@ -829,7 +835,8 @@ static void image_scope_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_IMAGE: - ED_region_tag_redraw(ar); + if (wmn->action != NA_PAINTING) + ED_region_tag_redraw(ar); break; case NC_NODE: ED_region_tag_redraw(ar); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index c823810fc75..cb060077166 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -380,6 +380,7 @@ typedef struct wmNotifier { #define NA_REMOVED 4 #define NA_RENAME 5 #define NA_SELECTED 6 +#define NA_PAINTING 7 /* ************** Gesture Manager data ************** */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 438004b5d76..3e9dc0f10c8 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -167,7 +167,6 @@ static void wm_method_draw_full(bContext *C, wmWindow *win) CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); - ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); } } @@ -177,7 +176,6 @@ static void wm_method_draw_full(bContext *C, wmWindow *win) } ED_screen_draw(win); - ED_area_overdraw(C); /* draw overlapping regions */ for (ar = screen->regionbase.first; ar; ar = ar->next) { @@ -282,7 +280,6 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); - ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); if (exchange) @@ -293,7 +290,6 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); wm_paintcursor_draw(C, ar); - ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); ar->swap = WIN_BOTH_OK; @@ -328,8 +324,6 @@ static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange) screen->swap = WIN_BOTH_OK; } - ED_area_overdraw(C); - /* draw marked overlapping regions */ for (ar = screen->regionbase.first; ar; ar = ar->next) { if (ar->swinid && ar->do_draw) { @@ -621,7 +615,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) if (ar->overlap == 0) { CTX_wm_region_set(C, ar); ED_region_do_draw(C, ar); - ED_area_overdraw_flush(sa, ar); CTX_wm_region_set(C, NULL); copytex = 1; } @@ -634,7 +627,6 @@ static void wm_method_draw_triple(bContext *C, wmWindow *win) if (copytex) { wmSubWindowSet(win, screen->mainwin); - ED_area_overdraw(C); wm_triple_copy_textures(win, triple); } |