From 3478219a3ec36d1037e8cabfbf67eba8dd1492b1 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 23:27:56 +0200 Subject: [PATCH] Extract stroke draw pad face orchestration --- src/canvas.cpp | 71 ++++++++++++++++++++++++++++++-------------------- src/canvas.h | 6 +++++ 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/canvas.cpp b/src/canvas.cpp index e9202a2..d06f178 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -876,6 +876,46 @@ void Canvas::stroke_draw_pad_pass( }); } +void Canvas::stroke_draw_pad_face_orchestration( + const std::array& box_dirty, + const std::array& box_face, + bool copy_stroke_destination, + const pp::renderer::Extent2D& stroke_extent, + const glm::vec4& pad_color) +{ + pp::panopainter::setup_legacy_stroke_pad_shader( + pp::panopainter::LegacyStrokePadUniforms { + .color = pad_color, + .uses_destination_feedback = copy_stroke_destination, + }); + const auto pad_faces = pp::panopainter::make_legacy_canvas_stroke_pad_faces(box_dirty, box_face); + constexpr std::array pad_destination_texture_binding { + pp::panopainter::LegacyCanvasStrokeTextureBinding { + .input = pp::panopainter::LegacyCanvasStrokeTextureInput::stroke_destination, + .slot = 1, + }, + }; + const auto pad_destination_texture_dispatch = + pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch( + [&](int texture_slot) { + set_active_texture_unit(texture_slot); + }, + [&](int dst_face_index) { + m_tex[dst_face_index].bind(); + }, + [&](int dst_face_index) { + m_tex[dst_face_index].unbind(); + }, + 0); + stroke_draw_pad_pass( + pad_faces, + copy_stroke_destination, + pad_destination_texture_binding, + pad_destination_texture_dispatch, + stroke_extent, + pad_color); +} + void Canvas::stroke_draw_dual_pass( const std::vector& frames_dual, const std::array& dual_pass_texture_bindings, @@ -1172,35 +1212,10 @@ void Canvas::stroke_draw() // NOTE: at the moment this works on the whole canvas, but it can be optimized // to only affect the current dirty box. In this case it may be necessary to do this // work on documents that doesn't have the padding, so on document loading. - pp::panopainter::setup_legacy_stroke_pad_shader( - pp::panopainter::LegacyStrokePadUniforms { - .color = pad_color, - .uses_destination_feedback = copy_stroke_destination, - }); - const auto pad_faces = pp::panopainter::make_legacy_canvas_stroke_pad_faces(box_dirty, box_face); - constexpr std::array pad_destination_texture_binding { - pp::panopainter::LegacyCanvasStrokeTextureBinding { - .input = pp::panopainter::LegacyCanvasStrokeTextureInput::stroke_destination, - .slot = 1, - }, - }; - const auto pad_destination_texture_dispatch = - pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch( - [&](int texture_slot) { - set_active_texture_unit(texture_slot); - }, - [&](int dst_face_index) { - m_tex[dst_face_index].bind(); - }, - [&](int dst_face_index) { - m_tex[dst_face_index].unbind(); - }, - 0); - stroke_draw_pad_pass( - pad_faces, + stroke_draw_pad_face_orchestration( + box_dirty, + box_face, copy_stroke_destination, - pad_destination_texture_binding, - pad_destination_texture_dispatch, stroke_extent, pad_color); diff --git a/src/canvas.h b/src/canvas.h index 8f752d6..5500a7c 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -247,6 +247,12 @@ private: const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& pad_destination_texture_dispatch, const pp::renderer::Extent2D& stroke_extent, const glm::vec4& pad_color); + void stroke_draw_pad_face_orchestration( + const std::array& box_dirty, + const std::array& box_face, + bool copy_stroke_destination, + const pp::renderer::Extent2D& stroke_extent, + const glm::vec4& pad_color); void stroke_draw_dual_pass( const std::vector& frames_dual, const std::array& dual_pass_texture_bindings,