From 7659f4907bd039ae26808192a2a760951dfda729 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 16:52:08 +0200 Subject: [PATCH] Reuse main stroke texture dispatch helper --- docs/modernization/tasks.md | 6 +++ src/canvas.cpp | 42 +++++++++---------- src/legacy_canvas_stroke_execution_services.h | 18 ++++++++ 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 1cabcea..8c952c9 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -509,6 +509,12 @@ Done Checks: Progress Notes: +- 2026-06-13: `Canvas::stroke_draw()` main-pass texture dispatch now reuses + retained helper builders for texture-unit, brush-tip, pattern, and mixer + callback wiring; the live adapter still owns the concrete textures and + sampler state. Next slice should target the remaining inline `stroke_draw()` + dispatch construction or another narrow seam without reopening landed pad or + dual-pass helpers. - 2026-06-13: `Canvas::stroke_draw()` dual-brush replay now reuses the new retained brush-tip texture dispatch helper for binding and unbinding; the live adapter still owns the concrete brush texture object and live-pass diff --git a/src/canvas.cpp b/src/canvas.cpp index f3671a5..f8512d6 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -758,27 +758,27 @@ void Canvas::stroke_draw() }, }; const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch main_pass_texture_dispatch { - .activate_texture_unit = [&](int texture_slot) { - set_active_texture_unit(texture_slot); - }, - .bind_brush_tip = [&] { - brush->m_tip_texture->bind(); - }, - .unbind_brush_tip = [&] { - brush->m_tip_texture->unbind(); - }, - .bind_pattern = [&] { - brush->m_pattern_texture ? - brush->m_pattern_texture->bind() : - unbind_texture_2d(); - }, - .bind_mixer = [&] { - m_mixer.bindTexture(); - }, - .unbind_mixer = [&] { - m_mixer.unbindTexture(); - }, - }; + pp::panopainter::make_legacy_canvas_stroke_main_pass_texture_dispatch( + [&](int texture_slot) { + set_active_texture_unit(texture_slot); + }, + [&] { + brush->m_tip_texture->bind(); + }, + [&] { + brush->m_tip_texture->unbind(); + }, + [&] { + brush->m_pattern_texture ? + brush->m_pattern_texture->bind() : + unbind_texture_2d(); + }, + [&] { + m_mixer.bindTexture(); + }, + [&] { + m_mixer.unbindTexture(); + }); pp::panopainter::bind_legacy_canvas_stroke_sampler_inputs( live_pass_sampler_bindings, live_pass_sampler_dispatch); diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index 51d98e9..a6a0a87 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -86,6 +86,24 @@ struct LegacyCanvasStrokeTextureInputDispatch { std::function unbind_mixer; }; +[[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_main_pass_texture_dispatch( + std::function activate_texture_unit, + std::function bind_brush_tip, + std::function unbind_brush_tip, + std::function bind_pattern, + std::function bind_mixer, + std::function unbind_mixer) +{ + return LegacyCanvasStrokeTextureInputDispatch { + .activate_texture_unit = std::move(activate_texture_unit), + .bind_brush_tip = std::move(bind_brush_tip), + .unbind_brush_tip = std::move(unbind_brush_tip), + .bind_pattern = std::move(bind_pattern), + .bind_mixer = std::move(bind_mixer), + .unbind_mixer = std::move(unbind_mixer), + }; +} + [[nodiscard]] inline LegacyCanvasStrokeTextureInputDispatch make_legacy_canvas_stroke_brush_tip_texture_dispatch( std::function activate_texture_unit, std::function bind_brush_tip,