Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_draw.c
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| #include "WM_toolsystem.h" | #include "WM_toolsystem.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "wm.h" | #include "wm.h" | ||||
| #include "wm_draw.h" | #include "wm_draw.h" | ||||
| #include "wm_event_system.h" | #include "wm_event_system.h" | ||||
| #include "wm_surface.h" | #include "wm_surface.h" | ||||
| #include "wm_window.h" | #include "wm_window.h" | ||||
| #include "UI_resources.h" | |||||
| #ifdef WITH_OPENSUBDIV | #ifdef WITH_OPENSUBDIV | ||||
| # include "BKE_subsurf.h" | # include "BKE_subsurf.h" | ||||
| #endif | #endif | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Draw Paint Cursor | /** \name Draw Paint Cursor | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | for (pc = wm->paintcursors.first; pc; pc = pc->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Post Draw Region on display handlers | |||||
| * \{ */ | |||||
| static void wm_region_draw_overlay(bContext *C, ScrArea *area, ARegion *region) | |||||
| { | |||||
| wmWindowManager *wm = CTX_wm_manager(C); | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| /* Don't draw overlay with locked interface. Drawing could access scene data that another thread | |||||
| * may be modifying. */ | |||||
| if (wm->is_interface_locked) { | |||||
| return; | |||||
| } | |||||
| wmViewport(®ion->winrct); | |||||
| UI_SetTheme(area->spacetype, region->regiontype); | |||||
| region->type->draw_overlay(C, region); | |||||
| wmWindowViewport(win); | |||||
| } | |||||
| /** \} */ | |||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Internal Utilities | /** \name Internal Utilities | ||||
| * \{ */ | * \{ */ | ||||
| static bool wm_draw_region_stereo_set(Main *bmain, | static bool wm_draw_region_stereo_set(Main *bmain, | ||||
| ScrArea *area, | ScrArea *area, | ||||
| ARegion *region, | ARegion *region, | ||||
| eStereoViews sview) | eStereoViews sview) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 605 Lines • ▼ Show 20 Lines | ED_screen_areas_iter (win, screen, area) { | ||||
| LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| if (region->visible && region->overlap == false) { | if (region->visible && region->overlap == false) { | ||||
| /* Blit from offscreen buffer. */ | /* Blit from offscreen buffer. */ | ||||
| wm_draw_region_blit(region, view); | wm_draw_region_blit(region, view); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Draw paint cursors. */ | /* Draw overlays and paint cursors. */ | ||||
| if (wm->paintcursors.first) { | |||||
| ED_screen_areas_iter (win, screen, area) { | ED_screen_areas_iter (win, screen, area) { | ||||
| LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| if (region->visible && region == screen->active_region) { | if (region->visible) { | ||||
| const bool do_paint_cursor = (wm->paintcursors.first && region == screen->active_region); | |||||
| const bool do_draw_overlay = (region->type && region->type->draw_overlay); | |||||
| if (!(do_paint_cursor || do_draw_overlay)) { | |||||
| continue; | |||||
| } | |||||
| CTX_wm_area_set(C, area); | CTX_wm_area_set(C, area); | ||||
| CTX_wm_region_set(C, region); | CTX_wm_region_set(C, region); | ||||
| if (do_draw_overlay) { | |||||
brecht: Maybe merge this in the paint cursors loop below.
Also for paint cursors there is… | |||||
Done Inline ActionsDone, for draw_overlay the wm_region_draw_display resets the window viewport to its original state. Another wmWindowViewport was not needed. This part could be rechecked to reduce gl setup calls that aren't necessary. jbakker: Done, for `draw_overlay` the `wm_region_draw_display` resets the window viewport to its… | |||||
| /* make region ready for draw, scissor, pixelspace */ | wm_region_draw_overlay(C, area, region); | ||||
| } | |||||
| if (do_paint_cursor) { | |||||
| wm_paintcursor_draw(C, area, region); | wm_paintcursor_draw(C, area, region); | ||||
| } | |||||
| CTX_wm_region_set(C, NULL); | CTX_wm_region_set(C, NULL); | ||||
| CTX_wm_area_set(C, NULL); | CTX_wm_area_set(C, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| wmWindowViewport(win); | wmWindowViewport(win); | ||||
| } | |||||
| /* Blend in overlapping area regions */ | /* Blend in overlapping area regions */ | ||||
| ED_screen_areas_iter (win, screen, area) { | ED_screen_areas_iter (win, screen, area) { | ||||
| LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| if (region->visible && region->overlap) { | if (region->visible && region->overlap) { | ||||
| wm_draw_region_blend(region, 0, true); | wm_draw_region_blend(region, 0, true); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines | |||||
Maybe merge this in the paint cursors loop below.
Also for paint cursors there is wmWindowViewport to reset the OpenGL viewport to the whole window. I would guess this is needed for the draw_display case as well.