Extract app runtime tail, canvas camera shell, and preview sample services
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "legacy_canvas_stroke_services.h"
|
||||
#include "legacy_node_stroke_preview_execution_services.h"
|
||||
#include "legacy_node_stroke_preview_runtime_services.h"
|
||||
#include "legacy_node_stroke_preview_sample_services.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "paint_renderer/compositor.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
@@ -242,89 +243,6 @@ void copy_stroke_preview_destination_texture_region(
|
||||
copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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(
|
||||
const_cast<vertex_t*>(vertices.data()),
|
||||
static_cast<int>(vertices.size()));
|
||||
}
|
||||
|
||||
glm::vec4 execute_stroke_preview_sample_pass(
|
||||
std::array<vertex_t, 4>& vertices,
|
||||
glm::vec2 target_size,
|
||||
Texture2D& blend_texture,
|
||||
DynamicShape& brush_shape,
|
||||
bool copy_stroke_destination)
|
||||
{
|
||||
const auto sample_points = make_stroke_preview_sample_points(vertices);
|
||||
const auto result = pp::panopainter::execute_legacy_canvas_stroke_sample(
|
||||
make_stroke_preview_sample_request(
|
||||
vertices,
|
||||
sample_points,
|
||||
target_size,
|
||||
blend_texture,
|
||||
brush_shape,
|
||||
copy_stroke_destination));
|
||||
return result.dirty_bounds;
|
||||
}
|
||||
|
||||
void execute_stroke_preview_background_capture_pass(
|
||||
glm::vec2 size,
|
||||
bool colorize,
|
||||
@@ -441,12 +359,34 @@ glm::vec4 NodeStrokePreview::stroke_draw_samples(
|
||||
bool copy_stroke_destination)
|
||||
{
|
||||
const glm::vec2 size = { m_rtt.getWidth(), m_rtt.getHeight() };
|
||||
return execute_stroke_preview_sample_pass(
|
||||
P,
|
||||
size,
|
||||
blend_tex,
|
||||
m_brush_shape,
|
||||
copy_stroke_destination);
|
||||
return pp::panopainter::execute_legacy_node_stroke_preview_sample_pass(
|
||||
pp::panopainter::LegacyNodeStrokePreviewSamplePassRequest {
|
||||
.target_size = size,
|
||||
.vertices = P,
|
||||
.brush_shape = m_brush_shape,
|
||||
.copy_stroke_destination = copy_stroke_destination,
|
||||
.bind_destination_texture = [&] {
|
||||
bind_stroke_preview_destination_texture(blend_tex);
|
||||
},
|
||||
.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_tex);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<NodeStrokePreview::StrokeFrame> NodeStrokePreview::stroke_draw_compute(const Stroke& stroke, float zoom) const
|
||||
|
||||
Reference in New Issue
Block a user