From 55fb02e472d394e4962272c1a4ab3a3b235fe712 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 19:17:36 +0200 Subject: [PATCH] Extract stroke mix setup shell --- docs/modernization/debt.md | 4 ++++ docs/modernization/tasks.md | 3 +++ src/canvas.cpp | 13 +++++++----- src/legacy_canvas_stroke_execution_services.h | 15 +++++++++++++ .../paint_renderer/stroke_execution_tests.cpp | 21 +++++++++++++++++++ 5 files changed, 51 insertions(+), 5 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 3a05d70..2719539 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,10 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-13: `LATER-003` was narrowed again. `Canvas::stroke_draw_mix()` now + routes the setup/end shell through + `make_legacy_canvas_stroke_mix_pass_setup(...)`; the live path still owns + the concrete framebuffer bind and GL capability toggles. - 2026-06-13: `LATER-003` was narrowed again. `Canvas::stroke_draw_mix()` now routes its retained mix-pass execution shell through `execute_legacy_canvas_stroke_mix_pass_with_setup(...)` with a concrete diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 8fa3d87..40d0a79 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -595,6 +595,9 @@ Progress Notes: execution shell through `execute_legacy_canvas_stroke_mix_pass_with_setup(...)` with a concrete request builder; the live path still owns the OpenGL setup and per-plane texture wiring. +- 2026-06-13: `Canvas::stroke_draw_mix()` now routes the setup/end shell through + `make_legacy_canvas_stroke_mix_pass_setup(...)`; the live path still owns the + concrete framebuffer bind and GL capability toggles. - 2026-06-13: `Canvas::stroke_draw()` live-pass sampler wiring now reuses a retained helper builder, and the stroke execution tests cover it. `STR-004` is now done after the final pad-destination helper extraction and tracker diff --git a/src/canvas.cpp b/src/canvas.cpp index d3e51e0..72ac9ad 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -403,9 +403,8 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz) return current_layer.face(plane_index); }); const auto& b = m_current_stroke->m_brush; - [[maybe_unused]] const auto mix_result = - pp::panopainter::execute_legacy_canvas_stroke_mix_pass_with_setup( - [&] { + const auto mix_setup = pp::panopainter::make_legacy_canvas_stroke_mix_pass_setup( + [&] { m_mixer.bindFramebuffer(); apply_canvas_viewport(0, 0, m_mixer.getWidth(), m_mixer.getHeight()); apply_canvas_capability(depth_test_state(), false); @@ -417,9 +416,13 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz) static_cast(bb_sz.x), static_cast(bb_sz.y)); }, - [&] { + [&] { m_mixer.unbindFramebuffer(); - }, + }); + [[maybe_unused]] const auto mix_result = + pp::panopainter::execute_legacy_canvas_stroke_mix_pass_with_setup( + mix_setup.begin, + mix_setup.end, pp::panopainter::make_legacy_canvas_stroke_mix_pass_request( "Canvas::stroke_draw_mix", m_size, diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index 0e4600a..4fdc2e4 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -340,6 +340,21 @@ struct LegacyCanvasStrokeMixPassResult { std::size_t composed_planes = 0; }; +struct LegacyCanvasStrokeMixPassSetup { + std::function begin; + std::function end; +}; + +[[nodiscard]] inline LegacyCanvasStrokeMixPassSetup make_legacy_canvas_stroke_mix_pass_setup( + std::function begin, + std::function end) +{ + return LegacyCanvasStrokeMixPassSetup { + .begin = std::move(begin), + .end = std::move(end), + }; +} + [[nodiscard]] inline LegacyCanvasStrokeMixPassRequest make_legacy_canvas_stroke_mix_pass_request( std::string_view context, glm::vec2 resolution, diff --git a/tests/paint_renderer/stroke_execution_tests.cpp b/tests/paint_renderer/stroke_execution_tests.cpp index 74cc3da..d0644ec 100644 --- a/tests/paint_renderer/stroke_execution_tests.cpp +++ b/tests/paint_renderer/stroke_execution_tests.cpp @@ -1885,6 +1885,24 @@ void retained_stroke_mix_pass_request_builder_preserves_callback_wiring(pp::test PP_EXPECT(h, events == expected_events); } +void retained_stroke_mix_pass_setup_builder_preserves_boundaries(pp::tests::Harness& h) +{ + std::vector events; + const auto setup = pp::panopainter::make_legacy_canvas_stroke_mix_pass_setup( + [&] { events.emplace_back("begin"); }, + [&] { events.emplace_back("end"); }); + + PP_EXPECT(h, setup.begin); + PP_EXPECT(h, setup.end); + + setup.begin(); + setup.end(); + + PP_EXPECT(h, events.size() == 2U); + PP_EXPECT(h, events[0] == "begin"); + PP_EXPECT(h, events[1] == "end"); +} + } // namespace int main() @@ -1992,5 +2010,8 @@ int main() harness.run( "retained_stroke_mix_pass_request_builder_preserves_callback_wiring", retained_stroke_mix_pass_request_builder_preserves_callback_wiring); + harness.run( + "retained_stroke_mix_pass_setup_builder_preserves_boundaries", + retained_stroke_mix_pass_setup_builder_preserves_boundaries); return harness.finish(); }