Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_draw.c
| Show First 20 Lines • Show All 541 Lines • ▼ Show 20 Lines | |||||
| * Calculates a scale factor to squash the preview for \a screen into a rectangle | * Calculates a scale factor to squash the preview for \a screen into a rectangle | ||||
| * of given size and aspect. | * of given size and aspect. | ||||
| */ | */ | ||||
| static void screen_preview_scale_get( | static void screen_preview_scale_get( | ||||
| const bScreen *screen, float size_x, float size_y, const float asp[2], float r_scale[2]) | const bScreen *screen, float size_x, float size_y, const float asp[2], float r_scale[2]) | ||||
| { | { | ||||
| float max_x = 0, max_y = 0; | float max_x = 0, max_y = 0; | ||||
| for (ScrArea *area = screen->areabase.first; area; area = area->next) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| max_x = MAX2(max_x, area->totrct.xmax); | max_x = MAX2(max_x, area->totrct.xmax); | ||||
| max_y = MAX2(max_y, area->totrct.ymax); | max_y = MAX2(max_y, area->totrct.ymax); | ||||
| } | } | ||||
| r_scale[0] = (size_x * asp[0]) / max_x; | r_scale[0] = (size_x * asp[0]) / max_x; | ||||
| r_scale[1] = (size_y * asp[1]) / max_y; | r_scale[1] = (size_y * asp[1]) / max_y; | ||||
| } | } | ||||
| static void screen_preview_draw_areas(const bScreen *screen, | static void screen_preview_draw_areas(const bScreen *screen, | ||||
| const float scale[2], | const float scale[2], | ||||
| const float col[4], | const float col[4], | ||||
| const float ofs_between_areas) | const float ofs_between_areas) | ||||
| { | { | ||||
| const float ofs_h = ofs_between_areas * 0.5f; | const float ofs_h = ofs_between_areas * 0.5f; | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(col); | immUniformColor4fv(col); | ||||
| for (ScrArea *area = screen->areabase.first; area; area = area->next) { | LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { | ||||
| rctf rect = { | rctf rect = { | ||||
| .xmin = area->totrct.xmin * scale[0] + ofs_h, | .xmin = area->totrct.xmin * scale[0] + ofs_h, | ||||
| .xmax = area->totrct.xmax * scale[0] - ofs_h, | .xmax = area->totrct.xmax * scale[0] - ofs_h, | ||||
| .ymin = area->totrct.ymin * scale[1] + ofs_h, | .ymin = area->totrct.ymin * scale[1] + ofs_h, | ||||
| .ymax = area->totrct.ymax * scale[1] - ofs_h, | .ymax = area->totrct.ymax * scale[1] - ofs_h, | ||||
| }; | }; | ||||
| immBegin(GPU_PRIM_TRI_FAN, 4); | immBegin(GPU_PRIM_TRI_FAN, 4); | ||||
| ▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines | |||||