Extract stroke draw dual pass helper

This commit is contained in:
2026-06-13 23:22:24 +02:00
parent a99a324e5e
commit 07b188de4a
3 changed files with 102 additions and 41 deletions

View File

@@ -876,6 +876,58 @@ void Canvas::stroke_draw_pad_pass(
});
}
void Canvas::stroke_draw_dual_pass(
const std::vector<StrokeFrame>& frames_dual,
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& dual_pass_brush_tip_dispatch,
const pp::renderer::Extent2D& stroke_extent,
const std::array<bool, 6>& include_dual_dirty,
bool uses_pattern,
bool copy_stroke_destination)
{
[[maybe_unused]] const auto dual_result =
pp::panopainter::execute_legacy_canvas_stroke_dual_pass(
pp::panopainter::LegacyCanvasStrokeDualPassRequest {
.context = "Canvas::stroke_draw",
.bind_brush_tip = [&] {
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
dual_pass_texture_bindings,
dual_pass_brush_tip_dispatch);
},
.unbind_brush_tip = [&] {
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
dual_pass_texture_bindings,
dual_pass_brush_tip_dispatch);
},
.setup_dual_shader = [&] {
pp::panopainter::setup_legacy_canvas_stroke_dual_shader(
uses_pattern);
},
.execute_frame_pass = [&] {
pp::panopainter::execute_legacy_canvas_stroke_dual_pass_frame_callbacks(
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);
},
});
}
void Canvas::stroke_draw()
{
if (!(m_current_stroke && m_current_stroke->has_sample()))
@@ -1150,47 +1202,14 @@ void Canvas::stroke_draw()
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);
[[maybe_unused]] const auto dual_result =
pp::panopainter::execute_legacy_canvas_stroke_dual_pass(
pp::panopainter::LegacyCanvasStrokeDualPassRequest {
.context = "Canvas::stroke_draw",
.bind_brush_tip = [&] {
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
dual_pass_texture_bindings,
dual_pass_brush_tip_dispatch);
},
.unbind_brush_tip = [&] {
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
dual_pass_texture_bindings,
dual_pass_brush_tip_dispatch);
},
.setup_dual_shader = [&] {
pp::panopainter::setup_legacy_canvas_stroke_dual_shader(
stroke_material.dual_pass.uses_pattern);
},
.execute_frame_pass = [&] {
pp::panopainter::execute_legacy_canvas_stroke_dual_pass_frame_callbacks(
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);
},
});
stroke_draw_dual_pass(
frames_dual,
dual_pass_texture_bindings,
dual_pass_brush_tip_dispatch,
stroke_extent,
include_dual_dirty,
stroke_material.dual_pass.uses_pattern,
copy_stroke_destination);
}
pp::panopainter::unbind_legacy_canvas_stroke_sampler_inputs(

View File

@@ -247,6 +247,14 @@ private:
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& pad_destination_texture_dispatch,
const pp::renderer::Extent2D& stroke_extent,
const glm::vec4& pad_color);
void stroke_draw_dual_pass(
const std::vector<StrokeFrame>& frames_dual,
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& dual_pass_brush_tip_dispatch,
const pp::renderer::Extent2D& stroke_extent,
const std::array<bool, 6>& include_dual_dirty,
bool uses_pattern,
bool copy_stroke_destination);
Image thumbnail_read(std::string file_path);
void draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj, int i)>, int frame, bool save_history);
void draw_objects(std::function<void(const glm::mat4& camera, const glm::mat4& proj, int i)>, Layer& layer, int frame, bool save_history);