Cleanup: GPUState: Replace blend func separate by enum

This commit is contained in:
Clément Foucault 2020-08-16 15:16:21 +02:00
parent a1459b2f7a
commit 969bcf0793
39 changed files with 80 additions and 183 deletions

View File

@ -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. */

View File

@ -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);
}

View File

@ -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 ........................................... */

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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). */

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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];

View File

@ -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) {

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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 */

View File

@ -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++) {

View File

@ -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(&region->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);

View File

@ -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);

View File

@ -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 */

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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.

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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)

View File

@ -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,