Changeset View
Changeset View
Standalone View
Standalone View
source/blender/windowmanager/intern/wm_draw.c
| Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | static void wm_region_test_gizmo_do_draw(bContext *C, | ||||
| ARegion *region, | ARegion *region, | ||||
| bool tag_redraw) | bool tag_redraw) | ||||
| { | { | ||||
| if (region->gizmo_map == NULL) { | if (region->gizmo_map == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| wmGizmoMap *gzmap = region->gizmo_map; | wmGizmoMap *gzmap = region->gizmo_map; | ||||
| for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; | LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, WM_gizmomap_group_list(gzmap)) { | ||||
| gzgroup = gzgroup->next) { | |||||
| if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) { | if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) { | ||||
| ScrArea *ctx_area = CTX_wm_area(C); | ScrArea *ctx_area = CTX_wm_area(C); | ||||
| ARegion *ctx_region = CTX_wm_region(C); | ARegion *ctx_region = CTX_wm_region(C); | ||||
| 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 (WM_gizmo_group_type_poll(C, gzgroup->type)) { | if (WM_gizmo_group_type_poll(C, gzgroup->type)) { | ||||
| ED_region_tag_redraw_editor_overlays(region); | ED_region_tag_redraw_editor_overlays(region); | ||||
| } | } | ||||
| /* Reset. */ | /* Reset. */ | ||||
| CTX_wm_area_set(C, ctx_area); | CTX_wm_area_set(C, ctx_area); | ||||
| CTX_wm_region_set(C, ctx_region); | CTX_wm_region_set(C, ctx_region); | ||||
| } | } | ||||
| for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { | LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { | ||||
| if (gz->do_draw) { | if (gz->do_draw) { | ||||
| if (tag_redraw) { | if (tag_redraw) { | ||||
| ED_region_tag_redraw_editor_overlays(region); | ED_region_tag_redraw_editor_overlays(region); | ||||
| } | } | ||||
| gz->do_draw = false; | gz->do_draw = false; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | void *WM_draw_cb_activate(wmWindow *win, | ||||
| wdc->draw = draw; | wdc->draw = draw; | ||||
| wdc->customdata = customdata; | wdc->customdata = customdata; | ||||
| return wdc; | return wdc; | ||||
| } | } | ||||
| void WM_draw_cb_exit(wmWindow *win, void *handle) | void WM_draw_cb_exit(wmWindow *win, void *handle) | ||||
| { | { | ||||
| for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) { | LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) { | ||||
| if (wdc == (WindowDrawCB *)handle) { | if (wdc == (WindowDrawCB *)handle) { | ||||
| BLI_remlink(&win->drawcalls, wdc); | BLI_remlink(&win->drawcalls, wdc); | ||||
| MEM_freeN(wdc); | MEM_freeN(wdc); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void wm_draw_callbacks(wmWindow *win) | static void wm_draw_callbacks(wmWindow *win) | ||||
| { | { | ||||
| for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) { | LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) { | ||||
| wdc->draw(win, wdc->customdata); | wdc->draw(win, wdc->customdata); | ||||
| } | } | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Region Drawing | /** \name Region Drawing | ||||
| ▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| /* Draw screen areas into own frame buffer. */ | /* Draw screen areas into own frame buffer. */ | ||||
| ED_screen_areas_iter(win, screen, area) | ED_screen_areas_iter(win, screen, area) | ||||
| { | { | ||||
| CTX_wm_area_set(C, area); | CTX_wm_area_set(C, area); | ||||
| /* Compute UI layouts for dynamically size regions. */ | /* Compute UI layouts for dynamically size regions. */ | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| /* Dynamic region may have been flagged as too small because their size on init is 0. | /* Dynamic region may have been flagged as too small because their size on init is 0. | ||||
| * ARegion.visible is false then, as expected. The layout should still be created then, so | * ARegion.visible is false then, as expected. The layout should still be created then, so | ||||
| * the region size can be updated (it may turn out to be not too small then). */ | * the region size can be updated (it may turn out to be not too small then). */ | ||||
| const bool ignore_visibility = (region->flag & RGN_FLAG_DYNAMIC_SIZE) && | const bool ignore_visibility = (region->flag & RGN_FLAG_DYNAMIC_SIZE) && | ||||
| (region->flag & RGN_FLAG_TOO_SMALL) && | (region->flag & RGN_FLAG_TOO_SMALL) && | ||||
| !(region->flag & RGN_FLAG_HIDDEN); | !(region->flag & RGN_FLAG_HIDDEN); | ||||
| if ((region->visible || ignore_visibility) && region->do_draw && region->type && | if ((region->visible || ignore_visibility) && region->do_draw && region->type && | ||||
| Show All 9 Lines | ED_screen_areas_iter(win, screen, area) | ||||
| if (area->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { | if (area->flag & AREA_FLAG_ACTIVE_TOOL_UPDATE) { | ||||
| if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { | if ((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) { | ||||
| WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), area); | WM_toolsystem_update_from_context(C, CTX_wm_workspace(C), CTX_data_view_layer(C), area); | ||||
| } | } | ||||
| area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; | area->flag &= ~AREA_FLAG_ACTIVE_TOOL_UPDATE; | ||||
| } | } | ||||
| /* Then do actual drawing of regions. */ | /* Then do actual drawing of regions. */ | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| if (region->visible && region->do_draw) { | if (region->visible && region->do_draw) { | ||||
| CTX_wm_region_set(C, region); | CTX_wm_region_set(C, region); | ||||
| bool use_viewport = wm_region_use_viewport(area, region); | bool use_viewport = wm_region_use_viewport(area, region); | ||||
| if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) { | if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) { | ||||
| wm_draw_region_buffer_create(region, true, use_viewport); | wm_draw_region_buffer_create(region, true, use_viewport); | ||||
| for (int view = 0; view < 2; view++) { | for (int view = 0; view < 2; view++) { | ||||
| Show All 27 Lines | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| } | } | ||||
| } | } | ||||
| wm_area_mark_invalid_backbuf(area); | wm_area_mark_invalid_backbuf(area); | ||||
| CTX_wm_area_set(C, NULL); | CTX_wm_area_set(C, NULL); | ||||
| } | } | ||||
| /* Draw menus into their own framebuffer. */ | /* Draw menus into their own framebuffer. */ | ||||
| for (ARegion *region = screen->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { | ||||
| if (region->visible) { | if (region->visible) { | ||||
| CTX_wm_menu_set(C, region); | CTX_wm_menu_set(C, region); | ||||
| if (region->type && region->type->layout) { | if (region->type && region->type->layout) { | ||||
| /* UI code reads the OpenGL state, but we have to refresh | /* UI code reads the OpenGL state, but we have to refresh | ||||
| * the UI layout beforehand in case the menu size changes. */ | * the UI layout beforehand in case the menu size changes. */ | ||||
| wmViewport(®ion->winrct); | wmViewport(®ion->winrct); | ||||
| region->type->layout(C, region); | region->type->layout(C, region); | ||||
| Show All 26 Lines | |||||
| #if 0 | #if 0 | ||||
| glClearColor(0, 0, 0, 0); | glClearColor(0, 0, 0, 0); | ||||
| glClear(GL_COLOR_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT); | ||||
| #endif | #endif | ||||
| /* Blit non-overlapping area regions. */ | /* Blit non-overlapping area regions. */ | ||||
| ED_screen_areas_iter(win, screen, area) | ED_screen_areas_iter(win, screen, area) | ||||
| { | { | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | 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 paint cursors. */ | ||||
| if (wm->paintcursors.first) { | if (wm->paintcursors.first) { | ||||
| ED_screen_areas_iter(win, screen, area) | ED_screen_areas_iter(win, screen, area) | ||||
| { | { | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| if (region->visible && region == screen->active_region) { | if (region->visible && region == screen->active_region) { | ||||
| CTX_wm_area_set(C, area); | CTX_wm_area_set(C, area); | ||||
| CTX_wm_region_set(C, region); | CTX_wm_region_set(C, region); | ||||
| /* make region ready for draw, scissor, pixelspace */ | /* make region ready for draw, scissor, pixelspace */ | ||||
| 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) | ||||
| { | { | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | 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); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* After area regions so we can do area 'overlay' drawing. */ | /* After area regions so we can do area 'overlay' drawing. */ | ||||
| ED_screen_draw_edges(win); | ED_screen_draw_edges(win); | ||||
| wm_draw_callbacks(win); | wm_draw_callbacks(win); | ||||
| /* Blend in floating regions (menus). */ | /* Blend in floating regions (menus). */ | ||||
| for (ARegion *region = screen->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { | ||||
| if (region->visible) { | if (region->visible) { | ||||
| wm_draw_region_blend(region, 0, true); | wm_draw_region_blend(region, 0, true); | ||||
| } | } | ||||
| } | } | ||||
| /* always draw, not only when screen tagged */ | /* always draw, not only when screen tagged */ | ||||
| if (win->gesture.first) { | if (win->gesture.first) { | ||||
| wm_gesture_draw(win); | wm_gesture_draw(win); | ||||
| ▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
| /* Clear drawing flags, after drawing is complete so any draw flags set during | /* Clear drawing flags, after drawing is complete so any draw flags set during | ||||
| * drawing don't cause any additional redraws. */ | * drawing don't cause any additional redraws. */ | ||||
| static void wm_draw_update_clear_window(bContext *C, wmWindow *win) | static void wm_draw_update_clear_window(bContext *C, wmWindow *win) | ||||
| { | { | ||||
| bScreen *screen = WM_window_get_active_screen(win); | bScreen *screen = WM_window_get_active_screen(win); | ||||
| ED_screen_areas_iter(win, screen, area) | ED_screen_areas_iter(win, screen, area) | ||||
| { | { | ||||
| for (ARegion *region = area->regionbase.first; region; region = region->next) { | LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { | ||||
| wm_region_test_gizmo_do_draw(C, area, region, false); | wm_region_test_gizmo_do_draw(C, area, region, false); | ||||
| } | } | ||||
| } | } | ||||
| screen->do_draw_gesture = false; | screen->do_draw_gesture = false; | ||||
| screen->do_draw_paintcursor = false; | screen->do_draw_paintcursor = false; | ||||
| screen->do_draw_drag = false; | screen->do_draw_drag = false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 123 Lines • Show Last 20 Lines | |||||