Extract app runtime tail, canvas camera shell, and preview sample services

This commit is contained in:
2026-06-16 22:40:17 +02:00
parent 338f115540
commit 5f76716732
10 changed files with 259 additions and 199 deletions

View File

@@ -0,0 +1,60 @@
#include "pch.h"
#include "legacy_node_stroke_preview_sample_services.h"
namespace pp::panopainter {
namespace {
std::array<pp::paint_renderer::CanvasStrokePoint, 4> make_stroke_preview_sample_points(
const std::array<vertex_t, 4>& vertices)
{
return {
pp::paint_renderer::CanvasStrokePoint { .x = vertices[0].pos.x, .y = vertices[0].pos.y },
pp::paint_renderer::CanvasStrokePoint { .x = vertices[1].pos.x, .y = vertices[1].pos.y },
pp::paint_renderer::CanvasStrokePoint { .x = vertices[2].pos.x, .y = vertices[2].pos.y },
pp::paint_renderer::CanvasStrokePoint { .x = vertices[3].pos.x, .y = vertices[3].pos.y },
};
}
void upload_stroke_preview_brush_vertices(DynamicShape& brush_shape, std::span<const vertex_t> vertices)
{
brush_shape.update_vertices(
const_cast<vertex_t*>(vertices.data()),
static_cast<int>(vertices.size()));
}
LegacyStrokeSampleExecutionRequest make_stroke_preview_sample_request(
const LegacyNodeStrokePreviewSamplePassRequest& request,
const std::array<pp::paint_renderer::CanvasStrokePoint, 4>& sample_points)
{
return LegacyStrokeSampleExecutionRequest {
.context = "NodeStrokePreview::stroke_draw_samples",
.target_size = request.target_size,
.vertices = request.vertices,
.sample_points = sample_points,
.copy_stroke_destination = request.copy_stroke_destination,
.bind_destination_texture = request.bind_destination_texture,
.copy_framebuffer_to_destination_texture = request.copy_framebuffer_to_destination_texture,
.unbind_destination_texture = request.unbind_destination_texture,
.upload_brush_vertices = [&](std::span<const vertex_t> brush_vertices) {
upload_stroke_preview_brush_vertices(request.brush_shape, brush_vertices);
},
.draw_brush_shape = [&] {
request.brush_shape.draw_fill();
},
};
}
} // namespace
glm::vec4 execute_legacy_node_stroke_preview_sample_pass(
const LegacyNodeStrokePreviewSamplePassRequest& request)
{
const auto sample_points = make_stroke_preview_sample_points(request.vertices);
const auto result = execute_legacy_canvas_stroke_sample(
make_stroke_preview_sample_request(request, sample_points));
return result.dirty_bounds;
}
} // namespace pp::panopainter