Route stroke frame-face traversal through helper
This commit is contained in:
@@ -690,24 +690,21 @@ 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;
|
||||
for (auto& f : frames)
|
||||
{
|
||||
if (brush->m_tip_mix > 0.f)
|
||||
{
|
||||
stroke_draw_mix(xy(f.m_mixer_rect), zw(f.m_mixer_rect));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
auto& P = f.shapes[i];
|
||||
if (P.size() < 3)
|
||||
continue;
|
||||
pp::panopainter::execute_legacy_canvas_stroke_frame_faces(
|
||||
frames,
|
||||
[&](auto& f) {
|
||||
if (brush->m_tip_mix > 0.f)
|
||||
{
|
||||
stroke_draw_mix(xy(f.m_mixer_rect), zw(f.m_mixer_rect));
|
||||
}
|
||||
},
|
||||
[&](auto& f, int i, auto& P) {
|
||||
m_dirty_face[i] = true;
|
||||
merge_faces[i] = true;
|
||||
box_dirty[i] = true;
|
||||
|
||||
m_tmp[i].bindFramebuffer();
|
||||
|
||||
|
||||
pp::panopainter::use_legacy_stroke_shader();
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
@@ -718,7 +715,7 @@ void Canvas::stroke_draw()
|
||||
auto box_sample = stroke_draw_samples(i, P, copy_stroke_destination);
|
||||
|
||||
m_tmp[i].unbindFramebuffer();
|
||||
|
||||
|
||||
const auto dirty_update = pp::panopainter::plan_legacy_canvas_stroke_face_dirty_update(
|
||||
pp::panopainter::LegacyCanvasStrokeFaceDirtyRequest {
|
||||
.extent = stroke_extent,
|
||||
@@ -731,8 +728,7 @@ void Canvas::stroke_draw()
|
||||
box_face[i] = dirty_update.pass_dirty_box;
|
||||
// TODO: maybe average color?
|
||||
pad_color = f.col;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
set_active_texture_unit(3);
|
||||
m_mixer.unbindTexture();
|
||||
@@ -812,19 +808,17 @@ void Canvas::stroke_draw()
|
||||
dual_brush->m_tip_texture->bind() :
|
||||
unbind_texture_2d();
|
||||
auto frames_dual = stroke_draw_compute(*m_dual_stroke);
|
||||
for (auto& f : frames_dual)
|
||||
{
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = f.col,
|
||||
.alpha = f.flow,
|
||||
.opacity = f.opacity,
|
||||
});
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
auto& P = f.shapes[i];
|
||||
if (P.size() < 3)
|
||||
continue;
|
||||
pp::panopainter::execute_legacy_canvas_stroke_frame_faces(
|
||||
frames_dual,
|
||||
[&](auto& f) {
|
||||
pp::panopainter::apply_legacy_stroke_sample_uniforms(
|
||||
pp::panopainter::LegacyStrokeSampleUniforms {
|
||||
.color = f.col,
|
||||
.alpha = f.flow,
|
||||
.opacity = f.opacity,
|
||||
});
|
||||
},
|
||||
[&](auto&, int i, auto& P) {
|
||||
m_tmp_dual[i].bindFramebuffer();
|
||||
auto box_sample = stroke_draw_samples(i, P, copy_stroke_destination);
|
||||
m_tmp_dual[i].unbindFramebuffer();
|
||||
@@ -840,8 +834,7 @@ void Canvas::stroke_draw()
|
||||
stroke_material.composite_pass.dual_blend_mode == 0,
|
||||
});
|
||||
m_dirty_box[i] = dirty_update.accumulated_dirty_box;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
m_sampler_brush.unbind();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "util.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
@@ -152,6 +153,27 @@ template <typename ProjectStroke, typename MakeFrame>
|
||||
return frames;
|
||||
}
|
||||
|
||||
template <typename Frames, typename BeginFrame, typename ExecuteFace>
|
||||
std::size_t execute_legacy_canvas_stroke_frame_faces(
|
||||
Frames&& frames,
|
||||
BeginFrame&& begin_frame,
|
||||
ExecuteFace&& execute_face)
|
||||
{
|
||||
std::size_t executed_faces = 0;
|
||||
for (auto& frame : frames) {
|
||||
begin_frame(frame);
|
||||
for (int face_index = 0; face_index < 6; ++face_index) {
|
||||
auto& vertices = frame.shapes[face_index];
|
||||
if (vertices.size() < 3) {
|
||||
continue;
|
||||
}
|
||||
execute_face(frame, face_index, vertices);
|
||||
++executed_faces;
|
||||
}
|
||||
}
|
||||
return executed_faces;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::paint_renderer::CanvasStrokeBox legacy_canvas_stroke_box(glm::vec4 box) noexcept
|
||||
{
|
||||
return pp::paint_renderer::CanvasStrokeBox {
|
||||
|
||||
Reference in New Issue
Block a user