diff --git a/source/blender/editors/screen/screen_draw.cc b/source/blender/editors/screen/screen_draw.cc index 6f332512d90..5edd7ad6220 100644 --- a/source/blender/editors/screen/screen_draw.cc +++ b/source/blender/editors/screen/screen_draw.cc @@ -353,72 +353,3 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const immUnbindProgram(); } - -/* -------------------------------------------------------------------- */ -/* Screen Thumbnail Preview */ - -/** - * Calculates a scale factor to squash the preview for \a screen into a rectangle - * of given size and aspect. - */ -static void screen_preview_scale_get( - const bScreen *screen, float size_x, float size_y, const float asp[2], float r_scale[2]) -{ - float max_x = 0, max_y = 0; - - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - max_x = MAX2(max_x, area->totrct.xmax); - max_y = MAX2(max_y, area->totrct.ymax); - } - r_scale[0] = (size_x * asp[0]) / max_x; - r_scale[1] = (size_y * asp[1]) / max_y; -} - -static void screen_preview_draw_areas(const bScreen *screen, - const float scale[2], - const float col[4], - const float ofs_between_areas) -{ - const float ofs_h = ofs_between_areas * 0.5f; - uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - - immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); - immUniformColor4fv(col); - - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - rctf rect{}; - rect.xmin = area->totrct.xmin * scale[0] + ofs_h; - rect.xmax = area->totrct.xmax * scale[0] - ofs_h; - rect.ymin = area->totrct.ymin * scale[1] + ofs_h; - rect.ymax = area->totrct.ymax * scale[1] - ofs_h; - - immBegin(GPU_PRIM_TRI_FAN, 4); - immVertex2f(pos, rect.xmin, rect.ymin); - immVertex2f(pos, rect.xmax, rect.ymin); - immVertex2f(pos, rect.xmax, rect.ymax); - immVertex2f(pos, rect.xmin, rect.ymax); - immEnd(); - } - - immUnbindProgram(); -} - -static void screen_preview_draw(const bScreen *screen, int size_x, int size_y) -{ - const float asp[2] = {1.0f, 0.8f}; /* square previews look a bit ugly */ - /* could use theme color (tui.wcol_menu_item.text), - * but then we'd need to regenerate all previews when changing. */ - const float col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - float scale[2]; - - wmOrtho2(0.0f, size_x, 0.0f, size_y); - /* center */ - GPU_matrix_push(); - GPU_matrix_identity_set(); - GPU_matrix_translate_2f(size_x * (1.0f - asp[0]) * 0.5f, size_y * (1.0f - asp[1]) * 0.5f); - - screen_preview_scale_get(screen, size_x, size_y, asp, scale); - screen_preview_draw_areas(screen, scale, col, 1.5f); - - GPU_matrix_pop(); -}