diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 8c952c9..5dedad5 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -509,6 +509,11 @@ Done Checks: Progress Notes: +- 2026-06-13: `Canvas::stroke_draw()` live-pass sampler dispatch now reuses a + retained helper builder for brush-tip, destination, pattern, and mixer + sampler callbacks; the live adapter still owns the concrete sampler objects. + Next slice should target another narrow `stroke_draw()` seam without + reopening landed texture or dual-pass helpers. - 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 diff --git a/src/canvas.cpp b/src/canvas.cpp index f8512d6..070a57c 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -731,32 +731,32 @@ void Canvas::stroke_draw() .slot = 0, }, }; - const pp::panopainter::LegacyCanvasStrokeSamplerDispatch live_pass_sampler_dispatch { - .bind_brush_tip_sampler = [&](int slot) { - m_sampler_brush.bind(slot); - }, - .unbind_brush_tip_sampler = [&] { - m_sampler_brush.unbind(); - }, - .bind_stroke_destination_sampler = [&](int slot) { - m_sampler_nearest.bind(slot); - }, - .unbind_stroke_destination_sampler = [&] { - m_sampler_nearest.unbind(); - }, - .bind_pattern_sampler = [&](int slot) { - m_sampler_stencil.bind(slot); - }, - .unbind_pattern_sampler = [&] { - m_sampler_stencil.unbind(); - }, - .bind_mixer_sampler = [&](int slot) { - m_sampler.bind(slot); - }, - .unbind_mixer_sampler = [&] { - m_sampler.unbind(); - }, - }; + const pp::panopainter::LegacyCanvasStrokeSamplerDispatch live_pass_sampler_dispatch = + pp::panopainter::make_legacy_canvas_stroke_sampler_dispatch( + [&](int slot) { + m_sampler_brush.bind(slot); + }, + [&] { + m_sampler_brush.unbind(); + }, + [&](int slot) { + m_sampler_nearest.bind(slot); + }, + [&] { + m_sampler_nearest.unbind(); + }, + [&](int slot) { + m_sampler_stencil.bind(slot); + }, + [&] { + m_sampler_stencil.unbind(); + }, + [&](int slot) { + m_sampler.bind(slot); + }, + [&] { + m_sampler.unbind(); + }); const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch main_pass_texture_dispatch { pp::panopainter::make_legacy_canvas_stroke_main_pass_texture_dispatch( [&](int texture_slot) { diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index a6a0a87..94fc4a0 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_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), + }; +} + struct LegacyCanvasStrokeFaceDirtyRequest { pp::renderer::Extent2D extent {}; glm::vec4 previous_accumulated_dirty_box {};