Extract stroke dual pass boundary
This commit is contained in:
112
src/canvas.cpp
112
src/canvas.cpp
@@ -906,67 +906,75 @@ void Canvas::stroke_draw()
|
||||
if (stroke_material.dual_pass.enabled && m_dual_stroke)
|
||||
{
|
||||
const auto& dual_brush = m_dual_stroke->m_brush;
|
||||
pp::panopainter::setup_legacy_stroke_dual_shader(stroke_material.dual_pass.uses_pattern);
|
||||
|
||||
constexpr std::array dual_pass_texture_bindings {
|
||||
pp::panopainter::LegacyCanvasStrokeTextureBinding {
|
||||
.input = pp::panopainter::LegacyCanvasStrokeTextureInput::brush_tip,
|
||||
.slot = 0,
|
||||
},
|
||||
};
|
||||
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.bind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->unbind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
auto frames_dual = stroke_draw_compute(*m_dual_stroke);
|
||||
const std::array<bool, 6> include_dual_dirty =
|
||||
SIXPLETTE(stroke_material.composite_pass.dual_blend_mode == 0);
|
||||
pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers(
|
||||
frames_dual,
|
||||
stroke_extent,
|
||||
std::span<glm::vec4>(m_dirty_box),
|
||||
std::span<glm::vec4>(),
|
||||
std::span<const bool>(include_dual_dirty),
|
||||
[&](auto& f) {
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = f.col,
|
||||
.alpha = f.flow,
|
||||
.opacity = f.opacity,
|
||||
});
|
||||
},
|
||||
[](auto&, int, auto&) {},
|
||||
[&](auto&, int i, auto& P) {
|
||||
return stroke_draw_samples(i, P, copy_stroke_destination);
|
||||
},
|
||||
m_tmp_dual,
|
||||
true);
|
||||
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->unbind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
[[maybe_unused]] const auto dual_result =
|
||||
pp::panopainter::execute_legacy_canvas_stroke_dual_pass(
|
||||
pp::panopainter::LegacyCanvasStrokeDualPassRequest {
|
||||
.context = "Canvas::stroke_draw",
|
||||
.planes = dual_pass_texture_bindings,
|
||||
.setup_dual_shader = [&] {
|
||||
pp::panopainter::setup_legacy_stroke_dual_shader(
|
||||
stroke_material.dual_pass.uses_pattern);
|
||||
},
|
||||
.bind_brush_tip = [&] {
|
||||
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.bind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
},
|
||||
.execute_frame_pass = [&] {
|
||||
pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers(
|
||||
frames_dual,
|
||||
stroke_extent,
|
||||
std::span<glm::vec4>(m_dirty_box),
|
||||
std::span<glm::vec4>(),
|
||||
std::span<const bool>(include_dual_dirty),
|
||||
[&](auto& f) {
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = f.col,
|
||||
.alpha = f.flow,
|
||||
.opacity = f.opacity,
|
||||
});
|
||||
},
|
||||
[](auto&, int, auto&) {},
|
||||
[&](auto&, int i, auto& P) {
|
||||
return stroke_draw_samples(i, P, copy_stroke_destination);
|
||||
},
|
||||
m_tmp_dual,
|
||||
true);
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
|
||||
dual_pass_texture_bindings,
|
||||
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
|
||||
.activate_texture_unit = [&](int texture_slot) {
|
||||
set_active_texture_unit(texture_slot);
|
||||
},
|
||||
.unbind_brush_tip = [&] {
|
||||
dual_brush->m_tip_texture ?
|
||||
dual_brush->m_tip_texture->unbind() :
|
||||
unbind_texture_2d();
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
pp::panopainter::unbind_legacy_canvas_stroke_sampler_inputs(
|
||||
|
||||
Reference in New Issue
Block a user