From a860c74f60bdd11e4e2a32fa3d1aebf61b25fcce Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 23:56:03 +0200 Subject: [PATCH] Wire stroke commit service boundary --- docs/modernization/debt.md | 4 ++ docs/modernization/tasks.md | 4 +- src/canvas.cpp | 86 +++++++++++++++++++++++-------------- 3 files changed, 61 insertions(+), 33 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 9a3b015..b38572b 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -178,6 +178,10 @@ agent or engineer to remove them without reconstructing context from chat. `execute_legacy_canvas_draw_merge_layer_composite(...)`; the retained path still owns the concrete temporary-stroke, layer-texture, and layer-blend callback bodies. +- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::stroke_commit()` now + routes the remaining service wiring through `make_canvas_stroke_commit_request(...)`; + the retained path still owns the concrete history mutation and layer dirty + box updates. - 2026-06-13: DEBT-0036 was narrowed again. `Canvas::stroke_commit()` now builds its retained callback table through `make_legacy_canvas_stroke_commit_callbacks(...)`; the legacy executor still diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 3f2d16f..8f44f10 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -1808,7 +1808,7 @@ cmake --build --preset windows-msvc-default --config Debug --target PanoPainter ### STR-039 - Wire Stroke Commit Service Boundary -Status: Ready +Status: Done Score: +1 renderer boundary and OpenGL parity Debt: `DEBT-0036` Scope: `src/canvas.cpp`, `src/legacy_canvas_stroke_commit_services.h`, `tests/paint_renderer/stroke_execution_tests.cpp` @@ -1819,6 +1819,8 @@ Move the remaining `Canvas::stroke_commit()` service wiring behind the retained stroke-commit helper boundary so the callsite keeps only local history and layer mutation logic. +Closeout: `7cafaaa1` + Done Checks: - `Canvas::stroke_commit()` no longer owns the retained commit-service wiring diff --git a/src/canvas.cpp b/src/canvas.cpp index ff772a8..761f563 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -813,6 +813,41 @@ static auto execute_canvas_stroke_commit_sequence( build_request()); } +template +static auto make_canvas_stroke_commit_request( + 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, + const pp::paint_renderer::CanvasStrokeCommitMaterialPlan& stroke_material) +{ + const auto commit_callbacks = make_canvas_stroke_commit_callbacks( + canvas, + vp, + cc, + blend, + std::forward(set_active_texture_unit), + action, + current_stroke, + sequence, + stroke_material); + + const std::array faces { + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 0, .dirty = canvas.m_dirty_face[0] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 1, .dirty = canvas.m_dirty_face[1] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 2, .dirty = canvas.m_dirty_face[2] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 3, .dirty = canvas.m_dirty_face[3] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 4, .dirty = canvas.m_dirty_face[4] }, + pp::panopainter::LegacyCanvasStrokeCommitFace { .index = 5, .dirty = canvas.m_dirty_face[5] }, + }; + + return pp::panopainter::make_legacy_canvas_stroke_commit_request(faces, sequence, commit_callbacks); +} + std::vector Canvas::stroke_draw_compute(Stroke& stroke) const { auto samples = stroke.compute_samples(); @@ -1678,40 +1713,27 @@ void Canvas::stroke_commit() const auto& b = m_current_stroke->m_brush; const auto stroke_material = canvas_stroke_material_plan(*b, false); - const auto sequence = pp::paint_renderer::plan_canvas_stroke_commit_sequence( - pp::paint_renderer::CanvasStrokeCommitRequest { - .erase_mode = m_current_mode == kCanvasMode::Erase, - .alpha_locked = m_layers[m_current_layer_idx]->m_alpha_locked, - .selection_mask_active = m_smask_active, - .dual_stroke_enabled = stroke_material.composite_pass.use_dual, - .pattern_enabled = stroke_material.composite_pass.use_pattern, - }); - - 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 = execute_canvas_stroke_commit_sequence( [&]() { - return pp::panopainter::make_legacy_canvas_stroke_commit_request(faces, sequence, commit_callbacks); + return make_canvas_stroke_commit_request( + *this, + vp, + cc, + blend, + [&](int texture_slot) { + set_active_texture_unit(texture_slot); + }, + action, + m_current_stroke, + pp::paint_renderer::plan_canvas_stroke_commit_sequence( + pp::paint_renderer::CanvasStrokeCommitRequest { + .erase_mode = m_current_mode == kCanvasMode::Erase, + .alpha_locked = m_layers[m_current_layer_idx]->m_alpha_locked, + .selection_mask_active = m_smask_active, + .dual_stroke_enabled = stroke_material.composite_pass.use_dual, + .pattern_enabled = stroke_material.composite_pass.use_pattern, + }), + stroke_material); }); }