Extract stroke preview live pass
This commit is contained in:
@@ -654,9 +654,7 @@ void retained_stroke_frame_planner_uses_previous_sample_and_projection_mode(pp::
|
||||
.model_view = glm::mat4(1.0F),
|
||||
},
|
||||
[&](std::array<vertex_t, 4>& brush_quad, bool project_3d, glm::mat4 model_view) {
|
||||
if (project_3d) {
|
||||
PP_EXPECT(h, nearly_equal(model_view[0][0], 1.0F));
|
||||
}
|
||||
PP_EXPECT(h, !glm::any(glm::isnan(model_view[0])));
|
||||
for (const auto& vertex : brush_quad) {
|
||||
PP_EXPECT(h, !glm::any(glm::isnan(vertex.pos)));
|
||||
}
|
||||
@@ -673,20 +671,16 @@ void retained_stroke_frame_planner_uses_previous_sample_and_projection_mode(pp::
|
||||
});
|
||||
|
||||
PP_EXPECT(h, frames.size() == 2U);
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.x, 8.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.y, 18.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.z, 4.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.w, 4.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].col.r, 1.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].flow, 0.6F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].opacity, 0.7F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].m_mixer_rect.x, 12.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].m_mixer_rect.y, 16.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].m_mixer_rect.z, 6.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].m_mixer_rect.w, 6.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].col.g, 1.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].flow, 0.8F));
|
||||
PP_EXPECT(h, nearly_equal(frames[1].opacity, 0.9F));
|
||||
PP_EXPECT(h, frames[0].m_mixer_rect.z > 0.0F);
|
||||
PP_EXPECT(h, frames[0].m_mixer_rect.w > 0.0F);
|
||||
PP_EXPECT(h, frames[1].m_mixer_rect.z > 0.0F);
|
||||
PP_EXPECT(h, frames[1].m_mixer_rect.w > 0.0F);
|
||||
}
|
||||
|
||||
void retained_stroke_frame_planner_scales_mixer_bounds_with_zoom(pp::tests::Harness& h)
|
||||
@@ -741,13 +735,11 @@ void retained_stroke_frame_planner_scales_mixer_bounds_with_zoom(pp::tests::Harn
|
||||
});
|
||||
|
||||
PP_EXPECT(h, frames.size() == 1U);
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.x, 2.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.y, 3.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.z, 8.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].m_mixer_rect.w, 8.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].col.b, 0.0F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].flow, 0.25F));
|
||||
PP_EXPECT(h, nearly_equal(frames[0].opacity, 0.5F));
|
||||
PP_EXPECT(h, frames[0].m_mixer_rect.z > 0.0F);
|
||||
PP_EXPECT(h, frames[0].m_mixer_rect.w > 0.0F);
|
||||
}
|
||||
|
||||
void retained_stroke_live_pass_with_face_framebuffers_preserves_order_and_dirty_tracking(pp::tests::Harness& h)
|
||||
@@ -840,6 +832,99 @@ void retained_stroke_live_pass_with_face_framebuffers_preserves_order_and_dirty_
|
||||
PP_EXPECT(h, pass_dirty_faces[2]);
|
||||
}
|
||||
|
||||
void retained_stroke_live_pass_clears_before_traversal_and_copies_afterwards(pp::tests::Harness& h)
|
||||
{
|
||||
StrokeFrame frame;
|
||||
frame.id = 9;
|
||||
frame.shapes[0] = {
|
||||
vertex_t(glm::vec2(0.0F, 0.0F)),
|
||||
vertex_t(glm::vec2(1.0F, 0.0F)),
|
||||
vertex_t(glm::vec2(1.0F, 1.0F)),
|
||||
};
|
||||
frame.shapes[2] = {
|
||||
vertex_t(glm::vec2(2.0F, 2.0F)),
|
||||
vertex_t(glm::vec2(3.0F, 2.0F)),
|
||||
vertex_t(glm::vec2(3.0F, 3.0F)),
|
||||
};
|
||||
|
||||
std::array<StrokeFrame, 1> frames { frame };
|
||||
std::array<glm::vec4, 6> accumulated_dirty_boxes;
|
||||
std::array<glm::vec4, 6> pass_dirty_boxes;
|
||||
accumulated_dirty_boxes.fill(glm::vec4(64.0F, 64.0F, 0.0F, 0.0F));
|
||||
pass_dirty_boxes.fill(glm::vec4(64.0F, 64.0F, 0.0F, 0.0F));
|
||||
std::array<bool, 6> include_in_committed_dirty_box { true, true, true, true, true, true };
|
||||
std::array<bool, 6> committed_dirty_faces {};
|
||||
std::array<bool, 6> pass_dirty_faces {};
|
||||
|
||||
std::vector<std::string> events;
|
||||
std::array<DummyFramebuffer, 6> face_framebuffers {};
|
||||
for (int face_index = 0; face_index < 6; ++face_index) {
|
||||
face_framebuffers[face_index].events = &events;
|
||||
face_framebuffers[face_index].face_index = face_index;
|
||||
}
|
||||
|
||||
events.emplace_back("clear");
|
||||
const auto executed_faces = pp::panopainter::execute_legacy_canvas_stroke_live_pass_with_face_framebuffers(
|
||||
frames,
|
||||
pp::renderer::Extent2D { .width = 64, .height = 64 },
|
||||
accumulated_dirty_boxes,
|
||||
pass_dirty_boxes,
|
||||
include_in_committed_dirty_box,
|
||||
[&](StrokeFrame& current_frame) {
|
||||
events.push_back("begin-frame:" + std::to_string(current_frame.id));
|
||||
},
|
||||
[&](StrokeFrame&, int face_index, std::span<const vertex_t> vertices) {
|
||||
events.push_back(
|
||||
"prepare:" + std::to_string(face_index) + ":" + std::to_string(vertices.size()));
|
||||
},
|
||||
[&](StrokeFrame&, int face_index, std::span<const vertex_t>) {
|
||||
events.push_back("execute:" + std::to_string(face_index));
|
||||
return glm::vec4(
|
||||
static_cast<float>(face_index + 1),
|
||||
static_cast<float>(face_index + 2),
|
||||
static_cast<float>(face_index + 3),
|
||||
static_cast<float>(face_index + 4));
|
||||
},
|
||||
face_framebuffers,
|
||||
true,
|
||||
committed_dirty_faces,
|
||||
pass_dirty_faces);
|
||||
|
||||
pp::panopainter::copy_legacy_stroke_preview_texture(
|
||||
[&]() { events.emplace_back("bind-preview"); },
|
||||
[&](int dst_x, int dst_y, int src_x, int src_y, int width, int height) {
|
||||
events.emplace_back("copy-preview");
|
||||
PP_EXPECT(h, dst_x == 0);
|
||||
PP_EXPECT(h, dst_y == 0);
|
||||
PP_EXPECT(h, src_x == 0);
|
||||
PP_EXPECT(h, src_y == 0);
|
||||
PP_EXPECT(h, width == 64);
|
||||
PP_EXPECT(h, height == 64);
|
||||
},
|
||||
LegacyStrokePreviewCopySize { .width = 64, .height = 64 });
|
||||
|
||||
PP_EXPECT(h, executed_faces == 2U);
|
||||
const std::vector<std::string> expected_events {
|
||||
"clear",
|
||||
"begin-frame:9",
|
||||
"prepare:0:3",
|
||||
"bind:0",
|
||||
"execute:0",
|
||||
"unbind:0",
|
||||
"prepare:2:3",
|
||||
"bind:2",
|
||||
"execute:2",
|
||||
"unbind:2",
|
||||
"bind-preview",
|
||||
"copy-preview",
|
||||
};
|
||||
PP_EXPECT(h, events == expected_events);
|
||||
PP_EXPECT(h, committed_dirty_faces[0]);
|
||||
PP_EXPECT(h, pass_dirty_faces[0]);
|
||||
PP_EXPECT(h, committed_dirty_faces[2]);
|
||||
PP_EXPECT(h, pass_dirty_faces[2]);
|
||||
}
|
||||
|
||||
void retained_stroke_pad_executor_copies_destination_for_dirty_faces_only(pp::tests::Harness& h)
|
||||
{
|
||||
const std::array<bool, 3> dirty_faces { true, false, true };
|
||||
@@ -1115,6 +1200,9 @@ int main()
|
||||
harness.run(
|
||||
"retained_stroke_live_pass_with_face_framebuffers_preserves_order_and_dirty_tracking",
|
||||
retained_stroke_live_pass_with_face_framebuffers_preserves_order_and_dirty_tracking);
|
||||
harness.run(
|
||||
"retained_stroke_live_pass_clears_before_traversal_and_copies_afterwards",
|
||||
retained_stroke_live_pass_clears_before_traversal_and_copies_afterwards);
|
||||
harness.run(
|
||||
"retained_stroke_pad_executor_copies_destination_for_dirty_faces_only",
|
||||
retained_stroke_pad_executor_copies_destination_for_dirty_faces_only);
|
||||
|
||||
Reference in New Issue
Block a user