Extract Canvas draw_merge plane setup helper

This commit is contained in:
2026-06-13 11:53:42 +02:00
parent 3f8c25d78b
commit bec8d4623d
5 changed files with 72 additions and 20 deletions

View File

@@ -18,6 +18,11 @@ agent or engineer to remove them without reconstructing context from chat.
## Recent Reductions
- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge()` now routes
per-plane merge-target clear, blend-state gating, and optional checkerboard
prepass through `execute_legacy_canvas_draw_merge_plane_setup(...)`;
per-plane iteration, per-layer branch selection, and concrete framebuffer
ownership remain in the legacy Canvas path.
- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge()` now routes
the standard per-layer texture-alpha pass through
`execute_legacy_canvas_draw_merge_layer_texture(...)`; per-plane iteration,

View File

@@ -67,6 +67,10 @@ Recent 2026-06-13 retained preview reductions continue to narrow DEBT-0036:
feedback/material/composite planning and stroke-shader uniform assembly through
`plan_legacy_node_stroke_preview_pass_orchestration(...)`, leaving the preview
node with a smaller live-GL callback surface around pass execution.
`Canvas::draw_merge()` now also routes its per-plane merge-target clear,
blend-state gating, and optional checkerboard prepass through
`execute_legacy_canvas_draw_merge_plane_setup(...)`, reducing another retained
plane-setup branch.
`Canvas::draw_merge()` also now routes its standard per-layer texture-alpha pass
through `execute_legacy_canvas_draw_merge_layer_texture(...)`, reducing another
piece of retained layer-composite sequencing.

View File

@@ -509,6 +509,13 @@ Done Checks:
Progress Notes:
- 2026-06-13: `Canvas::draw_merge()` now routes per-plane merge-target clear,
blend-state gating, and optional checkerboard prepass through
`execute_legacy_canvas_draw_merge_plane_setup(...)`; per-layer iteration,
temporary-stroke branches, and concrete framebuffer ownership remain local to
`Canvas`. Next slice should target another narrow draw-merge execution seam
without reopening landed plane-setup, temporary-composite, layer-blend,
final-plane, or texture-alpha helpers.
- 2026-06-13: `Canvas::draw_merge()` now routes the standard per-layer
texture-alpha pass through
`execute_legacy_canvas_draw_merge_layer_texture(...)`; temporary-stroke

View File

@@ -1371,26 +1371,29 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
continue;
m_layers_merge.rtt(plane_index).bindFramebuffer();
m_layers_merge.rtt(plane_index).clear({ 1, 1, 1, 0 });
if (use_blend)
{
apply_canvas_capability(blend_state(), false);
m_layers_merge.rtt(plane_index).clear();
}
else
{
if (draw_checkerboard)
{
pp::panopainter::setup_legacy_canvas_draw_merge_checkerboard_shader(
pp::panopainter::LegacyCanvasDrawMergeCheckerboardUniforms {
.mvp = ortho,
.colorize = false,
});
m_plane.draw_fill();
}
apply_canvas_capability(blend_state(), true);
}
pp::panopainter::execute_legacy_canvas_draw_merge_plane_setup(
pp::panopainter::LegacyCanvasDrawMergePlaneSetupUniforms {
.checkerboard = {
.mvp = ortho,
.colorize = false,
},
.use_blend = use_blend,
.draw_checkerboard = draw_checkerboard,
},
pp::panopainter::LegacyCanvasDrawMergePlaneSetupExecution {
.clear_plane = [&] {
m_layers_merge.rtt(plane_index).clear({ 1, 1, 1, 0 });
},
.disable_blend = [&] {
apply_canvas_capability(blend_state(), false);
},
.enable_blend = [&] {
apply_canvas_capability(blend_state(), true);
},
.draw = [&] {
m_plane.draw_fill();
},
});
for (int layer_index = 0; layer_index < m_layers.size(); layer_index++)
{

View File

@@ -87,6 +87,19 @@ struct LegacyCanvasDrawMergeLayerTextureExecution {
std::function<void()> unbind_layer_texture;
};
struct LegacyCanvasDrawMergePlaneSetupUniforms {
LegacyCanvasDrawMergeCheckerboardUniforms checkerboard;
bool use_blend = false;
bool draw_checkerboard = false;
};
struct LegacyCanvasDrawMergePlaneSetupExecution {
std::function<void()> clear_plane;
std::function<void()> disable_blend;
std::function<void()> enable_blend;
std::function<void()> draw;
};
struct LegacyCanvasDrawMergeFinalPlaneCompositeUniforms {
LegacyCanvasDrawMergeCheckerboardUniforms checkerboard;
LegacyCanvasDrawMergeTextureUniforms texture;
@@ -291,6 +304,26 @@ inline void execute_legacy_canvas_draw_merge_layer_texture(
execution.unbind_layer_texture();
}
inline void execute_legacy_canvas_draw_merge_plane_setup(
const LegacyCanvasDrawMergePlaneSetupUniforms& uniforms,
const LegacyCanvasDrawMergePlaneSetupExecution& execution)
{
execution.clear_plane();
if (uniforms.use_blend) {
execution.disable_blend();
execution.clear_plane();
return;
}
if (uniforms.draw_checkerboard) {
setup_legacy_canvas_draw_merge_checkerboard_shader(uniforms.checkerboard);
execution.draw();
}
execution.enable_blend();
}
inline void execute_legacy_canvas_draw_merge_final_plane_composite(
const LegacyCanvasDrawMergeFinalPlaneCompositeUniforms& uniforms,
const LegacyCanvasDrawMergeFinalPlaneCompositeExecution& execution)