Extract stroke draw pad face orchestration

This commit is contained in:
2026-06-13 23:27:56 +02:00
parent c4c7994f88
commit 3478219a3e
2 changed files with 49 additions and 28 deletions

View File

@@ -876,6 +876,46 @@ void Canvas::stroke_draw_pad_pass(
});
}
void Canvas::stroke_draw_pad_face_orchestration(
const std::array<bool, 6>& box_dirty,
const std::array<glm::vec4, 6>& box_face,
bool copy_stroke_destination,
const pp::renderer::Extent2D& stroke_extent,
const glm::vec4& pad_color)
{
pp::panopainter::setup_legacy_stroke_pad_shader(
pp::panopainter::LegacyStrokePadUniforms {
.color = pad_color,
.uses_destination_feedback = copy_stroke_destination,
});
const auto pad_faces = pp::panopainter::make_legacy_canvas_stroke_pad_faces(box_dirty, box_face);
constexpr std::array pad_destination_texture_binding {
pp::panopainter::LegacyCanvasStrokeTextureBinding {
.input = pp::panopainter::LegacyCanvasStrokeTextureInput::stroke_destination,
.slot = 1,
},
};
const auto pad_destination_texture_dispatch =
pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch(
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
[&](int dst_face_index) {
m_tex[dst_face_index].bind();
},
[&](int dst_face_index) {
m_tex[dst_face_index].unbind();
},
0);
stroke_draw_pad_pass(
pad_faces,
copy_stroke_destination,
pad_destination_texture_binding,
pad_destination_texture_dispatch,
stroke_extent,
pad_color);
}
void Canvas::stroke_draw_dual_pass(
const std::vector<StrokeFrame>& frames_dual,
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& dual_pass_texture_bindings,
@@ -1172,35 +1212,10 @@ void Canvas::stroke_draw()
// NOTE: at the moment this works on the whole canvas, but it can be optimized
// to only affect the current dirty box. In this case it may be necessary to do this
// work on documents that doesn't have the padding, so on document loading.
pp::panopainter::setup_legacy_stroke_pad_shader(
pp::panopainter::LegacyStrokePadUniforms {
.color = pad_color,
.uses_destination_feedback = copy_stroke_destination,
});
const auto pad_faces = pp::panopainter::make_legacy_canvas_stroke_pad_faces(box_dirty, box_face);
constexpr std::array pad_destination_texture_binding {
pp::panopainter::LegacyCanvasStrokeTextureBinding {
.input = pp::panopainter::LegacyCanvasStrokeTextureInput::stroke_destination,
.slot = 1,
},
};
const auto pad_destination_texture_dispatch =
pp::panopainter::make_legacy_canvas_stroke_pad_destination_texture_dispatch(
[&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
[&](int dst_face_index) {
m_tex[dst_face_index].bind();
},
[&](int dst_face_index) {
m_tex[dst_face_index].unbind();
},
0);
stroke_draw_pad_pass(
pad_faces,
stroke_draw_pad_face_orchestration(
box_dirty,
box_face,
copy_stroke_destination,
pad_destination_texture_binding,
pad_destination_texture_dispatch,
stroke_extent,
pad_color);

View File

@@ -247,6 +247,12 @@ private:
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& pad_destination_texture_dispatch,
const pp::renderer::Extent2D& stroke_extent,
const glm::vec4& pad_color);
void stroke_draw_pad_face_orchestration(
const std::array<bool, 6>& box_dirty,
const std::array<glm::vec4, 6>& box_face,
bool copy_stroke_destination,
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,