Share retained stroke face sample dispatch

This commit is contained in:
2026-06-13 11:00:11 +02:00
parent f234f69502
commit 6cdf8c13a7
5 changed files with 109 additions and 10 deletions

View File

@@ -565,17 +565,33 @@ glm::vec4 Canvas::stroke_draw_samples(
std::vector<vertex_t>& P,
bool copy_stroke_destination)
{
const auto result = pp::panopainter::execute_legacy_canvas_stroke_sample_polygon(
pp::panopainter::LegacyStrokeSamplePolygonExecutionRequest {
constexpr std::array destination_texture_binding {
pp::panopainter::LegacyCanvasStrokeTextureBinding {
.input = pp::panopainter::LegacyCanvasStrokeTextureInput::stroke_destination,
.slot = 1,
},
};
const auto result = pp::panopainter::execute_legacy_canvas_stroke_face_sample_polygon(
pp::panopainter::LegacyStrokeFaceSamplePolygonExecutionRequest {
.context = "Canvas::stroke_draw_samples",
.target_size = { m_width, m_height },
.polygon_vertices = P,
.face_index = i,
.copy_stroke_destination = copy_stroke_destination,
.bind_destination_texture = [&] {
set_active_texture_unit(1);
m_tex[i].bind(); // bg, copy of framebuffer (copied before drawing)
.bind_destination_texture = [&](int face_index) {
pp::panopainter::bind_legacy_canvas_stroke_texture_inputs(
destination_texture_binding,
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
.activate_texture_unit = [&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
.bind_stroke_destination = [&] {
m_tex[face_index].bind(); // bg, copy of framebuffer (copied before drawing)
},
});
},
.copy_framebuffer_to_destination_texture = [](
int,
int src_x,
int src_y,
int dst_x,
@@ -584,16 +600,24 @@ glm::vec4 Canvas::stroke_draw_samples(
int height) {
copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height);
},
.unbind_destination_texture = [&] {
set_active_texture_unit(1);
m_tex[i].unbind();
.unbind_destination_texture = [&](int face_index) {
pp::panopainter::unbind_legacy_canvas_stroke_texture_inputs(
destination_texture_binding,
pp::panopainter::LegacyCanvasStrokeTextureInputDispatch {
.activate_texture_unit = [&](int texture_slot) {
set_active_texture_unit(texture_slot);
},
.unbind_stroke_destination = [&] {
m_tex[face_index].unbind();
},
});
},
.upload_brush_vertices = [&](std::span<const vertex_t> vertices) {
.upload_brush_vertices = [&](int, std::span<const vertex_t> vertices) {
m_brush_shape.update_vertices(
const_cast<vertex_t*>(vertices.data()),
static_cast<int>(vertices.size()));
},
.draw_brush_shape = [&] {
.draw_brush_shape = [&](int) {
m_brush_shape.draw_fill();
},
});