Extract Canvas draw_merge final plane composite helper
This commit is contained in:
@@ -301,6 +301,12 @@ agent or engineer to remove them without reconstructing context from chat.
|
|||||||
through `legacy_canvas_draw_merge_services.h`. The retained Canvas path still
|
through `legacy_canvas_draw_merge_services.h`. The retained Canvas path still
|
||||||
owns draw-merge layer iteration, blend-gate branching, framebuffer copies,
|
owns draw-merge layer iteration, blend-gate branching, framebuffer copies,
|
||||||
sampler/texture binding, and draw ordering.
|
sampler/texture binding, and draw ordering.
|
||||||
|
- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge` end-of-plane
|
||||||
|
merged-texture copy, optional checkerboard redraw, and final merged-texture
|
||||||
|
composite ordering now route through
|
||||||
|
`execute_legacy_canvas_draw_merge_final_plane_composite(...)`; the retained
|
||||||
|
Canvas path still owns per-plane iteration plus the concrete framebuffer,
|
||||||
|
sampler, texture, and draw callbacks.
|
||||||
- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::layer_merge` now reuses
|
- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::layer_merge` now reuses
|
||||||
`legacy_canvas_stroke_composite_services.h` for retained layer-merge
|
`legacy_canvas_stroke_composite_services.h` for retained layer-merge
|
||||||
`kShader::CompDraw` binding and source/destination blend uniform writes.
|
`kShader::CompDraw` binding and source/destination blend uniform writes.
|
||||||
|
|||||||
@@ -3150,6 +3150,11 @@ Results:
|
|||||||
ordering through `execute_legacy_canvas_draw_merge_layer_blend(...)`, while
|
ordering through `execute_legacy_canvas_draw_merge_layer_blend(...)`, while
|
||||||
temporary-stroke branch selection, framebuffer copies, and final merged-plane
|
temporary-stroke branch selection, framebuffer copies, and final merged-plane
|
||||||
ownership remain in the legacy Canvas path.
|
ownership remain in the legacy Canvas path.
|
||||||
|
- `Canvas::draw_merge()` end-of-plane merged-texture copy plus optional
|
||||||
|
checkerboard/final-texture redraw ordering now routes through
|
||||||
|
`execute_legacy_canvas_draw_merge_final_plane_composite(...)`, while
|
||||||
|
per-plane iteration and the concrete framebuffer, sampler, texture, and draw
|
||||||
|
callbacks remain in the legacy Canvas path.
|
||||||
- `NodeStrokePreview::draw_stroke_immediate()` now shares
|
- `NodeStrokePreview::draw_stroke_immediate()` now shares
|
||||||
`execute_legacy_node_stroke_preview_pass_sequence(...)` for
|
`execute_legacy_node_stroke_preview_pass_sequence(...)` for
|
||||||
dual-pass/background/main-pass/final-composite/copy-back ordering, while the
|
dual-pass/background/main-pass/final-composite/copy-back ordering, while the
|
||||||
|
|||||||
@@ -528,6 +528,13 @@ Progress Notes:
|
|||||||
merged-texture copy/grid/final-redraw seam or another similarly narrow final
|
merged-texture copy/grid/final-redraw seam or another similarly narrow final
|
||||||
composite boundary without reopening landed temporary-composite or
|
composite boundary without reopening landed temporary-composite or
|
||||||
per-layer blend helpers.
|
per-layer blend helpers.
|
||||||
|
- 2026-06-13: `Canvas::draw_merge()` end-of-plane merged-texture copy,
|
||||||
|
optional checkerboard redraw, and final merged-texture composite ordering now
|
||||||
|
route through `execute_legacy_canvas_draw_merge_final_plane_composite(...)`;
|
||||||
|
per-plane iteration and concrete framebuffer, sampler, texture, and draw
|
||||||
|
callbacks remain local to `Canvas`. Next slice should target another narrow
|
||||||
|
retained draw-merge boundary without reopening landed temporary-composite,
|
||||||
|
layer-blend, or final-plane helpers.
|
||||||
- 2026-06-13: `Canvas::draw_merge()` erase live temporary-stroke composite now
|
- 2026-06-13: `Canvas::draw_merge()` erase live temporary-stroke composite now
|
||||||
routes retained setup, sampler bind, texture bind, draw, and texture unbind
|
routes retained setup, sampler bind, texture bind, draw, and texture unbind
|
||||||
ordering through `execute_legacy_canvas_stroke_temporary_composite(...)`;
|
ordering through `execute_legacy_canvas_stroke_temporary_composite(...)`;
|
||||||
|
|||||||
@@ -1581,37 +1581,45 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array<bool, 6> faces /*= SI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_active_texture_unit(2);
|
|
||||||
m_merge_tex.bind();
|
|
||||||
copy_framebuffer_to_texture_2d(0, 0, 0, 0, m_width, m_height);
|
|
||||||
|
|
||||||
// draw the grid behind the layers using a temporary copy
|
|
||||||
if (use_blend)
|
if (use_blend)
|
||||||
{
|
{
|
||||||
apply_canvas_capability(blend_state(), true);
|
pp::panopainter::execute_legacy_canvas_draw_merge_final_plane_composite(
|
||||||
|
pp::panopainter::LegacyCanvasDrawMergeFinalPlaneCompositeUniforms {
|
||||||
//draw the grid
|
.checkerboard = {
|
||||||
if (draw_checkerboard)
|
|
||||||
{
|
|
||||||
pp::panopainter::setup_legacy_canvas_draw_merge_checkerboard_shader(
|
|
||||||
pp::panopainter::LegacyCanvasDrawMergeCheckerboardUniforms {
|
|
||||||
.mvp = ortho,
|
.mvp = ortho,
|
||||||
.colorize = false,
|
.colorize = false,
|
||||||
});
|
},
|
||||||
m_plane.draw_fill();
|
.texture = {
|
||||||
}
|
.mvp = ortho,
|
||||||
|
.texture_slot = 0,
|
||||||
// draw the layers
|
},
|
||||||
m_sampler.bind(0);
|
.draw_checkerboard = draw_checkerboard,
|
||||||
set_active_texture_unit(0);
|
},
|
||||||
m_merge_tex.bind();
|
pp::panopainter::LegacyCanvasDrawMergeFinalPlaneCompositeExecution {
|
||||||
pp::panopainter::setup_legacy_canvas_draw_merge_texture_shader(
|
.bind_merged_texture_copy_target = [&] {
|
||||||
pp::panopainter::LegacyCanvasDrawMergeTextureUniforms {
|
set_active_texture_unit(2);
|
||||||
.mvp = ortho,
|
m_merge_tex.bind();
|
||||||
.texture_slot = 0,
|
},
|
||||||
|
.copy_merged_framebuffer = [&] {
|
||||||
|
copy_framebuffer_to_texture_2d(0, 0, 0, 0, m_width, m_height);
|
||||||
|
},
|
||||||
|
.enable_blend = [&] {
|
||||||
|
apply_canvas_capability(blend_state(), true);
|
||||||
|
},
|
||||||
|
.draw = [&] {
|
||||||
|
m_plane.draw_fill();
|
||||||
|
},
|
||||||
|
.bind_sampler = [&] {
|
||||||
|
m_sampler.bind(0);
|
||||||
|
},
|
||||||
|
.bind_merged_texture = [&] {
|
||||||
|
set_active_texture_unit(0);
|
||||||
|
m_merge_tex.bind();
|
||||||
|
},
|
||||||
|
.unbind_merged_texture = [&] {
|
||||||
|
m_merge_tex.unbind();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
m_plane.draw_fill();
|
|
||||||
m_merge_tex.unbind();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_layers_merge.rtt(plane_index).unbindFramebuffer();
|
m_layers_merge.rtt(plane_index).unbindFramebuffer();
|
||||||
|
|||||||
@@ -80,6 +80,22 @@ struct LegacyCanvasDrawMergeLayerBlendExecution {
|
|||||||
std::function<void()> unbind_merge_texture;
|
std::function<void()> unbind_merge_texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LegacyCanvasDrawMergeFinalPlaneCompositeUniforms {
|
||||||
|
LegacyCanvasDrawMergeCheckerboardUniforms checkerboard;
|
||||||
|
LegacyCanvasDrawMergeTextureUniforms texture;
|
||||||
|
bool draw_checkerboard = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct LegacyCanvasDrawMergeFinalPlaneCompositeExecution {
|
||||||
|
std::function<void()> bind_merged_texture_copy_target;
|
||||||
|
std::function<void()> copy_merged_framebuffer;
|
||||||
|
std::function<void()> enable_blend;
|
||||||
|
std::function<void()> draw;
|
||||||
|
std::function<void()> bind_sampler;
|
||||||
|
std::function<void()> bind_merged_texture;
|
||||||
|
std::function<void()> unbind_merged_texture;
|
||||||
|
};
|
||||||
|
|
||||||
[[nodiscard]] inline LegacyCanvasDrawMergeShaderExecution legacy_shader_manager_draw_merge_execution() noexcept
|
[[nodiscard]] inline LegacyCanvasDrawMergeShaderExecution legacy_shader_manager_draw_merge_execution() noexcept
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@@ -257,4 +273,25 @@ inline void execute_legacy_canvas_draw_merge_layer_blend(
|
|||||||
execution.unbind_merge_texture();
|
execution.unbind_merge_texture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void execute_legacy_canvas_draw_merge_final_plane_composite(
|
||||||
|
const LegacyCanvasDrawMergeFinalPlaneCompositeUniforms& uniforms,
|
||||||
|
const LegacyCanvasDrawMergeFinalPlaneCompositeExecution& execution)
|
||||||
|
{
|
||||||
|
execution.bind_merged_texture_copy_target();
|
||||||
|
execution.copy_merged_framebuffer();
|
||||||
|
|
||||||
|
execution.enable_blend();
|
||||||
|
|
||||||
|
if (uniforms.draw_checkerboard) {
|
||||||
|
setup_legacy_canvas_draw_merge_checkerboard_shader(uniforms.checkerboard);
|
||||||
|
execution.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
execution.bind_sampler();
|
||||||
|
execution.bind_merged_texture();
|
||||||
|
setup_legacy_canvas_draw_merge_texture_shader(uniforms.texture);
|
||||||
|
execution.draw();
|
||||||
|
execution.unbind_merged_texture();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace pp::panopainter
|
} // namespace pp::panopainter
|
||||||
|
|||||||
Reference in New Issue
Block a user