From 6b12c520f0583004e4bcb318907abcc9b868d9eb Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 18:48:25 +0200 Subject: [PATCH] Extract dual stroke tip dispatch overload --- docs/modernization/debt.md | 4 ++++ docs/modernization/tasks.md | 3 +++ src/canvas.cpp | 14 ++++++----- src/legacy_canvas_stroke_execution_services.h | 16 +++++++++++++ .../paint_renderer/stroke_execution_tests.cpp | 24 +++++++++++++++++++ 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 3568d10..76627d5 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()` now + routes dual-brush tip dispatch through retained helper overloads, so the + face-index callback wiring is no longer built inline in the dual-pass + branch. - 2026-06-13: `LATER-003` was narrowed again. `Canvas::stroke_draw()` now routes pad destination texture dispatch through retained helper overloads, so the face-index callback wiring is no longer built inline in the pad diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index b30bcca..2179c4f 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -575,6 +575,9 @@ Done Checks: Progress Notes: +- 2026-06-13: `Canvas::stroke_draw()` now routes dual-brush tip dispatch + through retained helper overloads, so the face-index callback wiring is no + longer built inline in the dual-pass branch. - 2026-06-13: `Canvas::stroke_draw()` now routes pad destination texture dispatch through retained helper overloads, so the face-index callback wiring is no longer built inline in the pad branch. diff --git a/src/canvas.cpp b/src/canvas.cpp index 1e9d05e..b68b675 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -946,16 +946,17 @@ void Canvas::stroke_draw() [&](int texture_slot) { set_active_texture_unit(texture_slot); }, - [&] { + [&](int) { dual_brush->m_tip_texture ? dual_brush->m_tip_texture->bind() : unbind_texture_2d(); }, - [&] { + [&](int) { dual_brush->m_tip_texture ? dual_brush->m_tip_texture->unbind() : unbind_texture_2d(); - })); + }, + 0)); }, .unbind_brush_tip = [&] { pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs( @@ -964,16 +965,17 @@ void Canvas::stroke_draw() [&](int texture_slot) { set_active_texture_unit(texture_slot); }, - [&] { + [&](int) { dual_brush->m_tip_texture ? dual_brush->m_tip_texture->bind() : unbind_texture_2d(); }, - [&] { + [&](int) { dual_brush->m_tip_texture ? dual_brush->m_tip_texture->unbind() : unbind_texture_2d(); - })); + }, + 0)); }, .setup_dual_shader = [&] { pp::panopainter::setup_legacy_stroke_dual_shader( diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index 0f494f0..03da4a9 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -116,6 +116,22 @@ struct LegacyCanvasStrokeTextureInputDispatch { }; } +[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_brush_tip_texture_dispatch( + std::function activate_texture_unit, + std::function bind_brush_tip, + std::function unbind_brush_tip, + int face_index) +{ + return make_legacy_canvas_stroke_brush_tip_texture_dispatch( + std::move(activate_texture_unit), + [bind_brush_tip = std::move(bind_brush_tip), face_index]() { + bind_brush_tip(face_index); + }, + [unbind_brush_tip = std::move(unbind_brush_tip), face_index]() { + unbind_brush_tip(face_index); + }); +} + [[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_destination_texture_dispatch( std::function activate_texture_unit, std::function bind_stroke_destination, diff --git a/tests/paint_renderer/stroke_execution_tests.cpp b/tests/paint_renderer/stroke_execution_tests.cpp index 87e1249..d04819a 100644 --- a/tests/paint_renderer/stroke_execution_tests.cpp +++ b/tests/paint_renderer/stroke_execution_tests.cpp @@ -309,6 +309,27 @@ void retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_callback_ PP_EXPECT(h, events == expected_events); } +void retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_face_wiring(pp::tests::Harness& h) +{ + std::vector events; + const auto dispatch = pp::panopainter::make_legacy_canvas_stroke_brush_tip_texture_dispatch( + [&](int slot) { events.emplace_back("activate:" + std::to_string(slot)); }, + [&](int face_index) { events.emplace_back("bind:" + std::to_string(face_index)); }, + [&](int face_index) { events.emplace_back("unbind:" + std::to_string(face_index)); }, + 2); + + dispatch.activate_texture_unit(0); + dispatch.bind_brush_tip(); + dispatch.unbind_brush_tip(); + + const std::vector expected_events { + "activate:0", + "bind:2", + "unbind:2", + }; + 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; @@ -1818,6 +1839,9 @@ int main() harness.run( "retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_callback_wiring", retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_callback_wiring); + harness.run( + "retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_face_wiring", + retained_stroke_brush_tip_texture_dispatch_helper_builds_expected_face_wiring); harness.run( "retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring", retained_stroke_destination_texture_dispatch_helper_builds_expected_callback_wiring);