From 3672f9a5143993464d6672006ac55de8f6417e0b Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 13 Jun 2026 23:51:52 +0200 Subject: [PATCH] Extract preview dual pass live body --- docs/modernization/debt.md | 4 ++ docs/modernization/tasks.md | 30 +++++++++++++++ src/node_stroke_preview.cpp | 75 +++++++++++++++++++++++-------------- src/node_stroke_preview.h | 7 ++++ 4 files changed, 88 insertions(+), 28 deletions(-) diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 2319164..0fa1d86 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -165,6 +165,10 @@ agent or engineer to remove them without reconstructing context from chat. `make_stroke_draw_immediate_main_live_pass_request(...)`; the retained path still owns the concrete frame mutation, sample shader setup, and final mixer unbind. +- 2026-06-13: DEBT-0036 was narrowed again. `NodeStrokePreview::draw_stroke_immediate()` + now routes the dual-pass live body through + `execute_stroke_draw_immediate_dual_pass(...)`; the retained path still owns + the concrete frame mutation, shader setup, and preview copy behavior. - 2026-06-13: DEBT-0036 was narrowed again. `Canvas::draw_merge()` now routes the remaining per-layer branch orchestration through `execute_legacy_canvas_draw_merge_layer_composite(...)`; the retained path diff --git a/docs/modernization/tasks.md b/docs/modernization/tasks.md index 8bac9a3..74fd903 100644 --- a/docs/modernization/tasks.md +++ b/docs/modernization/tasks.md @@ -1745,6 +1745,36 @@ ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_composito cmake --build --preset windows-msvc-default --config Debug --target PanoPainter ``` +### STR-037 - Extract Preview Dual Pass Live Body + +Status: Done +Score: no score movement +Debt: `DEBT-0036` +Scope: `src/node_stroke_preview.cpp`, `tests/paint_renderer/compositor_tests.cpp` + +Goal: + +Move the remaining `NodeStrokePreview::draw_stroke_immediate()` dual-pass live +body into a retained helper so the callsite keeps only sequence orchestration +and preview copy handling. + +Closeout: `a2e805f9` + +Done Checks: + +- `NodeStrokePreview::draw_stroke_immediate()` no longer owns the dual-pass live + body inline. +- Regression coverage proves the helper preserves the dual-pass callback order + and preview copy behavior. +- `docs/modernization/debt.md` records the reduced dual-pass live surface. + +Validation: + +```powershell +ctest --preset desktop-fast --build-config Debug -R "pp_paint_renderer_compositor|pp_paint_renderer_stroke_execution" --output-onfailure +cmake --build --preset windows-msvc-default --config Debug --target PanoPainter +``` + ### STR-010 - Extract Remaining Draw Merge Composite Orchestration ### STR-016 - Extract Draw Merge Layer Composite Execution diff --git a/src/node_stroke_preview.cpp b/src/node_stroke_preview.cpp index fe09f5e..09300a5 100644 --- a/src/node_stroke_preview.cpp +++ b/src/node_stroke_preview.cpp @@ -748,34 +748,13 @@ void NodeStrokePreview::draw_stroke_immediate() bind_stroke_preview_dual_pass_textures(*dual_brush); }, .execute_dual_pass = [&] { - pp::panopainter::execute_legacy_stroke_preview_live_pass( - [&] { - m_rtt.clear(); - }, - [&] { - return stroke_draw_compute(m_dual_stroke, zoom); - }, - [](auto& frame) { - frame.col = { 0, 0, 0, 1 }; - }, - [&](auto& frame) { - pp::panopainter::use_legacy_stroke_shader(); - pp::panopainter::apply_legacy_stroke_sample_uniforms( - pp::panopainter::LegacyStrokeSampleUniforms { - .color = frame.col, - .alpha = frame.flow, - .opacity = frame.opacity, - }); - }, - [&](auto& frame) { - /*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex_dual, copy_stroke_destination); - }, - [&] { - copy_stroke_preview_framebuffer_to_texture( - m_tex_dual, - size, - stroke_preview_composite_slots::kStroke); - }); + execute_stroke_draw_immediate_dual_pass( + *b, + pass_orchestration, + dual_brush, + copy_stroke_destination, + zoom, + size); }, .capture_background = [&] { execute_stroke_preview_background_capture_pass( @@ -893,6 +872,46 @@ NodeStrokePreview::make_stroke_draw_immediate_main_live_pass_request( }; } +void NodeStrokePreview::execute_stroke_draw_immediate_dual_pass( + const Brush& brush, + const pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationPlan& pass_orchestration, + std::shared_ptr dual_brush, + bool copy_stroke_destination, + float zoom, + const glm::vec2& size) +{ + (void)pass_orchestration; + (void)dual_brush; + pp::panopainter::execute_legacy_stroke_preview_live_pass( + [&] { + m_rtt.clear(); + }, + [&] { + return stroke_draw_compute(m_dual_stroke, zoom); + }, + [](auto& frame) { + frame.col = { 0, 0, 0, 1 }; + }, + [&](auto& frame) { + pp::panopainter::use_legacy_stroke_shader(); + pp::panopainter::apply_legacy_stroke_sample_uniforms( + pp::panopainter::LegacyStrokeSampleUniforms { + .color = frame.col, + .alpha = frame.flow, + .opacity = frame.opacity, + }); + }, + [&](auto& frame) { + /*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex_dual, copy_stroke_destination); + }, + [&] { + copy_stroke_preview_framebuffer_to_texture( + m_tex_dual, + size, + stroke_preview_composite_slots::kStroke); + }); +} + Image NodeStrokePreview::render_to_image() { std::lock_guard _lock(s_render_mutex); diff --git a/src/node_stroke_preview.h b/src/node_stroke_preview.h index 4a7a9b9..2e6967d 100644 --- a/src/node_stroke_preview.h +++ b/src/node_stroke_preview.h @@ -59,6 +59,13 @@ public: bool copy_stroke_destination, float zoom, const glm::vec2& size); + void execute_stroke_draw_immediate_dual_pass( + const Brush& brush, + const pp::panopainter::LegacyNodeStrokePreviewPassOrchestrationPlan& pass_orchestration, + std::shared_ptr dual_brush, + bool copy_stroke_destination, + float zoom, + const glm::vec2& size); void draw_stroke(); void draw_stroke_immediate(); Image render_to_image();