diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_draw.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 116 |
1 files changed, 81 insertions, 35 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 1d3db3e7609..b11dae27d19 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -53,6 +53,7 @@ #include "GPU_batch_presets.h" #include "GPU_context.h" +#include "GPU_debug.h" #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_state.h" @@ -85,7 +86,6 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); bScreen *screen = WM_window_get_active_screen(win); - wmPaintCursor *pc; /* Don't draw paint cursors with locked interface. Painting is not possible * then, and cursor drawing can use scene data that another thread may be @@ -94,36 +94,37 @@ static void wm_paintcursor_draw(bContext *C, ScrArea *area, ARegion *region) return; } - if (region->visible && region == screen->active_region) { - for (pc = wm->paintcursors.first; pc; pc = pc->next) { - - if ((pc->space_type != SPACE_TYPE_ANY) && (area->spacetype != pc->space_type)) { - continue; - } + if (!region->visible || region != screen->active_region) { + return; + } - if ((pc->region_type != RGN_TYPE_ANY) && (region->regiontype != pc->region_type)) { - continue; - } + LISTBASE_FOREACH (wmPaintCursor *, pc, &wm->paintcursors) { + if ((pc->space_type != SPACE_TYPE_ANY) && (area->spacetype != pc->space_type)) { + continue; + } - if (pc->poll == NULL || pc->poll(C)) { - /* Prevent drawing outside region. */ - GPU_scissor_test(true); - GPU_scissor(region->winrct.xmin, - region->winrct.ymin, - BLI_rcti_size_x(®ion->winrct) + 1, - BLI_rcti_size_y(®ion->winrct) + 1); - - if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { - int x = 0, y = 0; - wm_get_cursor_position(win, &x, &y); - pc->draw(C, x, y, pc->customdata); - } - else { - pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata); - } + if (!ELEM(pc->region_type, RGN_TYPE_ANY, region->regiontype)) { + continue; + } - GPU_scissor_test(false); + if (pc->poll == NULL || pc->poll(C)) { + /* Prevent drawing outside region. */ + GPU_scissor_test(true); + GPU_scissor(region->winrct.xmin, + region->winrct.ymin, + BLI_rcti_size_x(®ion->winrct) + 1, + BLI_rcti_size_y(®ion->winrct) + 1); + + if (ELEM(win->grabcursor, GHOST_kGrabWrap, GHOST_kGrabHide)) { + int x = 0, y = 0; + wm_get_cursor_position(win, &x, &y); + pc->draw(C, x, y, pc->customdata); + } + else { + pc->draw(C, win->eventstate->x, win->eventstate->y, pc->customdata); } + + GPU_scissor_test(false); } } } @@ -318,6 +319,37 @@ bool WM_region_use_viewport(ScrArea *area, ARegion *region) return wm_region_use_viewport_by_type(area->spacetype, region->regiontype); } +static const char *wm_area_name(ScrArea *area) +{ +#define SPACE_NAME(space) \ + case space: \ + return #space; + + switch (area->spacetype) { + SPACE_NAME(SPACE_EMPTY); + SPACE_NAME(SPACE_VIEW3D); + SPACE_NAME(SPACE_GRAPH); + SPACE_NAME(SPACE_OUTLINER); + SPACE_NAME(SPACE_PROPERTIES); + SPACE_NAME(SPACE_FILE); + SPACE_NAME(SPACE_IMAGE); + SPACE_NAME(SPACE_INFO); + SPACE_NAME(SPACE_SEQ); + SPACE_NAME(SPACE_TEXT); + SPACE_NAME(SPACE_ACTION); + SPACE_NAME(SPACE_NLA); + SPACE_NAME(SPACE_SCRIPT); + SPACE_NAME(SPACE_NODE); + SPACE_NAME(SPACE_CONSOLE); + SPACE_NAME(SPACE_USERPREF); + SPACE_NAME(SPACE_CLIP); + SPACE_NAME(SPACE_TOPBAR); + SPACE_NAME(SPACE_STATUSBAR); + default: + return "Unkown Space"; + } +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -396,9 +428,6 @@ static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen) /* Setup offscreen color texture for drawing. */ GPUTexture *texture = GPU_offscreen_color_texture(offscreen); - /* We don't support multisample textures here. */ - BLI_assert(GPU_texture_target(texture) == GL_TEXTURE_2D); - /* No mipmaps or filtering. */ GPU_texture_mipmap_mode(texture, false, false); } @@ -638,6 +667,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) /* Draw screen areas into own frame buffer. */ ED_screen_areas_iter (win, screen, area) { CTX_wm_area_set(C, area); + GPU_debug_group_begin(wm_area_name(area)); /* Compute UI layouts for dynamically size regions. */ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { @@ -671,6 +701,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) CTX_wm_region_set(C, region); bool use_viewport = WM_region_use_viewport(area, region); + GPU_debug_group_begin(use_viewport ? "Viewport" : "ARegion"); + if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) { wm_draw_region_buffer_create(region, true, use_viewport); @@ -700,6 +732,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) wm_draw_region_unbind(region); } + GPU_debug_group_end(); + region->do_draw = false; CTX_wm_region_set(C, NULL); } @@ -707,6 +741,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) wm_area_mark_invalid_backbuf(area); CTX_wm_area_set(C, NULL); + + GPU_debug_group_end(); } /* Draw menus into their own framebuffer. */ @@ -714,6 +750,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) if (region->visible) { CTX_wm_menu_set(C, region); + GPU_debug_group_begin("Menu"); + if (region->type && region->type->layout) { /* UI code reads the OpenGL state, but we have to refresh * the UI layout beforehand in case the menu size changes. */ @@ -727,6 +765,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) ED_region_do_draw(C, region); wm_draw_region_unbind(region); + GPU_debug_group_end(); + region->do_draw = false; CTX_wm_menu_set(C, NULL); } @@ -738,6 +778,8 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) wmWindowManager *wm = CTX_wm_manager(C); bScreen *screen = WM_window_get_active_screen(win); + GPU_debug_group_begin("Window Redraw"); + /* Draw into the window framebuffer, in full window coordinates. */ wmWindowViewport(win); @@ -813,12 +855,18 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) if (wm->drags.first) { wm_drags_draw(C, win, NULL); } + + GPU_debug_group_end(); } static void wm_draw_window(bContext *C, wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); bool stereo = WM_stereo3d_enabled(win, false); + + /* Avoid any BGL call issued before this to alter the window drawin. */ + GPU_bgl_end(); + /* Draw area regions into their own framebuffer. This way we can redraw * the areas that need it, and blit the rest from existing framebuffers. */ wm_draw_window_offscreen(C, win, stereo); @@ -912,10 +960,9 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win) ViewLayer *view_layer = WM_window_get_active_view_layer(win); struct Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer); bScreen *screen = WM_window_get_active_screen(win); - ARegion *region; bool do_draw = false; - for (region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { if (region->do_draw_paintcursor) { screen->do_draw_paintcursor = true; region->do_draw_paintcursor = false; @@ -926,7 +973,7 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win) } ED_screen_areas_iter (win, screen, area) { - for (region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { wm_region_test_gizmo_do_draw(C, area, region, true); wm_region_test_render_do_draw(scene, depsgraph, area, region); #ifdef WITH_XR_OPENXR @@ -995,12 +1042,11 @@ void wm_draw_update(bContext *C) { Main *bmain = CTX_data_main(C); wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *win; GPU_context_main_lock(); BKE_image_free_unused_gpu_textures(); - for (win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { #ifdef WIN32 GHOST_TWindowState state = GHOST_GetWindowState(win->ghostwin); |