From 536f268349ff2bc2565a77004f81c452dc6e1927 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 20:00:21 +0200 Subject: [PATCH] Extract stroke commit request assembly --- docs/modernization/tasks.md | 6 +++ src/canvas.cpp | 42 ++++++++++++------- tests/paint_renderer/compositor_tests.cpp | 50 +++++++++++++++++++++++ 3 files changed, 84 insertions(+), 14 deletions(-) diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 684a6cf..f34f0ff 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -1247,6 +1247,12 @@ Validation: ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_stroke_execution|pp_paint_renderer_compositor" --output-on-failure ``` +### Completed Task Log + +| Date | Task | Score | Validation | Commit | +| --- | --- | ---: | --- | --- | +| 2026-06-13 | STR-014 | +1 renderer boundary and OpenGL parity | `ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_stroke_execution|pp_paint_renderer_compositor" --output-on-failure` | `pending` | + ### STR-011 - Extract Preview Main Pass Orchestration Status: Done diff --git a/src/canvas.cpp b/src/canvas.cpp index 806748a..1afa5e2 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -531,11 +531,13 @@ static auto make_canvas_stroke_mix_pass_shell( }); } +template static auto make_canvas_stroke_commit_callbacks( Canvas& canvas, const glm::vec4& vp, const glm::vec4& cc, bool blend, + SetActiveTextureUnit&& set_active_texture_unit, ActionStroke* action, const Stroke* current_stroke, const pp::paint_renderer::CanvasStrokeCommitSequencePlan& sequence, @@ -734,6 +736,19 @@ static auto make_canvas_stroke_commit_callbacks( }); } +static auto make_canvas_stroke_commit_request( + const std::array& faces, + const pp::paint_renderer::CanvasStrokeCommitSequencePlan& sequence, + const pp::panopainter::LegacyCanvasStrokeCommitCallbacks& callbacks) +{ + return pp::panopainter::LegacyCanvasStrokeCommitRequest { + .context = "Canvas::stroke_commit", + .faces = faces, + .sequence = sequence, + .callbacks = callbacks, + }; +} + glm::vec4 Canvas::stroke_draw_samples( int i, std::vector& P, @@ -1315,31 +1330,30 @@ void Canvas::stroke_commit() .pattern_enabled = stroke_material.composite_pass.use_pattern, }); - std::array faces {}; - for (int i = 0; i < 6; ++i) { - faces[i] = pp::panopainter::LegacyCanvasStrokeCommitFace { - .index = i, - .dirty = m_dirty_face[i], - }; - } - const auto commit_callbacks = make_canvas_stroke_commit_callbacks( *this, vp, cc, blend, + [&](int texture_slot) { + set_active_texture_unit(texture_slot); + }, action, m_current_stroke, sequence, stroke_material); + const std::array faces { + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 0, .dirty = m_dirty_face[0] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 1, .dirty = m_dirty_face[1] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 2, .dirty = m_dirty_face[2] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 3, .dirty = m_dirty_face[3] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 4, .dirty = m_dirty_face[4] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 5, .dirty = m_dirty_face[5] }, + }; + [[maybe_unused]] const auto commit_result = pp::panopainter::execute_legacy_canvas_stroke_commit_sequence( - pp::panopainter::LegacyCanvasStrokeCommitRequest { - .context = "Canvas::stroke_commit", - .faces = faces, - .sequence = sequence, - .callbacks = commit_callbacks, - }); + make_canvas_stroke_commit_request(faces, sequence, commit_callbacks)); } void Canvas::stroke_commit_timelapse() diff --git a/tests/paint_renderer/compositor_tests.cpp b/tests/paint_renderer/compositor_tests.cpp index e78baf0..1e2860f 100644 --- a/tests/paint_renderer/compositor_tests.cpp +++ b/tests/paint_renderer/compositor_tests.cpp @@ -1922,6 +1922,56 @@ void retained_stroke_commit_face_input_binder_forwards_sequence_slots(pp::tests: PP_EXPECT(h, bound_samplers[3].second == 3); } +void retained_stroke_commit_request_builder_preserves_dirty_face_order(pp::tests::Harness& h) +{ + const pp::panopainter::LegacyCanvasStrokeCommitCallbacks callbacks { + .mark_commit_started = []() {}, + .capture_render_state = []() {}, + .prepare_render_state = []() {}, + .restore_render_state = []() {}, + .publish_history = []() {}, + .capture_timelapse_frame = []() {}, + .bind_layer_framebuffer = [](int) {}, + .capture_history_region = [](int) {}, + .apply_layer_dirty_region = [](int) {}, + .copy_layer_to_commit_destination = [](int) {}, + .bind_commit_inputs = [](int) {}, + .execute_erase_composite = [](int) {}, + .execute_paint_composite = [](int) {}, + .copy_committed_to_dilate_source = [](int) {}, + .execute_commit_dilate = [](int) {}, + .unbind_layer_framebuffer = [](int) {}, + }; + const auto sequence = plan_canvas_stroke_commit_sequence( + CanvasStrokeCommitRequest { + .erase_mode = false, + .alpha_locked = false, + .selection_mask_active = true, + .dual_stroke_enabled = true, + .pattern_enabled = true, + }); + const std::array faces { + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 0, .dirty = false }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 1, .dirty = true }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 2, .dirty = false }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 3, .dirty = true }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 4, .dirty = false }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 5, .dirty = true }, + }; + + const auto request = pp::panopainter::LegacyCanvasStrokeCommitRequest { + .context = "test", + .faces = faces, + .sequence = sequence, + .callbacks = callbacks, + }; + + PP_EXPECT(h, request.faces[0].index == 0); + PP_EXPECT(h, request.faces[1].index == 1); + PP_EXPECT(h, request.faces[3].dirty); + PP_EXPECT(h, request.faces[5].index == 5); +} + void retained_stroke_commit_dilate_copy_uses_layer_scratch_slot(pp::tests::Harness& h) { const auto sequence = plan_canvas_stroke_commit_sequence(