Route stroke pad pass through helper callbacks

This commit is contained in:
2026-06-13 10:07:57 +02:00
parent c1724edc47
commit f1f0dd5d03
4 changed files with 82 additions and 30 deletions

View File

@@ -742,10 +742,6 @@ void Canvas::stroke_draw()
.color = pad_color,
.uses_destination_feedback = copy_stroke_destination,
});
if (copy_stroke_destination)
{
set_active_texture_unit(1);
}
const std::array<pp::panopainter::LegacyCanvasStrokePadFace, 6> pad_faces = {
pp::panopainter::LegacyCanvasStrokePadFace { .index = 0, .dirty = box_dirty[0], .pass_dirty_box = box_face[0] },
pp::panopainter::LegacyCanvasStrokePadFace { .index = 1, .dirty = box_dirty[1], .pass_dirty_box = box_face[1] },
@@ -759,32 +755,40 @@ void Canvas::stroke_draw()
.context = "Canvas::stroke_draw",
.extent = stroke_extent,
.faces = pad_faces,
.execute_face =
[&](int face_index,
const pp::panopainter::LegacyCanvasStrokePadRegionResult& pad_region,
std::span<vertex_t> pad_quad) {
m_brush_shape.update_vertices(pad_quad.data(), pad_quad.size());
m_tmp[face_index].bindFramebuffer();
if (copy_stroke_destination)
{
m_tex[face_index].bind();
copy_framebuffer_to_texture_2d(
pad_region.copy_region.x,
pad_region.copy_region.y,
pad_region.copy_region.x,
pad_region.copy_region.y,
pad_region.copy_region.width,
pad_region.copy_region.height);
}
m_brush_shape.draw_fill();
m_tmp[face_index].unbindFramebuffer();
.copy_stroke_destination = copy_stroke_destination,
.upload_pad_vertices = [&](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()));
},
.begin_face = [&](int face_index) {
m_tmp[face_index].bindFramebuffer();
},
.bind_destination_texture = [&](int face_index) {
set_active_texture_unit(1);
m_tex[face_index].bind();
},
.copy_framebuffer_to_destination_texture =
[&](const pp::paint_renderer::CanvasStrokeCopyRegion& copy_region) {
copy_framebuffer_to_texture_2d(
copy_region.x,
copy_region.y,
copy_region.x,
copy_region.y,
copy_region.width,
copy_region.height);
},
.unbind_destination_texture = [&](int face_index) {
set_active_texture_unit(1);
m_tex[face_index].unbind();
},
.draw_pad = [&] {
m_brush_shape.draw_fill();
},
.finish_face = [&](int face_index) {
m_tmp[face_index].unbindFramebuffer();
},
});
if (copy_stroke_destination)
{
unbind_texture_2d();
}
// DRAW DUAL BRUSH