Extract stroke draw pad face helper

This commit is contained in:
2026-06-13 23:20:01 +02:00
parent fddddbb76c
commit e6f3be1c2e
3 changed files with 114 additions and 31 deletions

View File

@@ -828,6 +828,54 @@ std::vector<Canvas::StrokeFrame> Canvas::stroke_draw_compute(Stroke& stroke) con
});
}
void Canvas::stroke_draw_pad_pass(
const std::array<pp::panopainter::LegacyCanvasStrokePadFace, 6>& pad_faces,
bool copy_stroke_destination,
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& pad_destination_texture_binding,
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& pad_destination_texture_dispatch,
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,
});
[[maybe_unused]] const auto pad_result = pp::panopainter::execute_legacy_canvas_stroke_pad_face_callbacks(
pad_faces,
stroke_extent,
copy_stroke_destination,
[&](std::span<const vertex_t> pad_quad) {
m_brush_shape.update_vertices(
const_cast<vertex_t*>(pad_quad.data()),
static_cast<int>(pad_quad.size()));
},
[&](int face_index) {
m_tmp[face_index].bindFramebuffer();
},
[&](int) {
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
pad_destination_texture_binding,
pad_destination_texture_dispatch);
},
[&](const pp::paint_renderer::CanvasStrokeCopyRegion& copy_region) {
pp::panopainter::execute_legacy_canvas_stroke_pad_copy_region(
copy_region,
copy_framebuffer_to_texture_2d);
},
[&](int) {
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
pad_destination_texture_binding,
pad_destination_texture_dispatch);
},
[&] {
m_brush_shape.draw_fill();
},
[&](int face_index) {
m_tmp[face_index].unbindFramebuffer();
});
}
void Canvas::stroke_draw()
{
if (!(m_current_stroke && m_current_stroke->has_sample()))
@@ -1064,39 +1112,13 @@ void Canvas::stroke_draw()
m_tex[dst_face_index].unbind();
},
0);
[[maybe_unused]] const auto pad_result = pp::panopainter::execute_legacy_canvas_stroke_pad_face_callbacks(
stroke_draw_pad_pass(
pad_faces,
stroke_extent,
copy_stroke_destination,
[&](std::span<const vertex_t> pad_quad) {
m_brush_shape.update_vertices(
const_cast<vertex_t*>(pad_quad.data()),
static_cast<int>(pad_quad.size()));
},
[&](int face_index) {
m_tmp[face_index].bindFramebuffer();
},
[&](int face_index) {
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
pad_destination_texture_binding,
pad_destination_texture_dispatch);
},
[&](const pp::paint_renderer::CanvasStrokeCopyRegion& copy_region) {
pp::panopainter::execute_legacy_canvas_stroke_pad_copy_region(
copy_region,
copy_framebuffer_to_texture_2d);
},
[&](int face_index) {
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
pad_destination_texture_binding,
pad_destination_texture_dispatch);
},
[&] {
m_brush_shape.draw_fill();
},
[&](int face_index) {
m_tmp[face_index].unbindFramebuffer();
});
pad_destination_texture_binding,
pad_destination_texture_dispatch,
stroke_extent,
pad_color);
// DRAW DUAL BRUSH

View File

@@ -238,6 +238,15 @@ public:
bool project_open_thread(std::string file_path);
void inject_xmp(std::string jpg_path);
Image thumbnail_generate(int w, int h);
private:
void stroke_draw_pad_pass(
const std::array<pp::panopainter::LegacyCanvasStrokePadFace, 6>& pad_faces,
bool copy_stroke_destination,
const std::array<pp::panopainter::LegacyCanvasStrokeTextureBinding, 1>& pad_destination_texture_binding,
const pp::panopainter::LegacyCanvasStrokeTextureInputDispatch& pad_destination_texture_dispatch,
const pp::renderer::Extent2D& stroke_extent,
const glm::vec4& pad_color);
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);