Extract preview sample pass request helper

This commit is contained in:
2026-06-14 00:09:36 +02:00
parent cc1dd0dd95
commit 5f66d0e76e
2 changed files with 79 additions and 34 deletions

View File

@@ -322,6 +322,50 @@ std::array<pp::paint_renderer::CanvasStrokePoint, 4> make_stroke_preview_sample_
};
}
pp::panopainter::LegacyStrokeSampleExecutionRequest make_stroke_preview_sample_request(
std::array<vertex_t, 4>& vertices,
const std::array<pp::paint_renderer::CanvasStrokePoint, 4>& sample_points,
glm::vec2 target_size,
Texture2D& blend_texture,
DynamicShape& brush_shape,
bool copy_stroke_destination)
{
return pp::panopainter::LegacyStrokeSampleExecutionRequest {
.context = "NodeStrokePreview::stroke_draw_samples",
.target_size = target_size,
.vertices = vertices,
.sample_points = sample_points,
.copy_stroke_destination = copy_stroke_destination,
.bind_destination_texture = [&] {
bind_stroke_preview_destination_texture(blend_texture);
},
.copy_framebuffer_to_destination_texture = [](
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height) {
copy_stroke_preview_destination_texture_region(
src_x,
src_y,
dst_x,
dst_y,
width,
height);
},
.unbind_destination_texture = [&] {
unbind_stroke_preview_destination_texture(blend_texture);
},
.upload_brush_vertices = [&](std::span<const vertex_t> brush_vertices) {
upload_stroke_preview_brush_vertices(brush_shape, brush_vertices);
},
.draw_brush_shape = [&] {
brush_shape.draw_fill();
},
};
}
void upload_stroke_preview_brush_vertices(DynamicShape& brush_shape, std::span<const vertex_t> vertices)
{
brush_shape.update_vertices(
@@ -338,40 +382,13 @@ glm::vec4 execute_stroke_preview_sample_pass(
{
const auto sample_points = make_stroke_preview_sample_points(vertices);
const auto result = pp::panopainter::execute_legacy_canvas_stroke_sample(
pp::panopainter::LegacyStrokeSampleExecutionRequest {
.context = "NodeStrokePreview::stroke_draw_samples",
.target_size = target_size,
.vertices = vertices,
.sample_points = sample_points,
.copy_stroke_destination = copy_stroke_destination,
.bind_destination_texture = [&] {
bind_stroke_preview_destination_texture(blend_texture);
},
.copy_framebuffer_to_destination_texture = [](
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height) {
copy_stroke_preview_destination_texture_region(
src_x,
src_y,
dst_x,
dst_y,
width,
height);
},
.unbind_destination_texture = [&] {
unbind_stroke_preview_destination_texture(blend_texture);
},
.upload_brush_vertices = [&](std::span<const vertex_t> brush_vertices) {
upload_stroke_preview_brush_vertices(brush_shape, brush_vertices);
},
.draw_brush_shape = [&] {
brush_shape.draw_fill();
},
});
make_stroke_preview_sample_request(
vertices,
sample_points,
target_size,
blend_texture,
brush_shape,
copy_stroke_destination));
return result.dirty_bounds;
}