From f18e53745151eee946dcc01bc4b526994971daef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sun, 23 Aug 2020 11:11:27 +0200 Subject: Cleanup: GPU: Use explicit clear value in GPU_clear* commands This replace `GPU_clear()` by `GPU_clear_color()` and `GPU_clear_depth()`. Since we always set the clear value before clearing, it is unecessary to track the clear color state. Moreover, it makes it clearer what we clear the framebuffer to. --- source/blender/editors/gpencil/gpencil_fill.c | 2 +- source/blender/editors/include/UI_resources.h | 5 +---- source/blender/editors/interface/interface_panel.c | 4 ---- source/blender/editors/interface/interface_region_hud.c | 3 +-- source/blender/editors/interface/resources.c | 7 ------- source/blender/editors/render/render_opengl.c | 2 +- source/blender/editors/screen/area.c | 5 ----- source/blender/editors/screen/screen_draw.c | 4 ++-- source/blender/editors/space_action/space_action.c | 2 -- source/blender/editors/space_clip/space_clip.c | 4 ---- source/blender/editors/space_console/space_console.c | 1 - source/blender/editors/space_file/space_file.c | 5 +---- source/blender/editors/space_graph/space_graph.c | 10 ++-------- source/blender/editors/space_image/space_image.c | 2 -- source/blender/editors/space_info/info_draw.c | 1 - source/blender/editors/space_info/space_info.c | 1 - source/blender/editors/space_nla/space_nla.c | 2 -- source/blender/editors/space_node/node_draw.c | 4 +--- source/blender/editors/space_outliner/space_outliner.c | 1 - source/blender/editors/space_script/space_script.c | 1 - source/blender/editors/space_sequencer/sequencer_draw.c | 7 +------ source/blender/editors/space_text/space_text.c | 1 - source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/editors/uvedit/uvedit_draw.c | 1 - 24 files changed, 12 insertions(+), 65 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index ae9146b3a6a..eb4304a3746 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -455,7 +455,7 @@ static bool gpencil_render_offscreen(tGPDfill *tgpf) GPU_matrix_identity_set(); GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); - GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); ED_view3d_update_viewmat( tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->region, NULL, winmat, NULL, true); diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 3f548f98e97..5e3c8feb333 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -431,12 +431,9 @@ void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], // (for anything fancy use UI_GetThemeColor[Fancy] then BLF_color) void UI_FontThemeColor(int fontid, int colorid); -// clear the openGL ClearColor using the input colorid +// clear the framebuffer using the input colorid void UI_ThemeClearColor(int colorid); -// clear the openGL ClearColor using the input colorid using optional transparency -void UI_ThemeClearColorAlpha(int colorid, float alpha); - // internal (blender) usage only, for init and set active void UI_SetTheme(int spacetype, int regionid); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 812aa25568a..4f3c36c0b3b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1442,10 +1442,6 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y) void UI_panels_draw(const bContext *C, ARegion *region) { - if (region->alignment != RGN_ALIGN_FLOAT) { - UI_ThemeClearColor(TH_BACK); - } - /* Draw panels, selected on top. Also in reverse order, because * UI blocks are added in reverse order and we need child panels * to draw on top. */ diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index 1773a7b3057..204653f047d 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -217,8 +217,7 @@ static void hud_region_draw(const bContext *C, ARegion *region) { UI_view2d_view_ortho(®ion->v2d); wmOrtho2_region_pixelspace(region); - GPU_clear_color(0, 0, 0, 0.0f); - GPU_clear(GPU_COLOR_BIT); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); if ((region->flag & RGN_FLAG_HIDDEN) == 0) { ui_draw_menu_back(NULL, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 84fe3e13426..4c2b71514a4 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1474,13 +1474,6 @@ void UI_ThemeClearColor(int colorid) GPU_clear_color(col[0], col[1], col[2], 1.0f); } -void UI_ThemeClearColorAlpha(int colorid, float alpha) -{ - float col[3]; - UI_GetThemeColor3fv(colorid, col); - GPU_clear_color(col[0], col[1], col[2], alpha); -} - int UI_ThemeMenuShadowWidth(void) { bTheme *btheme = UI_GetTheme(); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 52a7b92217b..940ca963fc6 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -339,7 +339,7 @@ static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, R GPU_offscreen_bind(oglrender->ofs, true); GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); - GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); GPU_matrix_reset(); wmOrtho2(0, scene->r.xsch, 0, scene->r.ysch); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 80fa5a7815d..921cc92299e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -351,11 +351,9 @@ static void region_draw_status_text(ScrArea *area, ARegion *region) if (overlap) { GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); - GPU_clear(GPU_COLOR_BIT); } else { UI_ThemeClearColor(TH_HEADER); - GPU_clear(GPU_COLOR_BIT); } int fontid = BLF_set_default(); @@ -519,7 +517,6 @@ void ED_region_do_draw(bContext *C, ARegion *region) if (area && area_is_pseudo_minimized(area)) { UI_ThemeClearColor(TH_EDITOR_OUTLINE); - GPU_clear(GPU_COLOR_BIT); return; } /* optional header info instead? */ @@ -2529,11 +2526,9 @@ static void region_clear_color(const bContext *C, const ARegion *region, ThemeCo float back[4]; UI_GetThemeColor4fv(colorid, back); GPU_clear_color(back[3] * back[0], back[3] * back[1], back[3] * back[2], back[3]); - GPU_clear(GPU_COLOR_BIT); } else { UI_ThemeClearColor(colorid); - GPU_clear(GPU_COLOR_BIT); } } diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index 9bb14ee8c01..8ded845b008 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -606,8 +606,8 @@ void ED_screen_preview_render(const bScreen *screen, int size_x, int size_y, uin GPUOffScreen *offscreen = GPU_offscreen_create(size_x, size_y, true, false, err_out); GPU_offscreen_bind(offscreen, true); - GPU_clear_color(0.0, 0.0, 0.0, 0.0); - GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); + GPU_clear_depth(1.0f); screen_preview_draw(screen, size_x, size_y); diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index db55eff8284..cd4197d1df8 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -191,7 +191,6 @@ static void action_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -278,7 +277,6 @@ static void action_channel_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index d27b80efd40..18df8774e09 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -926,7 +926,6 @@ static void clip_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); /* data... */ movieclip_main_area_set_view2d(C, region); @@ -1054,7 +1053,6 @@ static void graph_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1099,7 +1097,6 @@ static void dopesheet_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1172,7 +1169,6 @@ static void clip_channels_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 3a0125356f7..4b554e0c5c0 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -215,7 +215,6 @@ static void console_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); /* worlks best with no view2d matrix set */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index f520f91b89b..61d6d8bf678 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -449,7 +449,6 @@ static void file_main_region_draw(const bContext *C, ARegion *region) FileSelectParams *params = ED_fileselect_get_params(sfile); View2D *v2d = ®ion->v2d; - float col[3]; /* Needed, because filelist is not initialized on loading */ if (!sfile->files || filelist_empty(sfile->files)) { @@ -457,9 +456,7 @@ static void file_main_region_draw(const bContext *C, ARegion *region) } /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - GPU_clear_color(col[0], col[1], col[2], 1.0f); - GPU_clear(GPU_COLOR_BIT); + UI_ThemeClearColor(TH_BACK); /* Allow dynamically sliders to be set, saves notifiers etc. */ diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 4e0f60544e6..a1e75e2b9b2 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -200,12 +200,9 @@ static void graph_main_region_draw(const bContext *C, ARegion *region) Scene *scene = CTX_data_scene(C); bAnimContext ac; View2D *v2d = ®ion->v2d; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - GPU_clear_color(col[0], col[1], col[2], 1.0f); - GPU_clear(GPU_COLOR_BIT); + UI_ThemeClearColor(TH_BACK); UI_view2d_view_ortho(v2d); @@ -358,12 +355,9 @@ static void graph_channel_region_draw(const bContext *C, ARegion *region) { bAnimContext ac; View2D *v2d = ®ion->v2d; - float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_BACK, col); - GPU_clear_color(col[0], col[1], col[2], 1.0f); - GPU_clear(GPU_COLOR_BIT); + UI_ThemeClearColor(TH_BACK); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1f7929cea7b..a806e3e25d1 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -650,7 +650,6 @@ static void image_main_region_draw(const bContext *C, ARegion *region) GPU_framebuffer_bind(framebuffer_default); GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); - GPU_clear(GPU_COLOR_BIT); GPU_framebuffer_bind(framebuffer_overlay); @@ -661,7 +660,6 @@ static void image_main_region_draw(const bContext *C, ARegion *region) UI_GetThemeColor3fv(TH_BACK, col); srgb_to_linearrgb_v3_v3(col, col); GPU_clear_color(col[0], col[1], col[2], 1.0f); - GPU_clear(GPU_COLOR_BIT); GPU_depth_test(GPU_DEPTH_NONE); image_user_refresh_scene(C, sima); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 72533b88406..595da97c75a 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -147,7 +147,6 @@ static int report_textview_begin(TextViewContext *tvc) tvc->iter = reports->list.last; UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); tvc->iter_tmp = 0; if (tvc->iter && report_textview_skip__internal(tvc)) { diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index b9153ec0cbd..8d3f21aefeb 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -142,7 +142,6 @@ static void info_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); /* quick way to avoid drawing if not bug enough */ if (region->winy < 16) { diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 7bbfe451eed..7a0cd35ece1 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -194,7 +194,6 @@ static void nla_channel_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -238,7 +237,6 @@ static void nla_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 917bb8e75fd..56e53e79a8d 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1343,8 +1343,6 @@ static void node_draw_basis(const bContext *C, } } - UI_ThemeClearColor(color_id); - UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1737,8 +1735,8 @@ void drawnodespace(const bContext *C, ARegion *region) UI_view2d_view_ortho(v2d); UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); GPU_depth_test(GPU_DEPTH_NONE); + GPU_scissor_test(true); /* XXX snode->cursor set in coordspace for placing new nodes, used for drawing noodles too */ UI_view2d_region_to_view(®ion->v2d, diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 6854367d975..6a63c3c65c3 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -87,7 +87,6 @@ static void outliner_main_region_draw(const bContext *C, ARegion *region) /* clear */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); draw_outliner(C); diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 4d0c2b658c6..3c3f7dc1e8e 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -127,7 +127,6 @@ static void script_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 066ab3b1f23..bd4503dbe54 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1529,11 +1529,7 @@ static void sequencer_stop_running_jobs(const bContext *C, Scene *scene) static void sequencer_preview_clear(void) { - float col[3]; - - UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); - GPU_clear_color(col[0], col[1], col[2], 1.0f); - GPU_clear(GPU_COLOR_BIT); + UI_ThemeClearColor(TH_SEQ_PREVIEW); } static void sequencer_preview_get_rect(rctf *preview, @@ -2266,7 +2262,6 @@ void draw_timeline_seq(const bContext *C, ARegion *region) else { GPU_clear_color(col[0], col[1], col[2], 0.0f); } - GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); /* Get timeline boundbox, needed for the scrollers. */ diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index f6d00ec94bf..300f63761c0 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -296,7 +296,6 @@ static void text_main_region_draw(const bContext *C, ARegion *region) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); // UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 4cc48dfd175..195199c45cd 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2319,7 +2319,7 @@ void ED_view3d_draw_depth_gpencil(Depsgraph *depsgraph, Scene *scene, ARegion *r /* Setup view matrix. */ ED_view3d_draw_setup_view(NULL, NULL, depsgraph, scene, region, v3d, NULL, NULL, NULL); - GPU_clear(GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); GPU_depth_test(GPU_DEPTH_LESS_EQUAL); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index d80e7f3c754..53f3694bf98 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -553,7 +553,6 @@ void ED_uvedit_draw_main(SpaceImage *sima, view_layer, ((View3D *)NULL), &objects_len); if (objects_len > 0) { GPU_clear_depth(1.0f); - GPU_clear(GPU_DEPTH_BIT); } /* go over all objects and create the batches + add their areas to the total */ -- cgit v1.2.3