Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/area.c
| Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | static void region_draw_emboss(const ARegion *region, const rcti *scirct, int sides) | ||||
| /* set transp line */ | /* set transp line */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| float color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; | float color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; | ||||
| UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); | UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(color); | immUniformColor4fv(color); | ||||
| immBeginAtMost(GPU_PRIM_LINES, 8); | immBeginAtMost(GPU_PRIM_LINES, 8); | ||||
| /* right */ | /* right */ | ||||
| if (sides & REGION_EMBOSS_RIGHT) { | if (sides & REGION_EMBOSS_RIGHT) { | ||||
| immVertex2f(pos, rect.xmax, rect.ymax); | immVertex2f(pos, rect.xmax, rect.ymax); | ||||
| immVertex2f(pos, rect.xmax, rect.ymin); | immVertex2f(pos, rect.xmax, rect.ymin); | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | default: | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| return; | return; | ||||
| } | } | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| /* NOTE(fclem): There is something strange going on with Mesa and GPU_SHADER_2D_UNIFORM_COLOR | |||||
| * that causes a crash on some GPUs (see T76113). Using 3D variant avoid the issue. */ | |||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4f(0.8f, 0.8f, 0.8f, 0.4f); | immUniformColor4f(0.8f, 0.8f, 0.8f, 0.4f); | ||||
| immBegin(GPU_PRIM_TRI_FAN, 6); | immBegin(GPU_PRIM_TRI_FAN, 6); | ||||
| for (int i = 0; i < 6; i++) { | for (int i = 0; i < 6; i++) { | ||||
| if (axis == 0) { | if (axis == 0) { | ||||
| immVertex2f(pos, center[0] + points[i][0] * size, center[1] + points[i][1] * sign * size); | immVertex2f(pos, center[0] + points[i][0] * size, center[1] + points[i][1] * sign * size); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | void ED_region_do_draw(bContext *C, ARegion *region) | ||||
| region_draw_azones(area, region); | region_draw_azones(area, region); | ||||
| /* for debugging unneeded area redraws and partial redraw */ | /* for debugging unneeded area redraws and partial redraw */ | ||||
| if (G.debug_value == 888) { | if (G.debug_value == 888) { | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4f(BLI_thread_frand(0), BLI_thread_frand(0), BLI_thread_frand(0), 0.1f); | immUniformColor4f(BLI_thread_frand(0), BLI_thread_frand(0), BLI_thread_frand(0), 0.1f); | ||||
| immRectf(pos, | immRectf(pos, | ||||
| region->drawrct.xmin - region->winrct.xmin, | region->drawrct.xmin - region->winrct.xmin, | ||||
| region->drawrct.ymin - region->winrct.ymin, | region->drawrct.ymin - region->winrct.ymin, | ||||
| region->drawrct.xmax - region->winrct.xmin, | region->drawrct.xmax - region->winrct.xmin, | ||||
| region->drawrct.ymax - region->winrct.ymin); | region->drawrct.ymax - region->winrct.ymin); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| Show All 13 Lines | if (area) { | ||||
| else if ((region->regiontype == RGN_TYPE_WINDOW) && (region->alignment == RGN_ALIGN_QSPLIT)) { | else if ((region->regiontype == RGN_TYPE_WINDOW) && (region->alignment == RGN_ALIGN_QSPLIT)) { | ||||
| /* draw separating lines between the quad views */ | /* draw separating lines between the quad views */ | ||||
| float color[4] = {0.0f, 0.0f, 0.0f, 0.8f}; | float color[4] = {0.0f, 0.0f, 0.0f, 0.8f}; | ||||
| UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); | UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(color); | immUniformColor4fv(color); | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| imm_draw_box_wire_2d(pos, | imm_draw_box_wire_2d(pos, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| region->winrct.xmax - region->winrct.xmin + 1, | region->winrct.xmax - region->winrct.xmin + 1, | ||||
| region->winrct.ymax - region->winrct.ymin + 1); | region->winrct.ymax - region->winrct.ymin + 1); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| ▲ Show 20 Lines • Show All 2,948 Lines • ▼ Show 20 Lines | void ED_region_info_draw_multiline(ARegion *region, | ||||
| /* setup scissor */ | /* setup scissor */ | ||||
| GPU_scissor_get(scissor); | GPU_scissor_get(scissor); | ||||
| GPU_scissor(rect.xmin, rect.ymin, BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1); | GPU_scissor(rect.xmin, rect.ymin, BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(fill_color); | immUniformColor4fv(fill_color); | ||||
| immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); | immRecti(pos, rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| /* text */ | /* text */ | ||||
| UI_FontThemeColor(fontid, TH_TEXT_HI); | UI_FontThemeColor(fontid, TH_TEXT_HI); | ||||
| BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax); | BLF_clipping(fontid, rect.xmin, rect.ymin, rect.xmax, rect.ymax); | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, float y0) | ||||
| UI_view2d_view_to_region(®ion->v2d, x0 + 1.0f, y0 + 1.0f, &x2, &y2); | UI_view2d_view_to_region(®ion->v2d, x0 + 1.0f, y0 + 1.0f, &x2, &y2); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| float gridcolor[4]; | float gridcolor[4]; | ||||
| UI_GetThemeColor4fv(TH_GRID, gridcolor); | UI_GetThemeColor4fv(TH_GRID, gridcolor); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* To fake alpha-blending, color shading is reduced when alpha is nearing 0. */ | /* To fake alpha-blending, color shading is reduced when alpha is nearing 0. */ | ||||
| immUniformThemeColorBlendShade(TH_BACK, TH_GRID, gridcolor[3], 20 * gridcolor[3]); | immUniformThemeColorBlendShade(TH_BACK, TH_GRID, gridcolor[3], 20 * gridcolor[3]); | ||||
| immRectf(pos, x1, y1, x2, y2); | immRectf(pos, x1, y1, x2, y2); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| /* gridsize adapted to zoom level */ | /* gridsize adapted to zoom level */ | ||||
| float gridsize = 0.5f * (zoomx + zoomy); | float gridsize = 0.5f * (zoomx + zoomy); | ||||
| float gridstep = 1.0f / 32.0f; | float gridstep = 1.0f / 32.0f; | ||||
| ▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | |||||
| void ED_region_cache_draw_background(ARegion *region) | void ED_region_cache_draw_background(ARegion *region) | ||||
| { | { | ||||
| /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ | /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ | ||||
| const rcti *rect_visible = ED_region_visible_rect(region); | const rcti *rect_visible = ED_region_visible_rect(region); | ||||
| const int region_bottom = rect_visible->ymin; | const int region_bottom = rect_visible->ymin; | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4ub(128, 128, 255, 64); | immUniformColor4ub(128, 128, 255, 64); | ||||
| immRecti(pos, 0, region_bottom, region->winx, region_bottom + 8 * UI_DPI_FAC); | immRecti(pos, 0, region_bottom, region->winx, region_bottom + 8 * UI_DPI_FAC); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y) | void ED_region_cache_draw_curfra_label(const int framenr, const float x, const float y) | ||||
| { | { | ||||
| const uiStyle *style = UI_style_get(); | const uiStyle *style = UI_style_get(); | ||||
| int fontid = style->widget.uifont_id; | int fontid = style->widget.uifont_id; | ||||
| char numstr[32]; | char numstr[32]; | ||||
| float font_dims[2] = {0.0f, 0.0f}; | float font_dims[2] = {0.0f, 0.0f}; | ||||
| /* frame number */ | /* frame number */ | ||||
| BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); | BLF_size(fontid, 11.0f * U.pixelsize, U.dpi); | ||||
| BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); | BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); | ||||
| BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); | BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformThemeColor(TH_CFRAME); | immUniformThemeColor(TH_CFRAME); | ||||
| immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); | immRecti(pos, x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| UI_FontThemeColor(fontid, TH_TEXT); | UI_FontThemeColor(fontid, TH_TEXT); | ||||
| BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f); | BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f); | ||||
| BLF_draw(fontid, numstr, sizeof(numstr)); | BLF_draw(fontid, numstr, sizeof(numstr)); | ||||
| } | } | ||||
| void ED_region_cache_draw_cached_segments( | void ED_region_cache_draw_cached_segments( | ||||
| ARegion *region, const int num_segments, const int *points, const int sfra, const int efra) | ARegion *region, const int num_segments, const int *points, const int sfra, const int efra) | ||||
| { | { | ||||
| if (num_segments) { | if (num_segments) { | ||||
| /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ | /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ | ||||
| const rcti *rect_visible = ED_region_visible_rect(region); | const rcti *rect_visible = ED_region_visible_rect(region); | ||||
| const int region_bottom = rect_visible->ymin; | const int region_bottom = rect_visible->ymin; | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4ub(128, 128, 255, 128); | immUniformColor4ub(128, 128, 255, 128); | ||||
| for (int a = 0; a < num_segments; a++) { | for (int a = 0; a < num_segments; a++) { | ||||
| float x1 = (float)(points[a * 2] - sfra) / (efra - sfra + 1) * region->winx; | float x1 = (float)(points[a * 2] - sfra) / (efra - sfra + 1) * region->winx; | ||||
| float x2 = (float)(points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * region->winx; | float x2 = (float)(points[a * 2 + 1] - sfra + 1) / (efra - sfra + 1) * region->winx; | ||||
| immRecti(pos, x1, region_bottom, x2, region_bottom + 8 * UI_DPI_FAC); | immRecti(pos, x1, region_bottom, x2, region_bottom + 8 * UI_DPI_FAC); | ||||
| /* TODO(merwin): use primitive restart to draw multiple rects more efficiently */ | /* TODO(merwin): use primitive restart to draw multiple rects more efficiently */ | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||