Add stroke frame planning coverage

This commit is contained in:
2026-06-13 16:26:01 +02:00
parent bec8d4623d
commit 1483b79061
2 changed files with 113 additions and 17 deletions

View File

@@ -605,6 +605,82 @@ void retained_stroke_frame_samples_with_dirty_tracking_updates_after_finish(pp::
PP_EXPECT(h, nearly_equal(pass_dirty_boxes[4].w, 10.0F));
}
void retained_stroke_frame_planner_uses_previous_sample_and_projection_mode(pp::tests::Harness& h)
{
const auto frames = pp::panopainter::plan_legacy_canvas_stroke_frames(
pp::panopainter::LegacyCanvasStrokeComputeRequest {
.previous_sample = StrokeSample {
.col = { 0.25F, 0.5F, 0.75F },
.pos = { 10.0F, 20.0F, 0.0F },
.origin = { 0.0F, 0.0F, 0.0F },
.scale = { 1.0F, 1.0F },
.size = 4.0F,
.flow = 0.5F,
.opacity = 0.75F,
.angle = 0.0F,
},
.samples = std::array<StrokeSample, 2> {
StrokeSample {
.col = { 1.0F, 0.0F, 0.0F },
.pos = { 14.0F, 26.0F, 0.0F },
.origin = { 0.0F, 0.0F, 0.0F },
.scale = { 1.0F, 1.0F },
.size = 2.0F,
.flow = 0.6F,
.opacity = 0.7F,
.angle = 0.0F,
},
StrokeSample {
.col = { 0.0F, 1.0F, 0.0F },
.pos = { 18.0F, 30.0F, 2.0F },
.origin = { 0.0F, 0.0F, 0.0F },
.scale = { 1.0F, 1.0F },
.size = 6.0F,
.flow = 0.8F,
.opacity = 0.9F,
.angle = 0.0F,
},
},
.zoom = 1.0F,
.mixer_size = glm::vec2(64.0F, 64.0F),
.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));
}
for (const auto& vertex : brush_quad) {
PP_EXPECT(h, !glm::any(glm::isnan(vertex.pos)));
}
return std::array<vertex_t, 4> { brush_quad };
},
[](glm::vec4 mixer_rect, glm::vec4 color, float flow, float opacity, auto&& shapes) {
return StrokeFrame {
.col = color,
.flow = flow,
.opacity = opacity,
.shapes = std::move(shapes),
.m_mixer_rect = mixer_rect,
};
});
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));
}
void retained_stroke_live_pass_with_face_framebuffers_preserves_order_and_dirty_tracking(pp::tests::Harness& h)
{
StrokeFrame frame;
@@ -961,6 +1037,9 @@ int main()
harness.run(
"retained_stroke_frame_samples_with_dirty_tracking_updates_after_finish",
retained_stroke_frame_samples_with_dirty_tracking_updates_after_finish);
harness.run(
"retained_stroke_frame_planner_uses_previous_sample_and_projection_mode",
retained_stroke_frame_planner_uses_previous_sample_and_projection_mode);
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);