Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager.c
| Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | return (v3d && ((v3d->flag2 & V3D_SHOW_ANNOTATION) != 0) && | ||||
| ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0)); | ((v3d->flag2 & V3D_HIDE_OVERLAYS) == 0)); | ||||
| } | } | ||||
| switch (DST.draw_ctx.space_data->spacetype) { | switch (DST.draw_ctx.space_data->spacetype) { | ||||
| case SPACE_IMAGE: { | case SPACE_IMAGE: { | ||||
| SpaceImage *sima = (SpaceImage *)DST.draw_ctx.space_data; | SpaceImage *sima = (SpaceImage *)DST.draw_ctx.space_data; | ||||
| return (sima->flag & SI_SHOW_GPENCIL) != 0; | return (sima->flag & SI_SHOW_GPENCIL) != 0; | ||||
| } | } | ||||
| case SPACE_NODE: | |||||
| /* Don't draw the annotation for the node editor. Annotations are handled by space_image as | |||||
| * the draw manager is only used to draw the background. */ | |||||
| return false; | |||||
| default: | default: | ||||
| BLI_assert(""); | BLI_assert(""); | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Threading | /** \name Threading | ||||
| ▲ Show 20 Lines • Show All 194 Lines • ▼ Show 20 Lines | else if (DST.draw_ctx.space_data && DST.draw_ctx.space_data->spacetype == SPACE_IMAGE) { | ||||
| const eSpaceImage_Flag display_channels_mode = sima->flag; | const eSpaceImage_Flag display_channels_mode = sima->flag; | ||||
| const bool display_color_channel = (display_channels_mode & (SI_SHOW_ALPHA | SI_SHOW_ZBUF)) == | const bool display_color_channel = (display_channels_mode & (SI_SHOW_ALPHA | SI_SHOW_ZBUF)) == | ||||
| 0; | 0; | ||||
| if (display_color_channel && image && (image->source != IMA_SRC_GENERATED) && | if (display_color_channel && image && (image->source != IMA_SRC_GENERATED) && | ||||
| ((image->flag & IMA_VIEW_AS_RENDER) != 0)) { | ((image->flag & IMA_VIEW_AS_RENDER) != 0)) { | ||||
| use_render_settings = true; | use_render_settings = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (DST.draw_ctx.space_data && DST.draw_ctx.space_data->spacetype == SPACE_NODE) { | |||||
| SpaceNode *snode = (SpaceNode *)DST.draw_ctx.space_data; | |||||
| const eSpaceImage_Flag display_channels_mode = snode->flag; | |||||
| const bool display_color_channel = (display_channels_mode & (SI_SHOW_ALPHA)) == 0; | |||||
| if (display_color_channel) { | |||||
| use_render_settings = true; | |||||
| } | |||||
| } | |||||
| else { | else { | ||||
| use_render_settings = true; | use_render_settings = true; | ||||
| use_view_transform = false; | use_view_transform = false; | ||||
| } | } | ||||
| if (use_render_settings) { | if (use_render_settings) { | ||||
| /* Use full render settings, for renders with scene lighting. */ | /* Use full render settings, for renders with scene lighting. */ | ||||
| view_settings = scene->view_settings; | view_settings = scene->view_settings; | ||||
| ▲ Show 20 Lines • Show All 876 Lines • ▼ Show 20 Lines | static void drw_engines_enable_editors(void) | ||||
| if (!space_data) { | if (!space_data) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (space_data->spacetype == SPACE_IMAGE) { | if (space_data->spacetype == SPACE_IMAGE) { | ||||
| use_drw_engine(&draw_engine_image_type); | use_drw_engine(&draw_engine_image_type); | ||||
| use_drw_engine(&draw_engine_overlay_type); | use_drw_engine(&draw_engine_overlay_type); | ||||
| } | } | ||||
| else if (space_data->spacetype == SPACE_NODE) { | |||||
| /* Only enable when drawing the space image backdrop. */ | |||||
| SpaceNode *snode = (SpaceNode *)space_data; | |||||
| if ((snode->flag & SNODE_BACKDRAW) != 0) { | |||||
| use_drw_engine(&draw_engine_image_type); | |||||
| use_drw_engine(&draw_engine_overlay_type); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| static void drw_engines_enable(ViewLayer *UNUSED(view_layer), | static void drw_engines_enable(ViewLayer *UNUSED(view_layer), | ||||
| RenderEngineType *engine_type, | RenderEngineType *engine_type, | ||||
| bool gpencil_engine_needed) | bool gpencil_engine_needed) | ||||
| { | { | ||||
| View3D *v3d = DST.draw_ctx.v3d; | View3D *v3d = DST.draw_ctx.v3d; | ||||
| const eDrawType drawtype = v3d->shading.type; | const eDrawType drawtype = v3d->shading.type; | ||||
| ▲ Show 20 Lines • Show All 739 Lines • ▼ Show 20 Lines | void DRW_custom_pipeline(DrawEngineType *draw_engine_type, | ||||
| GPU_finish(); | GPU_finish(); | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| /* Avoid accidental reuse. */ | /* Avoid accidental reuse. */ | ||||
| drw_state_ensure_not_reused(&DST); | drw_state_ensure_not_reused(&DST); | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* Used when the render engine want to redo another cache populate inside the same render frame. */ | /* Used when the render engine want to redo another cache populate inside the same render frame. | ||||
| */ | |||||
| void DRW_cache_restart(void) | void DRW_cache_restart(void) | ||||
| { | { | ||||
| /* Save viewport size. */ | /* Save viewport size. */ | ||||
| float size[2], inv_size[2]; | float size[2], inv_size[2]; | ||||
| copy_v2_v2(size, DST.size); | copy_v2_v2(size, DST.size); | ||||
| copy_v2_v2(inv_size, DST.inv_size); | copy_v2_v2(inv_size, DST.inv_size); | ||||
| /* Force cache to reset. */ | /* Force cache to reset. */ | ||||
| Show All 35 Lines | void DRW_draw_render_loop_2d_ex(struct Depsgraph *depsgraph, | ||||
| }; | }; | ||||
| drw_context_state_init(); | drw_context_state_init(); | ||||
| drw_viewport_var_init(); | drw_viewport_var_init(); | ||||
| drw_viewport_colormanagement_set(); | drw_viewport_colormanagement_set(); | ||||
| /* TODO(jbakker): Only populate when editor needs to draw object. | /* TODO(jbakker): Only populate when editor needs to draw object. | ||||
| * for the image editor this is when showing UV's.*/ | * for the image editor this is when showing UV's.*/ | ||||
| const bool do_populate_loop = true; | const bool do_populate_loop = (DST.draw_ctx.space_data->spacetype == SPACE_IMAGE); | ||||
| const bool do_annotations = drw_draw_show_annotation(); | const bool do_annotations = drw_draw_show_annotation(); | ||||
| const bool do_region_callbacks = (DST.draw_ctx.space_data->spacetype != SPACE_IMAGE); | |||||
| const bool do_draw_gizmos = (DST.draw_ctx.space_data->spacetype != SPACE_IMAGE); | |||||
| /* Get list of enabled engines */ | /* Get list of enabled engines */ | ||||
| drw_engines_enable_editors(); | drw_engines_enable_editors(); | ||||
| drw_engines_data_validate(); | drw_engines_data_validate(); | ||||
| /* Update ubos */ | /* Update ubos */ | ||||
| DRW_globals_update(); | DRW_globals_update(); | ||||
| Show All 34 Lines | #endif | ||||
| DRW_stats_begin(); | DRW_stats_begin(); | ||||
| GPU_framebuffer_bind(DST.default_framebuffer); | GPU_framebuffer_bind(DST.default_framebuffer); | ||||
| /* Start Drawing */ | /* Start Drawing */ | ||||
| DRW_state_reset(); | DRW_state_reset(); | ||||
| if (DST.draw_ctx.evil_C) { | if (do_region_callbacks && DST.draw_ctx.evil_C) { | ||||
| ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_PRE_VIEW); | ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_PRE_VIEW); | ||||
| } | } | ||||
| drw_engines_draw_scene(); | drw_engines_draw_scene(); | ||||
| /* Fix 3D view being "laggy" on macos and win+nvidia. (See T56996, T61474) */ | /* Fix 3D view being "laggy" on macos and win+nvidia. (See T56996, T61474) */ | ||||
| GPU_flush(); | GPU_flush(); | ||||
| if (DST.draw_ctx.evil_C) { | if (DST.draw_ctx.evil_C) { | ||||
| DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); | ||||
| DRW_state_reset(); | DRW_state_reset(); | ||||
| GPU_framebuffer_bind(dfbl->overlay_fb); | GPU_framebuffer_bind(dfbl->overlay_fb); | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| GPU_matrix_push_projection(); | GPU_matrix_push_projection(); | ||||
| wmOrtho2( | wmOrtho2( | ||||
| region->v2d.cur.xmin, region->v2d.cur.xmax, region->v2d.cur.ymin, region->v2d.cur.ymax); | region->v2d.cur.xmin, region->v2d.cur.xmax, region->v2d.cur.ymin, region->v2d.cur.ymax); | ||||
| if (do_annotations) { | if (do_annotations) { | ||||
| ED_annotation_draw_view2d(DST.draw_ctx.evil_C, true); | ED_annotation_draw_view2d(DST.draw_ctx.evil_C, true); | ||||
| } | } | ||||
| if (do_region_callbacks) { | |||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_POST_VIEW); | ED_region_draw_cb_draw(DST.draw_ctx.evil_C, DST.draw_ctx.region, REGION_DRAW_POST_VIEW); | ||||
| } | |||||
| GPU_matrix_pop_projection(); | GPU_matrix_pop_projection(); | ||||
| /* Callback can be nasty and do whatever they want with the state. | /* Callback can be nasty and do whatever they want with the state. | ||||
| * Don't trust them! */ | * Don't trust them! */ | ||||
| DRW_state_reset(); | DRW_state_reset(); | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| drw_engines_draw_text(); | drw_engines_draw_text(); | ||||
| if (do_annotations) { | if (do_annotations) { | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| ED_annotation_draw_view2d(DST.draw_ctx.evil_C, false); | ED_annotation_draw_view2d(DST.draw_ctx.evil_C, false); | ||||
| } | } | ||||
| } | } | ||||
| DRW_draw_cursor_2d(); | DRW_draw_cursor_2d(); | ||||
| ED_region_pixelspace(DST.draw_ctx.region); | ED_region_pixelspace(DST.draw_ctx.region); | ||||
| { | if (do_draw_gizmos) { | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| DRW_draw_gizmo_2d(); | DRW_draw_gizmo_2d(); | ||||
| } | } | ||||
| DRW_stats_reset(); | DRW_stats_reset(); | ||||
| if (G.debug_value > 20 && G.debug_value < 30) { | if (G.debug_value > 20 && G.debug_value < 30) { | ||||
| GPU_depth_test(GPU_DEPTH_NONE); | GPU_depth_test(GPU_DEPTH_NONE); | ||||
| ▲ Show 20 Lines • Show All 1,039 Lines • Show Last 20 Lines | |||||