Fix #35337: sculpt performance regression, partial redraw was not working anymore
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 13 May 2013 13:32:42 +0000 (13:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 13 May 2013 13:32:42 +0000 (13:32 +0000)
due to paint cursor redraw problem.

source/blender/editors/screen/area.c
source/blender/editors/sculpt_paint/paint_stroke.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c

index 188340e70a373118da839798ad151e900bf69122..749fa40a76c68989d7df631abec6ad142dcd6545 100644 (file)
@@ -454,6 +454,14 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
 
        ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
 
+       /* for debugging unneeded area redraws and partial redraw */
+#if 0
+       glEnable(GL_BLEND);
+       glColor4f(drand48(), drand48(), drand48(), 0.1f);
+       glRectf(ar->drawrct.xmin - 1, ar->drawrct.ymin - 1, ar->drawrct.xmax + 1, ar->drawrct.ymax + 1);
+       glDisable(GL_BLEND);
+#endif
+
        ar->do_draw = FALSE;
        memset(&ar->drawrct, 0, sizeof(ar->drawrct));
        
index 945fa14d613ded52edd8766ecf4edf22c2567c16..95cbc4b78b4ebef536ec5b9a484a476f7e64052f 100644 (file)
@@ -255,6 +255,7 @@ static void paint_brush_update(bContext *C, Brush *brush, PaintMode mode,
 static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const wmEvent *event, const float mouse_in[2])
 {
        Scene *scene = CTX_data_scene(C);
+       wmWindow *window = CTX_wm_window(C);
        ARegion *ar = CTX_wm_region(C);
        Paint *paint = BKE_paint_get_active_from_context(C);
        PaintMode mode = BKE_paintmode_get_active_from_context(C);
@@ -328,7 +329,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const wmEve
 
        /* always redraw region if brush is shown */
        if (ar && (paint->flags & PAINT_SHOW_BRUSH))
-               ED_region_tag_redraw(ar);
+               WM_paint_cursor_tag_redraw(window, ar);
 }
 
 /* Returns zero if no sculpt changes should be made, non-zero otherwise */
index 166aef48ec743b89b58c824e4bdd2847acb9dced..cfa914091f135507212dbbdfe3ce8ae6c3459027 100644 (file)
@@ -63,6 +63,7 @@ struct wmDropBox;
 struct wmDrag;
 struct ImBuf;
 struct ImageFormatData;
+struct ARegion;
 
 typedef struct wmJob wmJob;
 
@@ -130,6 +131,7 @@ void                *WM_paint_cursor_activate(struct wmWindowManager *wm,
                                       void *customdata);
 
 void           WM_paint_cursor_end(struct wmWindowManager *wm, void *handle);
+void           WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion *ar);
 
 void           WM_cursor_warp          (struct wmWindow *win, int x, int y);
 float          WM_cursor_pressure      (const struct wmWindow *win);
index 005d02647a4d5fb4a237d34f96f3e6bd0b1fdde8..438004b5d76fe4acfffea7099e3ce510bf74ea3c 100644 (file)
@@ -798,6 +798,12 @@ void wm_tag_redraw_overlay(wmWindow *win, ARegion *ar)
        }
 }
 
+void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *ar)
+{
+       win->screen->do_draw_paintcursor = TRUE;
+       wm_tag_redraw_overlay(win, ar);
+}
+
 void wm_draw_update(bContext *C)
 {
        wmWindowManager *wm = CTX_wm_manager(C);
index f79ac1c9083885125ecc84783b80f94c51a71143..89dc6ccc03830f00af158d4f17b924e763e3d831 100644 (file)
@@ -2002,8 +2002,7 @@ static void wm_paintcursor_tag(bContext *C, wmPaintCursor *pc, ARegion *ar)
                for (; pc; pc = pc->next) {
                        if (pc->poll == NULL || pc->poll(C)) {
                                wmWindow *win = CTX_wm_window(C);
-                               win->screen->do_draw_paintcursor = TRUE;
-                               wm_tag_redraw_overlay(win, ar);
+                               WM_paint_cursor_tag_redraw(win, ar);
                        }
                }
        }