Extract node lifecycle, preview runtime, and Win32 input state

This commit is contained in:
2026-06-16 22:18:30 +02:00
parent 24d9d5b6e2
commit 2a2f0c7dd6
12 changed files with 420 additions and 245 deletions

View File

@@ -13,6 +13,7 @@
#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_ui_gl_dispatch.h"
#include "paint_renderer/compositor.h"
#include "renderer_gl/opengl_capabilities.h"
@@ -506,66 +507,45 @@ void NodeStrokePreview::draw_stroke_immediate()
const auto vp = query_stroke_preview_viewport();
const auto cc = query_stroke_preview_clear_color();
float zoom = root()->m_zoom;
glm::vec2 size = { m_rtt.getWidth(), m_rtt.getHeight() };
const auto stroke_setup = pp::panopainter::plan_legacy_node_stroke_preview_stroke_setup(
pp::panopainter::LegacyNodeStrokePreviewStrokeSetupRequest {
const glm::vec2 size = { m_rtt.getWidth(), m_rtt.getHeight() };
const float zoom = root()->m_zoom;
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_immediate_runtime(
pp::panopainter::LegacyNodeStrokePreviewImmediateRuntimeRequest {
.brush = m_brush,
.preview_size = m_size,
.zoom = zoom,
.brush_tip_size = m_brush->m_tip_size,
.min_flow = m_min_flow,
.stroke_max_size_override = m_max_size,
.pad_override = m_pad_override,
.tip_size_pressure = m_brush->m_tip_size_pressure,
.dual_enabled = m_brush->m_dual_enabled,
.dual_size = m_brush->m_dual_size,
.pattern_scale = m_brush->m_pattern_scale,
.pattern_flipx = m_brush->m_pattern_flipx,
.pattern_flipy = m_brush->m_pattern_flipy,
});
glm::mat4 ortho_proj = glm::ortho<float>(0, size.x, 0, size.y, -1, 1);
apply_stroke_preview_viewport(0, 0, m_rtt.getWidth(), m_rtt.getHeight());
m_rtt.bindFramebuffer();
m_rtt.clear();
bind_stroke_preview_live_samplers(
m_sampler_mipmap,
m_sampler_linear,
m_sampler_linear_repeat);
const auto& b = m_brush;
auto prepared_strokes = pp::panopainter::prepare_legacy_node_stroke_preview_strokes(
b,
stroke_setup,
Canvas::I->m_cam_fov,
Canvas::I->m_cam_rot);
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), false);
const auto pass_orchestration = pp::panopainter::plan_legacy_node_stroke_preview_pass_orchestration(
pp::panopainter::make_legacy_node_stroke_preview_pass_orchestration_request(
stroke_preview_render_device_features(),
size,
*b,
ortho_proj));
pp::panopainter::setup_legacy_stroke_shader(pass_orchestration.stroke_shader);
const bool sequence_ok = pp::panopainter::execute_legacy_node_stroke_preview_live_render_passes(
pp::panopainter::LegacyNodeStrokePreviewLiveRenderRequest {
.brush = *b,
.pass_orchestration = pass_orchestration,
.prepared_strokes = prepared_strokes,
.stroke_texture = m_tex,
.mixer_rtt = m_rtt_mixer,
.render_target = m_rtt,
.background_texture = m_tex_background,
.dual_texture = m_tex_dual,
.preview_texture = m_tex_preview,
.camera_fov = Canvas::I->m_cam_fov,
.camera_rot = Canvas::I->m_cam_rot,
.render_device_features = stroke_preview_render_device_features(),
.preview_rtt = m_rtt,
.preview_rtt_mixer = m_rtt_mixer,
.preview_stroke_texture = m_tex,
.preview_dual_texture = m_tex_dual,
.preview_background_texture = m_tex_background,
.preview_image_texture = m_tex_preview,
.linear_sampler = m_sampler_linear,
.repeat_sampler = m_sampler_linear_repeat,
.zoom = zoom,
.min_flow = m_min_flow,
.copy_stroke_destination = pass_orchestration.copy_stroke_destination,
.size = size,
.prepare_render_target = [&] {
apply_stroke_preview_viewport(0, 0, m_rtt.getWidth(), m_rtt.getHeight());
m_rtt.bindFramebuffer();
m_rtt.clear();
bind_stroke_preview_live_samplers(
m_sampler_mipmap,
m_sampler_linear,
m_sampler_linear_repeat);
},
.finish_render_target = [&] {
m_rtt.unbindFramebuffer();
},
.set_blend_enabled = [&](bool enabled) {
apply_stroke_preview_capability(pp::renderer::gl::blend_state(), enabled);
},
.setup_stroke_shader = [](const pp::panopainter::LegacyStrokeShaderSetupUniforms& uniforms) {
pp::panopainter::setup_legacy_stroke_shader(uniforms);
},
.bind_dual_pass_textures = [](const Brush& dual_brush) {
bind_stroke_preview_dual_pass_textures(dual_brush);
},
@@ -592,7 +572,7 @@ void NodeStrokePreview::draw_stroke_immediate()
m_rtt_mixer.unbindTexture();
},
.bind_pattern_texture = [&] {
b->m_pattern_texture ? b->m_pattern_texture->bind() : unbind_texture_2d();
m_brush->m_pattern_texture ? m_brush->m_pattern_texture->bind() : unbind_texture_2d();
},
.draw_composite = [&] {
m_plane.draw_fill();
@@ -600,8 +580,6 @@ void NodeStrokePreview::draw_stroke_immediate()
});
assert(sequence_ok);
m_rtt.unbindFramebuffer();
apply_stroke_preview_viewport(vp.x, vp.y, vp.width, vp.height);
apply_stroke_preview_clear_color(cc);
}