Integrate dialog export and Apple service teams
This commit is contained in:
@@ -13,6 +13,7 @@ using pp::foundation::StatusCode;
|
||||
using pp::paint::BlendMode;
|
||||
using pp::paint::Rgba;
|
||||
using pp::paint::StrokeBlendMode;
|
||||
using pp::assets::decode_png_rgba8;
|
||||
using pp::paint_renderer::CanvasBlendGateRequest;
|
||||
using pp::paint_renderer::DocumentFaceCompositeRequest;
|
||||
using pp::paint_renderer::DocumentFrameCompositeRequest;
|
||||
@@ -22,6 +23,7 @@ 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::export_document_depth_pngs;
|
||||
using pp::paint_renderer::plan_canvas_blend_gate;
|
||||
using pp::paint_renderer::plan_canvas_stroke_feedback;
|
||||
using pp::paint_renderer::plan_document_depth_export_render;
|
||||
@@ -1176,6 +1178,126 @@ void plans_document_depth_export_renderer_work(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, plan.value().requires_renderer_readback);
|
||||
}
|
||||
|
||||
void exports_document_depth_as_png_payloads(pp::tests::Harness& h)
|
||||
{
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const AnimationFrame base_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
solid_face_payload(0, 1, 1, 255, 0, 0, 255),
|
||||
},
|
||||
},
|
||||
};
|
||||
const AnimationFrame top_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
solid_face_payload(0, 1, 1, 0, 255, 0, 255),
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Base",
|
||||
.frames = std::span<const AnimationFrame>(base_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Top",
|
||||
.frames = std::span<const AnimationFrame>(top_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);
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto exported = export_document_depth_pngs(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
.output_extent = Extent2D { .width = 1, .height = 1 },
|
||||
});
|
||||
PP_EXPECT(h, exported);
|
||||
if (!exported) {
|
||||
return;
|
||||
}
|
||||
|
||||
PP_EXPECT(h, exported.value().output_extent.width == 1U);
|
||||
PP_EXPECT(h, exported.value().output_extent.height == 1U);
|
||||
PP_EXPECT(h, exported.value().image_encoded_bytes > 0U);
|
||||
PP_EXPECT(h, exported.value().depth_encoded_bytes > 0U);
|
||||
PP_EXPECT(h, exported.value().merged_face_draw_count == pp::document::cube_face_count);
|
||||
PP_EXPECT(h, exported.value().layer_depth_draw_count == 2U);
|
||||
PP_EXPECT(h, exported.value().visited_layer_count == 2U);
|
||||
PP_EXPECT(h, exported.value().visible_layer_count == 2U);
|
||||
PP_EXPECT(h, exported.value().face_payload_count == 2U);
|
||||
PP_EXPECT(h, exported.value().uses_perspective_camera);
|
||||
|
||||
const auto image = decode_png_rgba8(exported.value().image_png);
|
||||
const auto depth = decode_png_rgba8(exported.value().depth_png);
|
||||
PP_EXPECT(h, image);
|
||||
PP_EXPECT(h, depth);
|
||||
if (!image || !depth) {
|
||||
return;
|
||||
}
|
||||
|
||||
PP_EXPECT(h, image.value().width == 1U);
|
||||
PP_EXPECT(h, image.value().height == 1U);
|
||||
PP_EXPECT(h, depth.value().width == 1U);
|
||||
PP_EXPECT(h, depth.value().height == 1U);
|
||||
const std::vector<std::uint8_t> expected_image { 0, 255, 0, 255 };
|
||||
const std::vector<std::uint8_t> expected_depth { 170, 170, 170, 255 };
|
||||
PP_EXPECT(h, image.value().pixels == expected_image);
|
||||
PP_EXPECT(h, depth.value().pixels == expected_depth);
|
||||
}
|
||||
|
||||
void depth_export_payload_boundary_rejects_malformed_face_bytes(pp::tests::Harness& h)
|
||||
{
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const AnimationFrame bad_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = {
|
||||
LayerFacePixels {
|
||||
.face_index = 0,
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.rgba8 = { 255, 0, 0 },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Broken",
|
||||
.frames = std::span<const AnimationFrame>(bad_frames, 1),
|
||||
},
|
||||
};
|
||||
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.ok());
|
||||
PP_EXPECT(h, document.status().code == StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
{
|
||||
RecordingRenderDevice device;
|
||||
@@ -1194,6 +1316,8 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
pp::paint_renderer::DocumentAnimationFrameEquirectangularPngExportRequest {});
|
||||
const auto no_document_depth = plan_document_depth_export_render(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {});
|
||||
const auto no_document_depth_pngs = export_document_depth_pngs(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {});
|
||||
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
@@ -1232,6 +1356,17 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
.frame_index = 0,
|
||||
.output_extent = Extent2D {},
|
||||
});
|
||||
const auto bad_frame_depth_pngs = export_document_depth_pngs(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 1,
|
||||
});
|
||||
const auto bad_extent_depth_pngs = export_document_depth_pngs(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
.output_extent = Extent2D {},
|
||||
});
|
||||
const auto bad_jpeg_quality = pp::paint_renderer::export_document_frame_equirectangular_jpeg(
|
||||
DocumentFrameCompositeRequest {
|
||||
.document = &document.value(),
|
||||
@@ -1253,6 +1388,8 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, no_document_frames.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !no_document_depth.ok());
|
||||
PP_EXPECT(h, no_document_depth.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !no_document_depth_pngs.ok());
|
||||
PP_EXPECT(h, no_document_depth_pngs.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_frame.ok());
|
||||
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_frame_readiness.ok());
|
||||
@@ -1261,6 +1398,10 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, bad_frame_depth.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_extent_depth.ok());
|
||||
PP_EXPECT(h, bad_extent_depth.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_frame_depth_pngs.ok());
|
||||
PP_EXPECT(h, bad_frame_depth_pngs.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_extent_depth_pngs.ok());
|
||||
PP_EXPECT(h, bad_extent_depth_pngs.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !bad_jpeg_quality.ok());
|
||||
PP_EXPECT(h, bad_jpeg_quality.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, device.commands().empty());
|
||||
@@ -1623,6 +1764,10 @@ int main()
|
||||
"exports_document_animation_frames_as_equirectangular_pngs",
|
||||
exports_document_animation_frames_as_equirectangular_pngs);
|
||||
harness.run("plans_document_depth_export_renderer_work", plans_document_depth_export_renderer_work);
|
||||
harness.run("exports_document_depth_as_png_payloads", exports_document_depth_as_png_payloads);
|
||||
harness.run(
|
||||
"depth export payload boundary rejects malformed face bytes",
|
||||
depth_export_payload_boundary_rejects_malformed_face_bytes);
|
||||
harness.run("document_frame_upload_rejects_invalid_requests", document_frame_upload_rejects_invalid_requests);
|
||||
harness.run("detects_feedback_requirements", detects_feedback_requirements);
|
||||
harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths);
|
||||
|
||||
Reference in New Issue
Block a user