Share retained stroke frame execution helpers

This commit is contained in:
2026-06-13 09:54:32 +02:00
parent 5dc0bc7342
commit 3f98e4e0c5
5 changed files with 118 additions and 90 deletions

View File

@@ -690,7 +690,7 @@ void Canvas::stroke_draw()
std::array<glm::vec4, 6> box_face = SIXPLETTE(glm::vec4(m_size, 0, 0));
std::array<bool, 6> box_dirty = SIXPLETTE(false);
glm::vec4 pad_color;
pp::panopainter::execute_legacy_canvas_stroke_frame_samples(
pp::panopainter::execute_legacy_canvas_stroke_frame_faces(
frames,
[&](auto& f) {
if (brush->m_tip_mix > 0.f)
@@ -698,33 +698,36 @@ void Canvas::stroke_draw()
stroke_draw_mix(xy(f.m_mixer_rect), zw(f.m_mixer_rect));
}
},
[&](auto&, int i, auto&) {
[&](auto& f, int i, auto& P) {
m_dirty_face[i] = true;
merge_faces[i] = true;
box_dirty[i] = true;
m_tmp[i].bindFramebuffer();
},
[&](auto& f, int i, auto& P) {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = f.col,
.alpha = f.flow,
.opacity = f.opacity,
});
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&](auto& f, int i, glm::vec4 box_sample) {
m_tmp[i].unbindFramebuffer();
[[maybe_unused]] const auto dirty_update = pp::panopainter::apply_legacy_canvas_stroke_face_dirty_update(
[[maybe_unused]] const auto dirty_update = pp::panopainter::execute_legacy_canvas_stroke_face_sample(
pp::panopainter::LegacyCanvasStrokeFaceDirtyRequest {
.extent = stroke_extent,
.previous_accumulated_dirty_box = m_dirty_box[i],
.previous_pass_dirty_box = box_face[i],
.sample_dirty_box = box_sample,
.include_in_committed_dirty_box = true,
},
m_dirty_box[i],
[&] {
pp::panopainter::use_legacy_stroke_shader();
pp::panopainter::apply_legacy_stroke_sample_uniforms(
pp::panopainter::LegacyStrokeSampleUniforms {
.color = f.col,
.alpha = f.flow,
.opacity = f.opacity,
});
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&] {
m_tmp[i].bindFramebuffer();
},
[&](auto&) {},
[&](glm::vec4) {
m_tmp[i].unbindFramebuffer();
},
&m_dirty_box[i],
&box_face[i]);
pad_color = f.col;
});
@@ -803,7 +806,7 @@ void Canvas::stroke_draw()
dual_brush->m_tip_texture->bind() :
unbind_texture_2d();
auto frames_dual = stroke_draw_compute(*m_dual_stroke);
pp::panopainter::execute_legacy_canvas_stroke_frame_samples(
pp::panopainter::execute_legacy_canvas_stroke_frame_faces(
frames_dual,
[&](auto& f) {
pp::panopainter::apply_legacy_stroke_sample_uniforms(
@@ -813,24 +816,28 @@ void Canvas::stroke_draw()
.opacity = f.opacity,
});
},
[&](auto&, int i, auto&) {
m_tmp_dual[i].bindFramebuffer();
},
[&](auto&, int i, auto& P) {
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&](auto&, int i, glm::vec4 box_sample) {
m_tmp_dual[i].unbindFramebuffer();
[[maybe_unused]] const auto dirty_update = pp::panopainter::apply_legacy_canvas_stroke_face_dirty_update(
pp::panopainter::LegacyCanvasStrokeFaceDirtyRequest {
.extent = stroke_extent,
.previous_accumulated_dirty_box = m_dirty_box[i],
.previous_pass_dirty_box = box_sample,
.sample_dirty_box = box_sample,
.include_in_committed_dirty_box =
stroke_material.composite_pass.dual_blend_mode == 0,
},
m_dirty_box[i]);
[[maybe_unused]] const auto dirty_update = pp::panopainter::execute_legacy_canvas_stroke_face_sample(
pp::panopainter::LegacyCanvasStrokeFaceDirtyRequest {
.extent = stroke_extent,
.previous_accumulated_dirty_box = m_dirty_box[i],
.previous_pass_dirty_box = glm::vec4(0.0f),
.include_in_committed_dirty_box =
stroke_material.composite_pass.dual_blend_mode == 0,
},
[&] {
return stroke_draw_samples(i, P, copy_stroke_destination);
},
[&] {
m_tmp_dual[i].bindFramebuffer();
},
[&](auto& request) {
request.previous_pass_dirty_box = request.sample_dirty_box;
},
[&](glm::vec4) {
m_tmp_dual[i].unbindFramebuffer();
},
&m_dirty_box[i]);
});
}