From 969bcf0793dca0e75bf42998aba92b1abd90ec23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sun, 16 Aug 2020 15:16:21 +0200 Subject: Cleanup: GPUState: Replace blend func separate by enum --- source/blender/blenfont/intern/blf_font.c | 3 +-- source/blender/draw/intern/draw_manager.c | 3 +-- .../editors/animation/anim_channels_defines.c | 3 +-- source/blender/editors/animation/anim_draw.c | 6 ++--- source/blender/editors/animation/anim_markers.c | 6 ++--- source/blender/editors/animation/time_scrub_ui.c | 3 +-- source/blender/editors/gpencil/annotate_draw.c | 3 +-- source/blender/editors/gpencil/annotate_paint.c | 3 +-- source/blender/editors/gpencil/gpencil_paint.c | 3 +-- source/blender/editors/gpencil/gpencil_utils.c | 3 +-- source/blender/editors/interface/interface.c | 3 +-- source/blender/editors/interface/interface_draw.c | 31 ++++++++-------------- source/blender/editors/interface/interface_icons.c | 18 +++++-------- .../blender/editors/interface/interface_widgets.c | 6 ++--- source/blender/editors/mask/mask_draw.c | 3 +-- source/blender/editors/mesh/editmesh_knife.c | 3 +-- source/blender/editors/screen/area.c | 12 +++------ source/blender/editors/screen/screen_draw.c | 12 +++------ source/blender/editors/space_clip/clip_draw.c | 9 +++---- source/blender/editors/space_clip/clip_utils.c | 3 +-- source/blender/editors/space_file/file_draw.c | 6 ++--- source/blender/editors/space_graph/graph_draw.c | 3 +-- source/blender/editors/space_image/image_draw.c | 15 ++++------- source/blender/editors/space_info/textview.c | 3 +-- source/blender/editors/space_nla/nla_draw.c | 9 +++---- source/blender/editors/space_node/drawnode.c | 3 +-- source/blender/editors/space_node/node_draw.c | 6 ++--- .../blender/editors/space_outliner/outliner_draw.c | 3 +-- .../editors/space_sequencer/sequencer_draw.c | 15 ++++------- source/blender/editors/space_text/text_draw.c | 3 +-- source/blender/editors/space_view3d/drawobject.c | 3 +-- source/blender/editors/space_view3d/view3d_draw.c | 9 +++---- source/blender/editors/transform/transform.c | 3 +-- .../editors/transform/transform_mode_edge_slide.c | 3 +-- .../editors/transform/transform_mode_vert_slide.c | 3 +-- source/blender/editors/uvedit/uvedit_draw.c | 3 +-- source/blender/gpu/GPU_state.h | 5 +--- source/blender/gpu/intern/gpu_state.cc | 29 ++------------------ source/blender/windowmanager/intern/wm_playanim.c | 3 +-- 39 files changed, 80 insertions(+), 183 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 76829db755c..2a6bc41704b 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -222,8 +222,7 @@ void blf_batch_draw(void) } GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); #ifndef BLF_STANDALONE /* We need to flush widget base first to ensure correct ordering. */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 4aa12ff2d23..664d514a77e 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1606,8 +1606,7 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph, if (draw_background) { /* Reset default. */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(false); } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 53401e0c05a..aa5dffffe36 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4386,8 +4386,7 @@ void ANIM_channel_draw( } /* set blending again, as may not be set in previous step */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); /* step 1) draw backdrop ........................................... */ diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index b2f687b49af..16c6638b6d9 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -98,8 +98,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) /* only draw this if preview range is set */ if (PRVRANGEON) { - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); GPUVertFormat *format = immVertexFormat(); @@ -133,8 +132,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) void ANIM_draw_framerange(Scene *scene, View2D *v2d) { /* draw darkened area outside of active timeline frame range */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); GPUVertFormat *format = immVertexFormat(); diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index bcdbf4c74f0..4e4e6b38342 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -500,8 +500,7 @@ static void draw_marker( marker_color_get(marker, text_color, line_color); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); draw_marker_line(line_color, xpos, UI_DPI_FAC * 20, region_height); @@ -530,8 +529,7 @@ static void draw_markers_background(rctf *rect) immUniformColor4ubv(shade); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.c index edc36326c57..8c2c01c60de 100644 --- a/source/blender/editors/animation/time_scrub_ui.c +++ b/source/blender/editors/animation/time_scrub_ui.c @@ -67,8 +67,7 @@ static void draw_background(const rcti *rect) immUniformThemeColor(TH_TIME_SCRUB_BACKGROUND); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c index df479325027..e0e8f72fd16 100644 --- a/source/blender/editors/gpencil/annotate_draw.c +++ b/source/blender/editors/gpencil/annotate_draw.c @@ -734,8 +734,7 @@ static void annotation_draw_data( GPU_line_smooth(true); /* turn on alpha-blending */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); /* Do not write to depth (avoid self-occlusion). */ diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 30e4fe0b531..52c6dcc5f77 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1701,8 +1701,7 @@ static void annotation_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_pt GPU_line_smooth(true); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immUniformColor4ub(255, 100, 100, 20); imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 680e7b37d31..81999bc7721 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -2269,8 +2269,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) GPU_line_smooth(true); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immUniformColor4ub(255, 100, 100, 20); imm_draw_circle_fill_2d(shdr_pos, x, y, p->radius, 40); diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 5aae10a5db5..aa3b6991a82 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1761,8 +1761,7 @@ void ED_gpencil_brush_draw_eraser(Brush *brush, int x, int y) GPU_line_smooth(true); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immUniformColor4ub(255, 100, 100, 20); imm_draw_circle_fill_2d(shdr_pos, x, y, radius, 40); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 478ef216421..fc4bf1b5636 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1891,8 +1891,7 @@ void UI_block_draw(const bContext *C, uiBlock *block) } /* we set this only once */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* scale fonts */ ui_fontscale(&style.paneltitle.points, block->aspect); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 0a40c39851a..4cb2b16910e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -754,7 +754,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region), GPU_blend(true); /* Combine with premultiplied alpha. */ - GPU_blend_set_func_separate(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT); if (w != ibuf->x || h != ibuf->y) { /* We scale the bitmap, rather than have OGL do a worse job. */ @@ -782,8 +782,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(region), GPU_blend(false); /* Reset default. */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); # if 0 // restore scissortest @@ -832,8 +831,7 @@ void UI_draw_safe_areas(uint pos, static void draw_scope_end(const rctf *rect) { - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* outline */ UI_draw_roundbox_corner_set(UI_CNR_ALL); @@ -863,7 +861,7 @@ static void histogram_draw_one(float r, } GPU_line_smooth(true); - GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE, GPU_ONE, GPU_ONE); + GPU_blend_set_func_separate(GPU_BLEND_ADDITIVE); immUniformColor4fv(color); @@ -893,8 +891,7 @@ static void histogram_draw_one(float r, /* curve outline */ immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); @@ -928,8 +925,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region), float h = BLI_rctf_size_y(&rect) * hist->ymax; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); float color[4]; UI_GetThemeColor4fv(TH_PREVIEW_BACK, color); @@ -1072,8 +1068,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), BLF_batch_draw_flush(); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); float color[4]; UI_GetThemeColor4fv(TH_PREVIEW_BACK, color); @@ -1101,8 +1096,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), BLF_batch_draw_flush(); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1405,8 +1399,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region), float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); float color[4]; UI_GetThemeColor4fv(TH_PREVIEW_BACK, color); @@ -1963,8 +1956,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, if (but->a1 == UI_GRAD_H) { /* grid, hsv uses different grid */ GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); ARRAY_SET_ITEMS(color_backdrop, 0, 0, 0, 48.0 / 255.0); immUniformColor4fv(color_backdrop); ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 0.1666666f); @@ -2468,8 +2460,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), int height = BLI_rctf_size_y(&rect); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* need scissor test, preview image can draw outside of boundary */ int scissor[4]; diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index a7b7bad2fe6..2dc4081a4c6 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1605,8 +1605,7 @@ static void icon_draw_cache_flush_ex(bool only_full_caches) icon_draw_cache_texture_flush_ex(icongltex.tex[1], &g_icon_draw_cache.border); } - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } } @@ -1726,8 +1725,7 @@ static void icon_draw_texture(float x, GPU_texture_unbind(texture); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } /* Drawing size for preview images */ @@ -1815,11 +1813,9 @@ static void icon_draw_size(float x, di->data.geom.inverted = invert; } - GPU_blend_set_func_separate( - GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT); icon_draw_rect(x, y, w, h, aspect, w, h, ibuf->rect, alpha, desaturate); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } else if (di->type == ICON_TYPE_EVENT) { const short event_type = di->data.input.event_type; @@ -1900,12 +1896,10 @@ static void icon_draw_size(float x, } /* Preview images use premultiplied alpha. */ - GPU_blend_set_func_separate( - GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT); icon_draw_rect( x, y, w, h, aspect, pi->w[size], pi->h[size], pi->rect[size], alpha, desaturate); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } } else if (di->type == ICON_TYPE_GPLAYER) { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 01e03a2a83b..54838dcbdbb 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2784,8 +2784,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir rect->ymax += 0.1f * U.widget_unit; } - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); widget_softshadow(rect, roundboxalign, wcol->roundness * U.widget_unit); @@ -5165,8 +5164,7 @@ static void ui_draw_widget_back_color(uiWidgetTypeEnum type, if (use_shadow) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); widget_softshadow(rect, UI_CNR_ALL, 0.25f * U.widget_unit); GPU_blend(false); } diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index c617c921d70..f39ca028e7a 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -595,8 +595,7 @@ static void draw_mask_layers(const bContext *C, const int height) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_program_point_size(true); MaskLayer *mask_layer; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index b02e48a652e..684350a15a6 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1129,8 +1129,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v float fcol[4]; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPUVertBuf *vert = GPU_vertbuf_create_with_format(format); GPU_vertbuf_data_alloc(vert, kcd->totlinehit); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 68d39246e5f..33632bbb0c3 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -94,8 +94,7 @@ static void region_draw_emboss(const ARegion *region, const rcti *scirct, int si /* set transp line */ GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); float color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; UI_GetThemeColor3fv(TH_EDITOR_OUTLINE, color); @@ -312,8 +311,7 @@ static void region_draw_azones(ScrArea *area, ARegion *region) GPU_line_width(1.0f); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_matrix_push(); GPU_matrix_translate_2f(-region->winrct.xmin, -region->winrct.ymin); @@ -377,8 +375,7 @@ static void region_draw_status_text(ScrArea *area, ARegion *region) const float y1 = pad; const float y2 = region->winy - pad; - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); float color[4] = {0.0f, 0.0f, 0.0f, 0.5f}; UI_GetThemeColor3fv(TH_BACK, color); @@ -3273,8 +3270,7 @@ void ED_region_info_draw_multiline(ARegion *region, GPU_scissor(rect.xmin, rect.ymin, BLI_rcti_size_x(&rect) + 1, BLI_rcti_size_y(&rect) + 1); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index b0e96c2dae1..129c8015c01 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -296,8 +296,7 @@ static GPUBatch *batch_screen_edges_get(int *corner_len) */ static void scrarea_draw_shape_dark(ScrArea *area, char dir, uint pos) { - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immUniformColor4ub(0, 0, 0, 50); draw_join_shape(area, dir, pos); @@ -308,8 +307,7 @@ static void scrarea_draw_shape_dark(ScrArea *area, char dir, uint pos) */ static void scrarea_draw_shape_light(ScrArea *area, char UNUSED(dir), uint pos) { - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immUniformColor4ub(255, 255, 255, 25); immRectf(pos, area->v1->vec.x, area->v1->vec.y, area->v3->vec.x, area->v3->vec.y); @@ -413,8 +411,7 @@ void ED_screen_draw_edges(wmWindow *win) edge_thickness = corner_scale * 0.21f; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPUBatch *batch = batch_screen_edges_get(&verts_per_corner); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_AREA_EDGES); @@ -487,8 +484,7 @@ void ED_screen_draw_split_preview(ScrArea *area, const int dir, const float fac) /* splitpoint */ GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); immUniformColor4ub(255, 255, 255, 100); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 07bdd337269..d17041737e4 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -154,8 +154,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *region, MovieClip *clip MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* cache background */ ED_region_cache_draw_background(region); @@ -331,8 +330,7 @@ static void draw_movieclip_buffer(const bContext *C, /* checkerboard for case alpha */ if (ibuf->planes == 32) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); imm_draw_box_checker_2d(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y); } @@ -1213,8 +1211,7 @@ static void draw_plane_marker_image(Scene *scene, if (plane_track->image_opacity != 1.0f || ibuf->planes == 32) { transparent = true; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } GPUTexture *texture = GPU_texture_create_nD(ibuf->x, diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 03f791ad70d..8e50c3f6774 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -415,8 +415,7 @@ void clip_draw_sfra_efra(View2D *v2d, Scene *scene) UI_view2d_view_ortho(v2d); /* currently clip editor supposes that editing clip length is equal to scene frame range */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 083d41747b3..88fd505d26d 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -290,8 +290,7 @@ static void file_draw_preview(uiBlock *block, if (!is_icon && typeflags & FILE_TYPE_BLENDERLIB) { /* Datablock preview images use premultiplied alpha. */ - GPU_blend_set_func_separate( - GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT); } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); @@ -309,8 +308,7 @@ static void file_draw_preview(uiBlock *block, 1.0f, col); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); if (icon && is_icon) { /* Small icon in the middle of large image, scaled to fit container and UI scale */ diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index f5861e792bc..677707602b2 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1262,8 +1262,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) float ymax = ACHANNEL_FIRST_TOP(ac); /* set blending again, as may not be set in previous step */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index f70589ac5f1..7e6f92f37f1 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -175,8 +175,7 @@ void ED_image_draw_info(Scene *scene, float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0; float col[4], finalcol[4]; - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); uint pos = GPU_vertformat_attr_add( @@ -540,8 +539,7 @@ static void draw_udim_label(ARegion *region, float fx, float fy, const char *lab int x, y; UI_view2d_view_to_region(®ion->v2d, fx, fy, &x, &y); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); int textwidth = BLF_width(blf_mono_font, label, strlen(label)) + 10; @@ -603,8 +601,7 @@ static void draw_image_buffer(const bContext *C, imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } /* If RGBA display with color management */ @@ -772,8 +769,7 @@ static void draw_image_paint_helpers( } GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex( @@ -1059,8 +1055,7 @@ void draw_image_cache(const bContext *C, ARegion *region) const int region_bottom = rect_visible->ymin; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* Draw cache background. */ ED_region_cache_draw_background(region); diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 93a79d9a2bc..b55c83fed9c 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -85,8 +85,7 @@ static void textview_draw_sel(const char *str, const int end = BLI_str_utf8_offset_to_column(str, min_ii(sel[1], str_len_draw)); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 97939a93d01..92f29023d73 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -434,8 +434,7 @@ static void nla_draw_strip(SpaceNla *snla, */ if ((strip->extendmode != NLASTRIP_EXTEND_NOTHING) && (non_solo == 0)) { /* enable transparency... */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); switch (strip->extendmode) { @@ -746,8 +745,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *region) /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, * and a second darker rect within which we draw keyframe indicator dots if there's data */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); /* get colors for drawing */ @@ -854,8 +852,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *region) float ymax = NLACHANNEL_FIRST_TOP(ac); /* set blending again, as may not be set in previous step */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); /* loop through channels, and set up drawing depending on their type */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 8f15cd82fe0..f41c482da76 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3689,8 +3689,7 @@ void draw_nodespace_back_pix(const bContext *C, } else if (snode->flag & SNODE_USE_ALPHA) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); ED_draw_imbuf_ctx(C, ibuf, x, y, false, snode->zoom, snode->zoom); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index fd18583195d..9a61d757ef5 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -911,8 +911,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) GPU_blend(true); /* premul graphics */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); immDrawPixelsTex(&state, @@ -1752,8 +1751,7 @@ void drawnodespace(const bContext *C, ARegion *region) ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW); /* only set once */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* nodes */ snode_set_context(C); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 6a91a8f7b49..ccbb191e411 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -3493,8 +3493,7 @@ static void outliner_draw_tree(bContext *C, const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; int starty, startx; - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* Only once. */ + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); /* Only once. */ if (space_outliner->outlinevis == SO_DATA_API) { /* struct marks */ diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 908ead31724..77bc8423365 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -383,8 +383,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, } GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); for (seq = seqbase->first; seq; seq = seq->next) { chan_min = min_ii(chan_min, seq->machine); @@ -492,8 +491,7 @@ static void draw_seq_handle(View2D *v2d, if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); if (seq->flag & whichsel) { if (seq_active) { @@ -755,8 +753,7 @@ static void draw_sequence_extensions(Scene *scene, Sequence *seq, uint pos, floa y2 = seq->machine + SEQ_STRIP_OFSTOP; GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); color3ubv_from_seq(scene, seq, col); if (seq->flag & SELECT) { @@ -845,8 +842,7 @@ static void draw_seq_background(Scene *scene, if (seq->flag & SEQ_MUTE) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); col[3] = MUTE_ALPHA; } @@ -1596,8 +1592,7 @@ static void sequencer_draw_display_buffer(const bContext *C, if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); } /* Format needs to be created prior to any immBindShader call. diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index e9ac6946032..c91595646ff 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1353,8 +1353,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *region) UI_GetThemeColor4fv(TH_TEXT, highlight_color); highlight_color[3] = 0.1f; immUniformColor4fv(highlight_color); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); immRecti(pos, 0, y1, region->winx, y2); GPU_blend(false); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 1ffa653372c..c102b4ff758 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -131,8 +131,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph, /* Just to create the data to pass to immediate mode, grr! */ const int *facemap_data = CustomData_get_layer(&me->pdata, CD_FACEMAP); if (facemap_data) { - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); const MVert *mvert = me->mvert; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index ac70547c293..6fecf80650d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -588,8 +588,7 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *region, float alpha = 1.0f; if (ca->passepartalpha != 1.0f) { - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); alpha = ca->passepartalpha; } @@ -1028,8 +1027,7 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) GPU_line_width(2.0f); GPU_line_smooth(true); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -1073,8 +1071,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) negate_v3_v3(o, rv3d->ofs); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_depth_mask(false); /* don't overwrite zbuf */ GPUVertFormat *format = immVertexFormat(); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 76cce5e725f..f760e90c68f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1544,8 +1544,7 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *region) #endif /* autokey recording icon... */ - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_blend(true); xco -= U.widget_unit; diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c index 1886f95beae..deed5c84d2b 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_slide.c @@ -1150,8 +1150,7 @@ void drawEdgeSlide(TransInfo *t) GPU_depth_test(false); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_matrix_push(); GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c index 38537194af3..9691da6a32f 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.c +++ b/source/blender/editors/transform/transform_mode_vert_slide.c @@ -393,8 +393,7 @@ void drawVertSlide(TransInfo *t) GPU_depth_test(false); GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); GPU_matrix_push(); GPU_matrix_mul(TRANS_DATA_CONTAINER_FIRST_OK(t)->obedit->obmat); diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index f26e95d8861..03ec8c81294 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -349,8 +349,7 @@ static void draw_uvs(SpaceImage *sima, interpedges = (ts->uv_selectmode == UV_SELECT_VERTEX); } - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); if (batch->faces) { GPU_batch_program_set_builtin(batch->faces, diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 19bb8001491..cb580adf23a 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -116,10 +116,7 @@ void GPU_state_init(void); void GPU_blend(bool enable); void GPU_blend_set_func(eGPUBlendFunction sfactor, eGPUBlendFunction dfactor); -void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb, - eGPUBlendFunction dst_rgb, - eGPUBlendFunction src_alpha, - eGPUBlendFunction dst_alpha); +void GPU_blend_set_func_separate(eGPUBlend blend); void GPU_face_culling(eGPUFaceCullTest culling); void GPU_front_facing(bool invert); void GPU_provoking_vertex(eGPUProvokingVertex vert); diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc index d2aa0816a3f..be4450193f5 100644 --- a/source/blender/gpu/intern/gpu_state.cc +++ b/source/blender/gpu/intern/gpu_state.cc @@ -46,25 +46,6 @@ using namespace blender::gpu; // GLStateStack::set_blend(blend); // } -static GLenum gpu_get_gl_blendfunction(eGPUBlendFunction blend) -{ - switch (blend) { - case GPU_ONE: - return GL_ONE; - case GPU_SRC_ALPHA: - return GL_SRC_ALPHA; - case GPU_ONE_MINUS_SRC_ALPHA: - return GL_ONE_MINUS_SRC_ALPHA; - case GPU_DST_COLOR: - return GL_DST_COLOR; - case GPU_ZERO: - return GL_ZERO; - default: - BLI_assert(!"Unhandled blend mode"); - return GL_ZERO; - } -} - void GPU_blend(bool enable) { if (enable) { @@ -94,15 +75,9 @@ void GPU_blend_set_func(eGPUBlendFunction sfactor, eGPUBlendFunction dfactor) } } -void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb, - eGPUBlendFunction dst_rgb, - eGPUBlendFunction src_alpha, - eGPUBlendFunction dst_alpha) +void GPU_blend_set_func_separate(eGPUBlend blend) { - glBlendFuncSeparate(gpu_get_gl_blendfunction(src_rgb), - gpu_get_gl_blendfunction(dst_rgb), - gpu_get_gl_blendfunction(src_alpha), - gpu_get_gl_blendfunction(dst_alpha)); + GLStateStack::set_blend(blend); } void GPU_face_culling(eGPUFaceCullTest culling) diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index a0a21fadbbb..b75d9db1c38 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -316,8 +316,7 @@ static void playanim_toscreen( /* checkerboard for case alpha */ if (ibuf->planes == 32) { GPU_blend(true); - GPU_blend_set_func_separate( - GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); + GPU_blend_set_func_separate(GPU_BLEND_ALPHA); imm_draw_box_checker_2d_ex(offs_x, offs_y, -- cgit v1.2.3