Add document frame render automation
This commit is contained in:
@@ -13,11 +13,13 @@ using pp::paint::Rgba;
|
||||
using pp::paint::StrokeBlendMode;
|
||||
using pp::paint_renderer::CanvasBlendGateRequest;
|
||||
using pp::paint_renderer::DocumentFaceCompositeRequest;
|
||||
using pp::paint_renderer::DocumentFrameCompositeRequest;
|
||||
using pp::paint_renderer::LayerCompositeView;
|
||||
using pp::paint_renderer::StrokeCompositePath;
|
||||
using pp::paint_renderer::StrokeCompositeRequest;
|
||||
using pp::paint_renderer::composite_layer;
|
||||
using pp::paint_renderer::composite_document_face;
|
||||
using pp::paint_renderer::composite_document_frame;
|
||||
using pp::paint_renderer::plan_canvas_blend_gate;
|
||||
using pp::paint_renderer::plan_canvas_stroke_feedback;
|
||||
using pp::paint_renderer::plan_stroke_composite;
|
||||
@@ -331,6 +333,129 @@ void document_face_composite_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_face.status().code == StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
void composites_document_frame_cube_faces(pp::tests::Harness& h)
|
||||
{
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const AnimationFrame base_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 255, 0, 0, 255 },
|
||||
},
|
||||
LayerFacePixels {
|
||||
.face_index = 5,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 0, 0, 255, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame paint_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 5,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 0, 255, 0, 255 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Base",
|
||||
.frames = std::span<const AnimationFrame>(base_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Paint",
|
||||
.opacity = 0.5F,
|
||||
.frames = std::span<const AnimationFrame>(paint_frames, 1),
|
||||
},
|
||||
};
|
||||
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.layers = std::span<const DocumentLayerConfig>(layers, 2),
|
||||
.frames = std::span<const AnimationFrame>(root_frames, 1),
|
||||
.selection_masks = {},
|
||||
});
|
||||
PP_EXPECT(h, document);
|
||||
|
||||
const auto result = composite_document_frame(DocumentFrameCompositeRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
.clear_color = Rgba { .r = 0.25F, .g = 0.25F, .b = 0.25F, .a = 1.0F },
|
||||
});
|
||||
|
||||
PP_EXPECT(h, result);
|
||||
if (result) {
|
||||
PP_EXPECT(h, result.value().extent.width == 1U);
|
||||
PP_EXPECT(h, result.value().extent.height == 1U);
|
||||
PP_EXPECT(h, result.value().faces.size() == pp::document::cube_face_count);
|
||||
PP_EXPECT(h, result.value().visited_layer_count == 2U);
|
||||
PP_EXPECT(h, result.value().composited_layer_face_count == 3U);
|
||||
PP_EXPECT(h, result.value().face_payload_count == 3U);
|
||||
PP_EXPECT(h, result.value().faces[0].pixels.size() == 1U);
|
||||
PP_EXPECT(h, near(result.value().faces[0].pixels[0].r, 1.0F));
|
||||
PP_EXPECT(h, near(result.value().faces[0].pixels[0].g, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().faces[0].pixels[0].b, 0.0F));
|
||||
PP_EXPECT(h, result.value().faces[1].pixels.size() == 1U);
|
||||
PP_EXPECT(h, near(result.value().faces[1].pixels[0].r, 0.25F));
|
||||
PP_EXPECT(h, near(result.value().faces[1].pixels[0].g, 0.25F));
|
||||
PP_EXPECT(h, near(result.value().faces[1].pixels[0].b, 0.25F));
|
||||
PP_EXPECT(h, result.value().faces[5].pixels.size() == 1U);
|
||||
PP_EXPECT(h, near(result.value().faces[5].pixels[0].r, 0.0F));
|
||||
PP_EXPECT(h, near(result.value().faces[5].pixels[0].g, 0.5F));
|
||||
PP_EXPECT(h, near(result.value().faces[5].pixels[0].b, 0.5F));
|
||||
PP_EXPECT(h, near(result.value().faces[5].pixels[0].a, 1.0F));
|
||||
}
|
||||
}
|
||||
|
||||
void document_frame_composite_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
{
|
||||
const auto no_document = composite_document_frame(DocumentFrameCompositeRequest {});
|
||||
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{ .name = "Layer", .frames = {} },
|
||||
};
|
||||
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.layers = std::span<const DocumentLayerConfig>(layers, 1),
|
||||
.frames = std::span<const AnimationFrame>(root_frames, 1),
|
||||
.selection_masks = {},
|
||||
});
|
||||
PP_EXPECT(h, document);
|
||||
|
||||
const auto bad_frame = composite_document_frame(DocumentFrameCompositeRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 1,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !no_document.ok());
|
||||
PP_EXPECT(h, no_document.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_frame.ok());
|
||||
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
|
||||
}
|
||||
|
||||
void detects_feedback_requirements(pp::tests::Harness& h)
|
||||
{
|
||||
PP_EXPECT(h, !stroke_composite_requires_feedback(
|
||||
@@ -673,6 +798,8 @@ int main()
|
||||
harness.run("composites_document_face_payloads_in_layer_order", composites_document_face_payloads_in_layer_order);
|
||||
harness.run("document_face_composite_skips_layers_without_requested_frame", document_face_composite_skips_layers_without_requested_frame);
|
||||
harness.run("document_face_composite_rejects_invalid_requests", document_face_composite_rejects_invalid_requests);
|
||||
harness.run("composites_document_frame_cube_faces", composites_document_frame_cube_faces);
|
||||
harness.run("document_frame_composite_rejects_invalid_requests", document_frame_composite_rejects_invalid_requests);
|
||||
harness.run("detects_feedback_requirements", detects_feedback_requirements);
|
||||
harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths);
|
||||
harness.run("rejects_bad_stroke_composite_plans", rejects_bad_stroke_composite_plans);
|
||||
|
||||
Reference in New Issue
Block a user