diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-15 18:37:05 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-15 18:37:05 +0400 |
commit | e1229b2978c37a043f3932657ac5cfa156093866 (patch) | |
tree | 9b11c52390302485cf1b5be799d693e4fce03f22 /source/blender/editors/sculpt_paint/paint_stroke.c | |
parent | 71775dc2a49d8ec20d31544f2fccf69729a8cd39 (diff) |
Attempt to fix #35057 and #35372: slow texture painting performance.
After the paint refactoring for 2.67, the OpenGL texture was getting updated for
every stroke point, rather than once for every redraw. With a small brush radius
and low spacing the number of stroke points can be quite large, which might have
a big performance impact depending on the graphics card / drivers.
Also for 2D image paint, avoid redrawing the button panels and properties editor
during painting.
There is another possible cause for slowdowns with 3D texture painting which was
not fixed. Projection painting is creating and destroying threads for every stroke
point. Depending on the CPU/OS there might be a lot of overhead in doing that if
the brush size is small.
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_stroke.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 95cbc4b78b4..90c0d7e3a7a 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; @@ -425,6 +426,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 +439,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 +459,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 +619,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 +670,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 +690,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; } |