Route Canvas erase setup through helper
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<bool, 6> 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);
|
||||
|
||||
@@ -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<void(kShader)> use_shader;
|
||||
std::function<void(kShaderUniform, int)> set_int;
|
||||
std::function<void(kShaderUniform, float)> set_float;
|
||||
std::function<void(kShaderUniform, const glm::mat4&)> 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user