diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 884e87a..8950786 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -18,6 +18,11 @@ agent or engineer to remove them without reconstructing context from chat. ## Recent Reductions +- 2026-06-13: DEBT-0036 was narrowed again. `Canvas::stroke_commit` and + `Canvas::draw_merge` retained `CompErase` shader setup now route through + `legacy_canvas_stroke_erase_services.h`; Canvas still owns texture binding, + mask RTT binding, dirty/layer mutation, framebuffer feedback, and draw + execution. - 2026-06-13: DEBT-0036 was narrowed again. `NodeCanvas` live temporary-erase `CompErase` shader setup now routes through `legacy_canvas_stroke_erase_services.h`; the retained node path still owns diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 3a92345..5f7fb8b 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -3009,6 +3009,10 @@ Results: shader setup helper for `CompErase` uniforms, while keeping per-onion-frame alpha updates, texture binding, temporary erase texture selection, and draw execution in the retained node path. +- `Canvas::stroke_commit` and `Canvas::draw_merge` retained erase compositing + now share the stroke erase shader setup helper, while texture binding, mask + RTT binding, dirty/layer mutation, framebuffer feedback, and draw execution + remain in retained Canvas code. - `Canvas::stroke_draw_mix` now shares the retained stroke composite shader helper for mixer-pass `CompDraw` setup, while preserving its caller-specific texture slot uniforms. Mixer framebuffer/scissor state, sampler and texture diff --git a/src/canvas.cpp b/src/canvas.cpp index 7718186..7adac0d 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -3,6 +3,7 @@ #include "canvas.h" #include "app.h" #include "legacy_canvas_draw_merge_services.h" +#include "legacy_canvas_stroke_erase_services.h" #include "legacy_gl_renderbuffer_dispatch.h" #include "legacy_canvas_stroke_commit_services.h" #include "legacy_canvas_stroke_composite_services.h" @@ -1124,13 +1125,15 @@ void Canvas::stroke_commit() m_sampler_stencil.bind(4); }, .execute_erase_composite = [&](int i) { - ShaderManager::use(kShader::CompErase); - ShaderManager::u_int(kShaderUniform::Tex, 0); - ShaderManager::u_int(kShaderUniform::TexStroke, 1); - ShaderManager::u_int(kShaderUniform::TexMask, 2); - ShaderManager::u_int(kShaderUniform::Mask, m_smask_active); - ShaderManager::u_float(kShaderUniform::Alpha, 1); - ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f)); + pp::panopainter::setup_legacy_stroke_erase_shader( + pp::panopainter::LegacyStrokeEraseUniforms { + .mvp = glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f), + .texture_slot = 0, + .stroke_texture_slot = 1, + .mask_texture_slot = 2, + .alpha = 1.0f, + .mask_enabled = m_smask_active, + }); set_active_texture_unit(0); m_tex2[i].bind(); @@ -1302,15 +1305,17 @@ void Canvas::draw_merge(bool draw_checkerboard, std::array faces /*= SI m_sampler.bind(1); m_sampler.bind(2); - ShaderManager::use(kShader::CompErase); - ShaderManager::u_int(kShaderUniform::Tex, 0); - ShaderManager::u_int(kShaderUniform::TexStroke, 1); - ShaderManager::u_int(kShaderUniform::TexMask, 2); //ShaderManager::u_vec2(kShaderUniform::Resolution, zw(m_box) / zoom); - ShaderManager::u_float(kShaderUniform::Alpha, m_layers[layer_index]->m_opacity); //ShaderManager::u_int(kShaderUniform::Lock, m_layers[layer_index]->m_alpha_locked); - ShaderManager::u_int(kShaderUniform::Mask, m_smask_active); - ShaderManager::u_mat4(kShaderUniform::MVP, ortho); + pp::panopainter::setup_legacy_stroke_erase_shader( + pp::panopainter::LegacyStrokeEraseUniforms { + .mvp = ortho, + .texture_slot = 0, + .stroke_texture_slot = 1, + .mask_texture_slot = 2, + .alpha = m_layers[layer_index]->m_opacity, + .mask_enabled = m_smask_active, + }); set_active_texture_unit(0); m_layers[layer_index]->rtt(plane_index).bindTexture(); set_active_texture_unit(1); diff --git a/src/legacy_canvas_stroke_erase_services.h b/src/legacy_canvas_stroke_erase_services.h index 28ff174..0bc3f44 100644 --- a/src/legacy_canvas_stroke_erase_services.h +++ b/src/legacy_canvas_stroke_erase_services.h @@ -11,12 +11,14 @@ struct LegacyStrokeEraseUniforms { int texture_slot = 0; int stroke_texture_slot = 1; int mask_texture_slot = 2; + float alpha = 1.0f; bool mask_enabled = false; }; struct LegacyStrokeEraseShaderExecution { std::function use_shader; std::function set_int; + std::function set_float; std::function set_mat4; }; @@ -25,6 +27,7 @@ struct LegacyStrokeEraseShaderExecution { return { .use_shader = [](kShader shader) { ShaderManager::use(shader); }, .set_int = [](kShaderUniform uniform, int value) { ShaderManager::u_int(uniform, value); }, + .set_float = [](kShaderUniform uniform, float value) { ShaderManager::u_float(uniform, value); }, .set_mat4 = [](kShaderUniform uniform, const glm::mat4& value) { ShaderManager::u_mat4(uniform, value); }, }; } @@ -38,6 +41,7 @@ inline void setup_legacy_stroke_erase_shader( execution.set_int(kShaderUniform::TexStroke, uniforms.stroke_texture_slot); execution.set_int(kShaderUniform::TexMask, uniforms.mask_texture_slot); execution.set_int(kShaderUniform::Mask, uniforms.mask_enabled); + execution.set_float(kShaderUniform::Alpha, uniforms.alpha); execution.set_mat4(kShaderUniform::MVP, uniforms.mvp); }