From 3acb2da300423a223b21aea0838f91264d5fdf96 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 23:41:04 +0200 Subject: [PATCH] Extract stroke draw samples request assembly --- src/canvas.cpp | 61 +++++++++++++++++++++++++++++--------------------- src/canvas.h | 4 ++++ 2 files changed, 40 insertions(+), 25 deletions(-) diff --git a/src/canvas.cpp b/src/canvas.cpp index f28d13e..d1e3090 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -759,37 +759,48 @@ glm::vec4 Canvas::stroke_draw_samples( m_tex[i].unbind(); }); const auto result = pp::panopainter::execute_legacy_canvas_stroke_face_sample_polygon( - pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest { - .context = "Canvas::stroke_draw_samples", - .target_size = { m_width, m_height }, - .polygon_vertices = P, - .face_index = i, - .copy_stroke_destination = copy_stroke_destination, - .copy_framebuffer_to_destination_texture = []( - int, - int src_x, - int src_y, - int dst_x, - int dst_y, - int width, - int height) { - copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height); - }, - .upload_brush_vertices = [&](int, std::span vertices) { - m_brush_shape.update_vertices( - const_cast(vertices.data()), - static_cast(vertices.size())); - }, - .draw_brush_shape = [&](int) { - m_brush_shape.draw_fill(); - }, - }, + make_stroke_draw_samples_request( + i, + P, + copy_stroke_destination), destination_texture_binding, destination_texture_dispatch); return result.dirty_bounds; } +pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest Canvas::make_stroke_draw_samples_request( + int face_index, + std::vector& polygon_vertices, + bool copy_stroke_destination) const +{ + return pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest { + .context = "Canvas::stroke_draw_samples", + .target_size = { m_width, m_height }, + .polygon_vertices = polygon_vertices, + .face_index = face_index, + .copy_stroke_destination = copy_stroke_destination, + .copy_framebuffer_to_destination_texture = []( + int, + int src_x, + int src_y, + int dst_x, + int dst_y, + int width, + int height) { + copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height); + }, + .upload_brush_vertices = [&](int, std::span vertices) { + m_brush_shape.update_vertices( + const_cast(vertices.data()), + static_cast(vertices.size())); + }, + .draw_brush_shape = [&](int) { + m_brush_shape.draw_fill(); + }, + }; +} + template static auto execute_canvas_stroke_commit_sequence( BuildRequest&& build_request) diff --git a/src/canvas.h b/src/canvas.h index 0e0eb1d..b467ce4 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -279,6 +279,10 @@ private: void draw_merge_final_plane_composite( const glm::mat4& ortho, bool draw_checkerboard); + pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest make_stroke_draw_samples_request( + int face_index, + std::vector& polygon_vertices, + bool copy_stroke_destination) const; void stroke_draw_dual_pass( const std::vector& frames_dual, const std::array& dual_pass_texture_bindings,