From 2a29ebb1a995d2e523bc6dff7a7119175d69a9b7 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 16:51:27 +0200 Subject: [PATCH] Reuse stroke brush tip dispatch helper --- docs/modernization/tasks.md | 11 ++++---- src/canvas.cpp | 26 ++++++++++++------- src/legacy_canvas_stroke_execution_services.h | 12 +++++++++ 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 84ee43a..1cabcea 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -509,12 +509,11 @@ Done Checks: Progress Notes: -- 2026-06-13: `Canvas::stroke_draw()` dual-brush replay now routes shader - setup, brush-tip texture binding, live-pass execution, and brush-tip - unbinding through `execute_legacy_canvas_stroke_dual_pass(...)`; the live - adapter still owns the concrete texture callbacks and face-frame replay. - Next slice should target another narrow `stroke_draw()` seam without - reopening landed pad or sample 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 + execution. Next slice should target another narrow `stroke_draw()` seam + without reopening landed pad or sample helpers. - 2026-06-13: `Canvas::stroke_draw()` dual-brush replay now routes shader setup, brush-tip texture binding, live-pass execution, and brush-tip unbinding through `execute_legacy_canvas_stroke_dual_pass(...)`; the live diff --git a/src/canvas.cpp b/src/canvas.cpp index 77cc35b..f3671a5 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -926,16 +926,20 @@ void Canvas::stroke_draw() .bind_brush_tip = [&] { pp::panopainter::bind_legacy_canvas_stroke_texture_inputs( dual_pass_texture_bindings, - pp::panopainter::LegacyCanvasStrokeTextureInputDispatch { - .activate_texture_unit = [&](int texture_slot) { + pp::panopainter::make_legacy_canvas_stroke_brush_tip_texture_dispatch( + [&](int texture_slot) { set_active_texture_unit(texture_slot); }, - .bind_brush_tip = [&] { + [&] { dual_brush->m_tip_texture ? dual_brush->m_tip_texture->bind() : unbind_texture_2d(); }, - }); + [&] { + dual_brush->m_tip_texture ? + dual_brush->m_tip_texture->unbind() : + unbind_texture_2d(); + })); }, .execute_frame_pass = [&] { pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers( @@ -962,16 +966,20 @@ void Canvas::stroke_draw() .unbind_brush_tip = [&] { pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs( dual_pass_texture_bindings, - pp::panopainter::LegacyCanvasStrokeTextureInputDispatch { - .activate_texture_unit = [&](int texture_slot) { + pp::panopainter::make_legacy_canvas_stroke_brush_tip_texture_dispatch( + [&](int texture_slot) { set_active_texture_unit(texture_slot); }, - .unbind_brush_tip = [&] { + [&] { + dual_brush->m_tip_texture ? + dual_brush->m_tip_texture->bind() : + unbind_texture_2d(); + }, + [&] { dual_brush->m_tip_texture ? dual_brush->m_tip_texture->unbind() : unbind_texture_2d(); - }, - }); + })); }, }); } diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index 7193ab9..51d98e9 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -86,6 +86,18 @@ struct LegacyCanvasStrokeTextureInputDispatch { std::function unbind_mixer; }; +[[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) +{ + 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), + }; +} + struct LegacyCanvasStrokeSamplerDispatch { std::function bind_brush_tip_sampler; std::function unbind_brush_tip_sampler;