diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_proj.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d7cea395409..dff033b3613 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 { @@ -4044,10 +4046,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) { @@ -4059,22 +4061,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; } @@ -4195,6 +4196,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; |