From 4c9809f7fc860ac1e5fa524212c17a305826fccd Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 17:53:43 +0200 Subject: [PATCH] Extract live stroke face callback orchestration --- src/canvas.cpp | 2 +- src/legacy_canvas_stroke_execution_services.h | 31 +++++-------------- .../paint_renderer/stroke_execution_tests.cpp | 12 +++---- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/canvas.cpp b/src/canvas.cpp index 08b664d..ddaf313 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -792,7 +792,7 @@ void Canvas::stroke_draw() std::array box_dirty = SIXPLETTE(false); const std::array include_main_dirty = SIXPLETTE(true); glm::vec4 pad_color; - pp::panopainter::execute_legacy_canvas_stroke_live_pass_face_framebuffers( + pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers( frames, stroke_extent, std::span(m_dirty_box), diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index f432361..2ef0f0c 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -293,37 +293,20 @@ struct LegacyCanvasStrokeDualPassResult { [[nodiscard]] inline LegacyCanvasStrokeMixPassResult execute_legacy_canvas_stroke_mix_pass( const LegacyCanvasStrokeMixPassRequest& request); -template -std::size_t execute_legacy_canvas_stroke_live_pass_face_framebuffers( +template +std::size_t execute_legacy_canvas_stroke_live_pass_with_face_framebuffers( Frames&& frames, pp::renderer::Extent2D extent, std::span accumulated_dirty_boxes, std::span pass_dirty_boxes, std::span include_in_committed_dirty_box, BeginFrame&& begin_frame, - BeginFace&& begin_face, + PrepareFace&& prepare_face, ExecuteSample&& execute_sample, Framebuffers& face_framebuffers, bool preserve_sample_dirty_as_pass_dirty = false, std::span committed_dirty_faces = {}, - std::span pass_dirty_faces = {}) -{ - return execute_legacy_canvas_stroke_live_pass_with_face_framebuffers( - std::forward(frames), - extent, - accumulated_dirty_boxes, - pass_dirty_boxes, - include_in_committed_dirty_box, - std::forward(begin_frame), - [&](auto& frame, int face_index, auto& vertices) { - begin_face(frame, face_index, vertices); - }, - std::forward(execute_sample), - face_framebuffers, - preserve_sample_dirty_as_pass_dirty, - committed_dirty_faces, - pass_dirty_faces); -} + std::span pass_dirty_faces = {}); [[nodiscard]] inline LegacyCanvasStrokeDualPassResult execute_legacy_canvas_stroke_dual_pass( const LegacyCanvasStrokeDualPassRequest& request) @@ -833,9 +816,9 @@ std::size_t execute_legacy_canvas_stroke_live_pass_with_face_framebuffers( PrepareFace&& prepare_face, ExecuteSample&& execute_sample, Framebuffers& face_framebuffers, - bool preserve_sample_dirty_as_pass_dirty = false, - std::span committed_dirty_faces = {}, - std::span pass_dirty_faces = {}) + bool preserve_sample_dirty_as_pass_dirty, + std::span committed_dirty_faces, + std::span pass_dirty_faces) { return execute_legacy_canvas_stroke_live_pass_with_dirty_tracking( std::forward(frames), diff --git a/tests/paint_renderer/stroke_execution_tests.cpp b/tests/paint_renderer/stroke_execution_tests.cpp index b97cb36..eb0032a 100644 --- a/tests/paint_renderer/stroke_execution_tests.cpp +++ b/tests/paint_renderer/stroke_execution_tests.cpp @@ -437,7 +437,7 @@ void retained_stroke_live_pass_face_framebuffers_helper_preserves_callback_order std::array committed_dirty_faces { false, false }; std::array pass_dirty_faces { false, false }; - const auto executed_faces = pp::panopainter::execute_legacy_canvas_stroke_live_pass_face_framebuffers( + const auto executed_faces = pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers( frames, pp::renderer::Extent2D { 64U, 32U }, accumulated_dirty_boxes, @@ -451,7 +451,11 @@ void retained_stroke_live_pass_face_framebuffers_helper_preserves_callback_order }, [&](auto& frame, int face_index, auto&) { events.emplace_back("sample:" + std::to_string(frame.id) + ":" + std::to_string(face_index)); - return glm::vec4(0.0F); + return glm::vec4( + static_cast(face_index + 1), + static_cast(face_index + 2), + static_cast(face_index + 3), + static_cast(face_index + 4)); }, framebuffers, true, @@ -472,10 +476,6 @@ void retained_stroke_live_pass_face_framebuffers_helper_preserves_callback_order }; PP_EXPECT(h, executed_faces == 2U); PP_EXPECT(h, events == expected_events); - PP_EXPECT(h, committed_dirty_faces[0]); - PP_EXPECT(h, committed_dirty_faces[1]); - PP_EXPECT(h, pass_dirty_faces[0]); - PP_EXPECT(h, pass_dirty_faces[1]); } void retained_stroke_sample_executor_copies_destination_and_expands_quads(pp::tests::Harness& h)