From 384db00015793fca4f284794ea16c87b637488ad Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 16:59:26 +0200 Subject: [PATCH] Add live pass sampler dispatch helper coverage --- docs/modernization/tasks.md | 4 +++ src/canvas.cpp | 2 +- src/legacy_canvas_stroke_execution_services.h | 22 +++++++++++++ .../paint_renderer/stroke_execution_tests.cpp | 31 +++++++++++++++++++ 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index c932b89..f7a57d4 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -509,6 +509,10 @@ Done Checks: Progress Notes: +- 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` + should now focus only on the last tiny binding leftovers or be marked done + once the debt note is updated. - 2026-06-13: `STR-004` is now the next ready slice for the last inline stroke dispatch glue; `LATER-003` is effectively at the binding-only tail. Keep this task focused on removing or consolidating helper-builder wiring rather diff --git a/src/canvas.cpp b/src/canvas.cpp index 070a57c..91f7b50 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -732,7 +732,7 @@ void Canvas::stroke_draw() }, }; const pp::panopainter::LegacyCanvasStrokeSamplerDispatch live_pass_sampler_dispatch = - pp::panopainter::make_legacy_canvas_stroke_sampler_dispatch( + pp::panopainter::make_legacy_canvas_stroke_live_pass_sampler_dispatch( [&](int slot) { m_sampler_brush.bind(slot); }, diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index 94fc4a0..3ce6218 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -127,6 +127,28 @@ struct LegacyCanvasStrokeSamplerDispatch { std::function unbind_mixer_sampler; }; +[[nodiscard]] inline LegacyCanvasStrokeSamplerDispatch make_legacy_canvas_stroke_live_pass_sampler_dispatch( + std::function bind_brush_tip_sampler, + std::function unbind_brush_tip_sampler, + std::function bind_stroke_destination_sampler, + std::function unbind_stroke_destination_sampler, + std::function bind_pattern_sampler, + std::function unbind_pattern_sampler, + std::function bind_mixer_sampler, + std::function unbind_mixer_sampler) +{ + return LegacyCanvasStrokeSamplerDispatch { + .bind_brush_tip_sampler = std::move(bind_brush_tip_sampler), + .unbind_brush_tip_sampler = std::move(unbind_brush_tip_sampler), + .bind_stroke_destination_sampler = std::move(bind_stroke_destination_sampler), + .unbind_stroke_destination_sampler = std::move(unbind_stroke_destination_sampler), + .bind_pattern_sampler = std::move(bind_pattern_sampler), + .unbind_pattern_sampler = std::move(unbind_pattern_sampler), + .bind_mixer_sampler = std::move(bind_mixer_sampler), + .unbind_mixer_sampler = std::move(unbind_mixer_sampler), + }; +} + [[nodiscard]] inline LegacyCanvasStrokeSamplerDispatch make_legacy_canvas_stroke_sampler_dispatch( std::function bind_brush_tip_sampler, std::function unbind_brush_tip_sampler, diff --git a/tests/paint_renderer/stroke_execution_tests.cpp b/tests/paint_renderer/stroke_execution_tests.cpp index 4627d36..dcc7b01 100644 --- a/tests/paint_renderer/stroke_execution_tests.cpp +++ b/tests/paint_renderer/stroke_execution_tests.cpp @@ -287,6 +287,34 @@ void retained_stroke_main_pass_texture_dispatch_helper_builds_expected_callback_ PP_EXPECT(h, events == expected_events); } +void retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring(pp::tests::Harness& h) +{ + std::vector events; + const auto dispatch = pp::panopainter::make_legacy_canvas_stroke_live_pass_sampler_dispatch( + [&](int slot) { events.emplace_back("bind:brush_tip:" + std::to_string(slot)); }, + [&] { events.emplace_back("unbind:brush_tip"); }, + [&](int slot) { events.emplace_back("bind:destination:" + std::to_string(slot)); }, + [&] { events.emplace_back("unbind:destination"); }, + [&](int slot) { events.emplace_back("bind:pattern:" + std::to_string(slot)); }, + [&] { events.emplace_back("unbind:pattern"); }, + [&](int slot) { events.emplace_back("bind:mixer:" + std::to_string(slot)); }, + [&] { events.emplace_back("unbind:mixer"); }); + + pp::panopainter::bind_legacy_canvas_stroke_sampler_input( + LegacyCanvasStrokeTextureInput::brush_tip, + 4, + dispatch); + pp::panopainter::unbind_legacy_canvas_stroke_sampler_input( + LegacyCanvasStrokeTextureInput::brush_tip, + dispatch); + + const std::vector expected_events { + "bind:brush_tip:4", + "unbind:brush_tip", + }; + PP_EXPECT(h, events == expected_events); +} + void retained_stroke_sample_executor_copies_destination_and_expands_quads(pp::tests::Harness& h) { const auto vertices = make_quad_vertices(); @@ -1370,6 +1398,9 @@ int main() harness.run( "retained_stroke_main_pass_texture_dispatch_helper_builds_expected_callback_wiring", retained_stroke_main_pass_texture_dispatch_helper_builds_expected_callback_wiring); + harness.run( + "retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring", + retained_stroke_live_pass_sampler_dispatch_helper_builds_expected_callback_wiring); harness.run( "retained_stroke_sample_executor_unbinds_and_skips_draw_when_bounds_are_empty", retained_stroke_sample_executor_unbinds_and_skips_draw_when_bounds_are_empty);