Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_background.c
| Show All 26 Lines | |||||
| #include "draw_manager_text.h" | #include "draw_manager_text.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.h" | ||||
| #define BG_SOLID 0 | #define BG_SOLID 0 | ||||
| #define BG_GRADIENT 1 | #define BG_GRADIENT 1 | ||||
| #define BG_CHECKER 2 | #define BG_CHECKER 2 | ||||
| #define BG_RADIAL 3 | #define BG_RADIAL 3 | ||||
| #define BG_SOLID_CHECKER 4 | #define BG_SOLID_CHECKER 4 | ||||
| #define BG_MASK 5 | |||||
| void OVERLAY_background_cache_init(OVERLAY_Data *vedata) | void OVERLAY_background_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const Scene *scene = draw_ctx->scene; | const Scene *scene = draw_ctx->scene; | ||||
| const RegionView3D *rv3d = draw_ctx->rv3d; | const RegionView3D *rv3d = draw_ctx->rv3d; | ||||
| const BoundBox *bb = rv3d ? rv3d->clipbb : NULL; | const BoundBox *bb = rv3d ? rv3d->clipbb : NULL; | ||||
| const View3D *v3d = draw_ctx->v3d; | const View3D *v3d = draw_ctx->v3d; | ||||
| bool draw_clipping_bounds = (pd->clipping_state != 0); | bool draw_clipping_bounds = (pd->clipping_state != 0); | ||||
| { | { | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_BACKGROUND; | |||||
| float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | ||||
| int background_type; | int background_type; | ||||
| if (DRW_state_is_opengl_render() && !DRW_state_draw_background()) { | if (DRW_state_is_opengl_render() && !DRW_state_draw_background()) { | ||||
| background_type = BG_SOLID; | background_type = BG_SOLID; | ||||
| color_override[3] = 1.0f; | color_override[3] = 1.0f; | ||||
| } | } | ||||
| else if (pd->is_image_editor) { | else if (pd->space_type == SPACE_IMAGE) { | ||||
| background_type = BG_SOLID_CHECKER; | background_type = BG_SOLID_CHECKER; | ||||
| } | } | ||||
| else if (pd->space_type == SPACE_NODE) { | |||||
| background_type = BG_MASK; | |||||
| state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_MUL; | |||||
| } | |||||
| else if (!DRW_state_draw_background()) { | else if (!DRW_state_draw_background()) { | ||||
| background_type = BG_CHECKER; | background_type = BG_CHECKER; | ||||
| } | } | ||||
| else if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD && scene->world) { | else if (v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD && scene->world) { | ||||
| background_type = BG_SOLID; | background_type = BG_SOLID; | ||||
| /* TODO(fclem): this is a scene referred linear color. we should convert | /* TODO(fclem): this is a scene referred linear color. we should convert | ||||
| * it to display linear here. */ | * it to display linear here. */ | ||||
| copy_v3_v3(color_override, &scene->world->horr); | copy_v3_v3(color_override, &scene->world->horr); | ||||
| Show All 15 Lines | else { | ||||
| break; | break; | ||||
| default: | default: | ||||
| case TH_BACKGROUND_SINGLE_COLOR: | case TH_BACKGROUND_SINGLE_COLOR: | ||||
| background_type = BG_SOLID; | background_type = BG_SOLID; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_BACKGROUND; | |||||
| DRW_PASS_CREATE(psl->background_ps, state); | DRW_PASS_CREATE(psl->background_ps, state); | ||||
| GPUShader *sh = OVERLAY_shader_background(); | GPUShader *sh = OVERLAY_shader_background(); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->background_ps); | DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->background_ps); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &dtxl->color); | DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &dtxl->color); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override); | DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override); | ||||
| Show All 33 Lines | |||||