Extract stroke preview live pass

This commit is contained in:
2026-06-13 16:35:59 +02:00
parent 073becac14
commit 5b8409718d
4 changed files with 170 additions and 70 deletions

View File

@@ -201,25 +201,6 @@ void execute_stroke_preview_final_composite_pass(const StrokePreviewCompositePas
});
}
template <typename Frames, typename BeforeFrame, typename DrawSample>
void execute_stroke_preview_frames(
Frames& frames,
BeforeFrame&& before_frame,
DrawSample&& draw_sample)
{
for (auto& frame : frames) {
before_frame(frame);
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = frame.col,
.alpha = frame.flow,
.opacity = frame.opacity,
});
draw_sample(frame);
}
}
void copy_stroke_preview_framebuffer_to_texture(
Texture2D& texture,
glm::vec2 size,
@@ -427,30 +408,6 @@ void copy_stroke_preview_result_to_texture(Texture2D& preview_texture, glm::vec2
});
}
template <typename ClearTarget, typename ComputeFrames, typename BeforeFrame, typename DrawSample>
void execute_stroke_preview_live_pass(
Texture2D& output_texture,
glm::vec2 size,
bool copy_stroke_destination,
ClearTarget&& clear_target,
ComputeFrames&& compute_frames,
BeforeFrame&& before_frame,
DrawSample&& draw_sample)
{
auto frames = compute_frames();
clear_target();
execute_stroke_preview_frames(
frames,
std::forward<BeforeFrame>(before_frame),
[&](auto& frame) {
draw_sample(frame, output_texture, copy_stroke_destination);
});
copy_stroke_preview_framebuffer_to_texture(
output_texture,
size,
stroke_preview_composite_slots::kStroke);
}
}
std::atomic_int NodeStrokePreview::s_instances{ 0 };
@@ -768,10 +725,7 @@ void NodeStrokePreview::draw_stroke_immediate()
bind_stroke_preview_dual_pass_textures(*dual_brush);
},
.execute_dual_pass = [&] {
execute_stroke_preview_live_pass(
m_tex_dual,
size,
copy_stroke_destination,
pp::panopainter::execute_legacy_stroke_preview_live_pass(
[&] {
m_rtt.clear();
},
@@ -781,8 +735,23 @@ void NodeStrokePreview::draw_stroke_immediate()
[](auto& frame) {
frame.col = { 0, 0, 0, 1 };
},
[&](auto& frame, Texture2D& blend_texture, bool copy_destination) {
/*auto rect =*/ stroke_draw_samples(frame.shapes, blend_texture, copy_destination);
[&](auto& frame) {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = frame.col,
.alpha = frame.flow,
.opacity = frame.opacity,
});
},
[&](auto& frame) {
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex_dual, copy_stroke_destination);
},
[&] {
copy_stroke_preview_framebuffer_to_texture(
m_tex_dual,
size,
stroke_preview_composite_slots::kStroke);
});
},
.capture_background = [&] {
@@ -810,10 +779,7 @@ void NodeStrokePreview::draw_stroke_immediate()
pass_orchestration.composite.uses_mixer);
},
.execute_main_pass = [&] {
execute_stroke_preview_live_pass(
m_tex,
size,
copy_stroke_destination,
pp::panopainter::execute_legacy_stroke_preview_live_pass(
[&] {
m_rtt.clear();
},
@@ -831,8 +797,23 @@ void NodeStrokePreview::draw_stroke_immediate()
glm::vec4 { 0, 0, 0, 1 };
frame.flow = glm::max(frame.flow, m_min_flow);
},
[&](auto& frame, Texture2D& blend_texture, bool copy_destination) {
/*auto rect =*/ stroke_draw_samples(frame.shapes, blend_texture, copy_destination);
[&](auto& frame) {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = frame.col,
.alpha = frame.flow,
.opacity = frame.opacity,
});
},
[&](auto& frame) {
/*auto rect =*/ stroke_draw_samples(frame.shapes, m_tex, copy_stroke_destination);
},
[&] {
copy_stroke_preview_framebuffer_to_texture(
m_tex,
size,
stroke_preview_composite_slots::kStroke);
});
},
.finish_main_pass = [&] {