Extract fill modes, preview runtime pockets, and brush item UI
This commit is contained in:
@@ -3,19 +3,13 @@
|
||||
#include "node_stroke_preview.h"
|
||||
#include "texture.h"
|
||||
#include "shader.h"
|
||||
#include "bezier.h"
|
||||
#include "canvas.h"
|
||||
#include "app.h"
|
||||
#include "legacy_canvas_draw_merge_services.h"
|
||||
#include "legacy_canvas_stroke_execution_services.h"
|
||||
#include "legacy_canvas_stroke_preview_services.h"
|
||||
#include "legacy_canvas_stroke_shader_services.h"
|
||||
#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"
|
||||
#include "util.h"
|
||||
#include <array>
|
||||
@@ -119,39 +113,6 @@ void copy_stroke_preview_destination_texture_region(
|
||||
copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height);
|
||||
}
|
||||
|
||||
void execute_stroke_preview_background_capture_pass(
|
||||
glm::vec2 size,
|
||||
bool colorize,
|
||||
Texture2D& background_texture,
|
||||
const std::function<void()>& draw_checkerboard)
|
||||
{
|
||||
const float aspect = size.x / size.y;
|
||||
pp::panopainter::setup_legacy_canvas_draw_merge_checkerboard_shader(
|
||||
pp::panopainter::LegacyCanvasDrawMergeCheckerboardUniforms {
|
||||
.mvp = glm::ortho(-.5f, .5f, -.5f / aspect, .5f / aspect, -1.f, 1.f),
|
||||
.colorize = colorize,
|
||||
});
|
||||
draw_checkerboard();
|
||||
const auto copy_status = pp::paint_renderer::copy_stroke_preview_result_to_texture(
|
||||
[&] {
|
||||
background_texture.bind();
|
||||
},
|
||||
[](
|
||||
int src_x,
|
||||
int src_y,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
int width,
|
||||
int height) {
|
||||
copy_framebuffer_to_texture_2d(src_x, src_y, dst_x, dst_y, width, height);
|
||||
},
|
||||
pp::paint_renderer::StrokePreviewCopySize {
|
||||
.width = static_cast<int>(size.x),
|
||||
.height = static_cast<int>(size.y),
|
||||
});
|
||||
assert(copy_status.ok());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Node* NodeStrokePreview::clone_instantiate() const
|
||||
@@ -240,39 +201,11 @@ glm::vec4 NodeStrokePreview::stroke_draw_samples(
|
||||
|
||||
std::vector<NodeStrokePreview::StrokeFrame> NodeStrokePreview::stroke_draw_compute(const Stroke& stroke, float zoom) const
|
||||
{
|
||||
auto samples = const_cast<Stroke&>(stroke).compute_samples();
|
||||
StrokeSample previous_sample = stroke.m_prev_sample;
|
||||
previous_sample.size *= zoom;
|
||||
for (auto& sample : samples) {
|
||||
sample.size *= zoom;
|
||||
}
|
||||
|
||||
return pp::panopainter::plan_legacy_canvas_stroke_frames(
|
||||
pp::panopainter::LegacyCanvasStrokeComputeRequest {
|
||||
.previous_sample = previous_sample,
|
||||
.samples = samples,
|
||||
.zoom = 1.0f,
|
||||
return pp::panopainter::plan_legacy_node_stroke_preview_stroke_frames(
|
||||
pp::panopainter::LegacyNodeStrokePreviewStrokeComputeRequest {
|
||||
.stroke = stroke,
|
||||
.zoom = zoom,
|
||||
.mixer_size = glm::vec2(m_rtt.getWidth(), m_rtt.getHeight()),
|
||||
},
|
||||
[](
|
||||
std::array<vertex_t, 4>& brush_quad,
|
||||
bool /*project_3d*/,
|
||||
glm::mat4 /*model_view*/) {
|
||||
return brush_quad;
|
||||
},
|
||||
[](
|
||||
glm::vec4 mixer_rect,
|
||||
glm::vec4 color,
|
||||
float flow,
|
||||
float opacity,
|
||||
std::array<vertex_t, 4>&& shapes) -> StrokeFrame {
|
||||
return StrokeFrame {
|
||||
.col = color,
|
||||
.flow = flow,
|
||||
.opacity = opacity,
|
||||
.shapes = std::move(shapes),
|
||||
.mixer_rect = mixer_rect,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -339,12 +272,14 @@ void NodeStrokePreview::draw_stroke_immediate()
|
||||
bind_stroke_preview_dual_pass_textures(dual_brush);
|
||||
},
|
||||
.capture_background = [&](bool colorize) {
|
||||
execute_stroke_preview_background_capture_pass(
|
||||
size,
|
||||
colorize,
|
||||
m_tex_background,
|
||||
[&] {
|
||||
m_plane.draw_fill();
|
||||
pp::panopainter::execute_legacy_node_stroke_preview_background_capture_pass(
|
||||
pp::panopainter::LegacyNodeStrokePreviewBackgroundCaptureRequest {
|
||||
.size = size,
|
||||
.colorize = colorize,
|
||||
.background_texture = m_tex_background,
|
||||
.draw_checkerboard = [&] {
|
||||
m_plane.draw_fill();
|
||||
},
|
||||
});
|
||||
},
|
||||
.compute_frames = [&](const Stroke& stroke, float frame_zoom) {
|
||||
|
||||
Reference in New Issue
Block a user