From d03f0c63718ccb6183147593031a78215a87d9f9 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 23:10:48 +0200 Subject: [PATCH] Extract pad stroke copy region helper --- docs/modernization/debt.md | 3 ++ docs/modernization/tasks.md | 8 ++++- src/canvas.cpp | 10 ++----- src/legacy_canvas_stroke_execution_services.h | 13 +++++++++ tests/paint_renderer/compositor_tests.cpp | 29 +++++++++++++++++++ 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 90460a4..f1f0ed9 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -541,6 +541,9 @@ agent or engineer to remove them without reconstructing context from chat. brush-tip dispatch now uses a retained helper object, with regression coverage proving the helper order; the live path still owns the concrete brush-tip texture object and dual-pass branch wiring. +- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::stroke_draw()` pad copy + behavior now uses a retained helper for copy-region wiring; the pad branch + still owns the concrete framebuffer and texture-object callbacks. - 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge` checkerboard background shader setup and final merged-texture redraw setup now route through `legacy_canvas_draw_merge_services.h`. The retained Canvas path still diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 161f3e5..299f462 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -840,7 +840,7 @@ ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_composito ### STR-029 - Extract Stroke Draw Pad Copy Callback Body -Status: Ready +Status: Done Score: +1 renderer boundary and OpenGL parity Debt: `DEBT-0036` Scope: `src/canvas.cpp`, `src/legacy_canvas_stroke_execution_services.h`, `tests/paint_renderer/compositor_tests.cpp` @@ -864,6 +864,12 @@ Validation: ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_compositor|pp_paint_renderer_stroke_execution" --output-onfailure ``` +### Completed Task Log + +| Date | Task | Score | Validation | Commit | +| --- | --- | --- | --- | --- | +| 2026-06-13 | STR-029 | +1 renderer boundary and OpenGL parity | `ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_compositor|pp_paint_renderer_stroke_execution" --output-onfailure` | `pending` | + Progress Notes: - 2026-06-13: `NodeStrokePreview::draw_stroke_immediate()` now routes final diff --git a/src/canvas.cpp b/src/canvas.cpp index 42cdbf1..fbd67c5 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -1080,13 +1080,9 @@ void Canvas::stroke_draw() face_index)); }, [&](const pp::paint_renderer::CanvasStrokeCopyRegion& copy_region) { - copy_framebuffer_to_texture_2d( - copy_region.x, - copy_region.y, - copy_region.x, - copy_region.y, - copy_region.width, - copy_region.height); + pp::panopainter::execute_legacy_canvas_stroke_pad_copy_region( + copy_region, + copy_framebuffer_to_texture_2d); }, [&](int face_index) { pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs( diff --git a/src/legacy_canvas_stroke_execution_services.h b/src/legacy_canvas_stroke_execution_services.h index df155b8..1378d85 100644 --- a/src/legacy_canvas_stroke_execution_services.h +++ b/src/legacy_canvas_stroke_execution_services.h @@ -311,6 +311,19 @@ struct LegacyCanvasStrokePadExecutionResult { [[nodiscard]] inline LegacyCanvasStrokePadExecutionResult execute_legacy_canvas_stroke_pad_faces( const LegacyCanvasStrokePadExecutionRequest& request); +inline void execute_legacy_canvas_stroke_pad_copy_region( + const pp::paint_renderer::CanvasStrokeCopyRegion& copy_region, + const std::function& copy_framebuffer_to_texture_2d) +{ + copy_framebuffer_to_texture_2d( + copy_region.x, + copy_region.y, + copy_region.x, + copy_region.y, + copy_region.width, + copy_region.height); +} + struct LegacyCanvasStrokeMixPassPlane { int index = 0; bool visible = true; diff --git a/tests/paint_renderer/compositor_tests.cpp b/tests/paint_renderer/compositor_tests.cpp index f09803e..d8c8133 100644 --- a/tests/paint_renderer/compositor_tests.cpp +++ b/tests/paint_renderer/compositor_tests.cpp @@ -1934,6 +1934,32 @@ void legacy_canvas_stroke_dual_pass_brush_tip_dispatch_preserves_order(pp::tests PP_EXPECT(h, steps == expected); } +void legacy_canvas_stroke_pad_copy_region_preserves_coordinates(pp::tests::Harness& h) +{ + std::vector steps; + pp::panopainter::execute_legacy_canvas_stroke_pad_copy_region( + pp::paint_renderer::CanvasStrokeCopyRegion { + .x = 7, + .y = 11, + .width = 13, + .height = 17, + }, + [&](int src_x, int src_y, int dst_x, int dst_y, int width, int height) { + steps.emplace_back( + std::to_string(src_x) + "," + + std::to_string(src_y) + "," + + std::to_string(dst_x) + "," + + std::to_string(dst_y) + "," + + std::to_string(width) + "," + + std::to_string(height)); + }); + + const std::vector expected { + "7,11,7,11,13,17", + }; + PP_EXPECT(h, steps == expected); +} + void plans_canvas_stroke_commit_erase_sequence(pp::tests::Harness& h) { const auto plan = plan_canvas_stroke_commit_sequence( @@ -3812,6 +3838,9 @@ int main() harness.run( "legacy_canvas_stroke_dual_pass_brush_tip_dispatch_preserves_order", legacy_canvas_stroke_dual_pass_brush_tip_dispatch_preserves_order); + harness.run( + "legacy_canvas_stroke_pad_copy_region_preserves_coordinates", + legacy_canvas_stroke_pad_copy_region_preserves_coordinates); harness.run("plans_canvas_stroke_commit_erase_sequence", plans_canvas_stroke_commit_erase_sequence); harness.run("plans_canvas_stroke_commit_composite_sequence", plans_canvas_stroke_commit_composite_sequence); harness.run(