Extract stroke mix request wiring

This commit is contained in:
2026-06-13 19:15:42 +02:00
parent 5b76f3d1f9
commit c62a60a4af
5 changed files with 174 additions and 55 deletions

View File

@@ -420,61 +420,60 @@ void Canvas::stroke_draw_mix(const glm::vec2& bb_min, const glm::vec2& bb_sz)
[&] {
m_mixer.unbindFramebuffer();
},
pp::panopainter::LegacyCanvasStrokeMixPassRequest {
.context = "Canvas::stroke_draw_mix",
.resolution = m_size,
.planes = mix_planes,
.bind_mix_samplers = [&] {
m_sampler.bind(0);
m_sampler.bind(1);
m_sampler.bind(2);
},
.unbind_mix_samplers = [&] {
m_sampler.unbind();
},
.setup_plane_shader = [&](int plane_index, const glm::mat4& plane_mvp_z) {
(void)plane_index;
pp::panopainter::setup_legacy_stroke_composite_shader(
pp::panopainter::LegacyStrokeCompositeUniforms {
.resolution = m_size,
.mvp = plane_mvp_z,
.pattern_texture_slot = 3,
.layer_alpha = 1.0f,
.alpha_lock = false, /*current_layer.m_alpha_locked*/
.mask_enabled = false, /*m_smask_active*/
.use_fragcoord = false,
.blend_mode = b->m_blend_mode,
.use_dual = false,
.use_pattern = false,
});
},
.bind_layer_texture = [&](int plane_index) {
set_active_texture_unit(0);
current_layer.rtt(plane_index).bindTexture();
},
.bind_stroke_texture = [&](int plane_index) {
set_active_texture_unit(1);
m_tmp[plane_index].bindTexture();
},
.bind_mask_texture = [&](int plane_index) {
set_active_texture_unit(2);
m_smask.rtt(plane_index).bindTexture();
},
.draw_plane = [&] {
m_node->m_face_plane.draw_fill();
},
.unbind_mask_texture = [&](int plane_index) {
set_active_texture_unit(2);
m_smask.rtt(plane_index).unbindTexture();
},
.unbind_stroke_texture = [&](int plane_index) {
set_active_texture_unit(1);
m_tmp[plane_index].unbindTexture();
},
.unbind_layer_texture = [&](int plane_index) {
set_active_texture_unit(0);
current_layer.rtt(plane_index).unbindTexture();
},
pp::panopainter::make_legacy_canvas_stroke_mix_pass_request(
"Canvas::stroke_draw_mix",
m_size,
mix_planes,
[&] {
m_sampler.bind(0);
m_sampler.bind(1);
m_sampler.bind(2);
},
[&] {
m_sampler.unbind();
},
[&](int plane_index, const glm::mat4& plane_mvp_z) {
(void)plane_index;
pp::panopainter::setup_legacy_stroke_composite_shader(
pp::panopainter::LegacyStrokeCompositeUniforms {
.resolution = m_size,
.mvp = plane_mvp_z,
.pattern_texture_slot = 3,
.layer_alpha = 1.0f,
.alpha_lock = false, /*current_layer.m_alpha_locked*/
.mask_enabled = false, /*m_smask_active*/
.use_fragcoord = false,
.blend_mode = b->m_blend_mode,
.use_dual = false,
.use_pattern = false,
});
},
[&](int plane_index) {
set_active_texture_unit(0);
current_layer.rtt(plane_index).bindTexture();
},
[&](int plane_index) {
set_active_texture_unit(1);
m_tmp[plane_index].bindTexture();
},
[&](int plane_index) {
set_active_texture_unit(2);
m_smask.rtt(plane_index).bindTexture();
},
[&] {
m_node->m_face_plane.draw_fill();
},
[&](int plane_index) {
set_active_texture_unit(2);
m_smask.rtt(plane_index).unbindTexture();
},
[&](int plane_index) {
set_active_texture_unit(1);
m_tmp[plane_index].unbindTexture();
},
[&](int plane_index) {
set_active_texture_unit(0);
current_layer.rtt(plane_index).unbindTexture();
});
gl.restore();

View File

@@ -340,6 +340,38 @@ struct LegacyCanvasStrokeMixPassResult {
std::size_t composed_planes = 0;
};
[[nodiscard]] inline LegacyCanvasStrokeMixPassRequest make_legacy_canvas_stroke_mix_pass_request(
std::string_view context,
glm::vec2 resolution,
std::span<const LegacyCanvasStrokeMixPassPlane> planes,
std::function<void()> bind_mix_samplers,
std::function<void()> unbind_mix_samplers,
std::function<void(int, const glm::mat4&)> setup_plane_shader,
std::function<void(int)> bind_layer_texture,
std::function<void(int)> bind_stroke_texture,
std::function<void(int)> bind_mask_texture,
std::function<void()> draw_plane,
std::function<void(int)> unbind_mask_texture,
std::function<void(int)> unbind_stroke_texture,
std::function<void(int)> unbind_layer_texture)
{
return LegacyCanvasStrokeMixPassRequest {
.context = context,
.resolution = resolution,
.planes = planes,
.bind_mix_samplers = std::move(bind_mix_samplers),
.unbind_mix_samplers = std::move(unbind_mix_samplers),
.setup_plane_shader = std::move(setup_plane_shader),
.bind_layer_texture = std::move(bind_layer_texture),
.bind_stroke_texture = std::move(bind_stroke_texture),
.bind_mask_texture = std::move(bind_mask_texture),
.draw_plane = std::move(draw_plane),
.unbind_mask_texture = std::move(unbind_mask_texture),
.unbind_stroke_texture = std::move(unbind_stroke_texture),
.unbind_layer_texture = std::move(unbind_layer_texture),
};
}
struct LegacyCanvasStrokeDualPassRequest {
std::string_view context;
std::function<void()> bind_brush_tip;