Plan depth export through document renderer
This commit is contained in:
@@ -24,6 +24,7 @@ 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_document_depth_export_render;
|
||||
using pp::paint_renderer::plan_stroke_composite;
|
||||
using pp::paint_renderer::stroke_composite_path_name;
|
||||
using pp::paint_renderer::stroke_composite_requires_feedback;
|
||||
@@ -1036,6 +1037,80 @@ void exports_document_animation_frames_as_equirectangular_pngs(pp::tests::Harnes
|
||||
PP_EXPECT(h, decoded.value().pixels[2] == 0U);
|
||||
}
|
||||
|
||||
void plans_document_depth_export_renderer_work(pp::tests::Harness& h)
|
||||
{
|
||||
std::vector<LayerFacePixels> visible_faces;
|
||||
visible_faces.push_back(solid_face_payload(0, 1, 1, 255, 0, 0, 255));
|
||||
visible_faces.push_back(solid_face_payload(2, 1, 1, 0, 0, 255, 255));
|
||||
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const AnimationFrame visible_layer_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = visible_faces },
|
||||
};
|
||||
const AnimationFrame hidden_layer_frames[] {
|
||||
{
|
||||
.duration_ms = 100,
|
||||
.face_pixels = solid_cube_faces(1, 1, 255, 255, 0, 255),
|
||||
},
|
||||
};
|
||||
const AnimationFrame empty_layer_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
};
|
||||
const DocumentLayerConfig layers[] {
|
||||
{
|
||||
.name = "Visible",
|
||||
.frames = std::span<const AnimationFrame>(visible_layer_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Hidden",
|
||||
.visible = false,
|
||||
.frames = std::span<const AnimationFrame>(hidden_layer_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "Transparent",
|
||||
.opacity = 0.0F,
|
||||
.frames = std::span<const AnimationFrame>(hidden_layer_frames, 1),
|
||||
},
|
||||
{
|
||||
.name = "EmptyVisible",
|
||||
.frames = std::span<const AnimationFrame>(empty_layer_frames, 1),
|
||||
},
|
||||
};
|
||||
const auto document = CanvasDocument::create_from_snapshot(DocumentSnapshotConfig {
|
||||
.width = 1,
|
||||
.height = 1,
|
||||
.layers = std::span<const DocumentLayerConfig>(layers, 4),
|
||||
.frames = std::span<const AnimationFrame>(root_frames, 1),
|
||||
.selection_masks = {},
|
||||
});
|
||||
PP_EXPECT(h, document);
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto plan = plan_document_depth_export_render(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
});
|
||||
PP_EXPECT(h, plan);
|
||||
if (!plan) {
|
||||
return;
|
||||
}
|
||||
|
||||
PP_EXPECT(h, plan.value().output_extent.width == 1024U);
|
||||
PP_EXPECT(h, plan.value().output_extent.height == 1024U);
|
||||
PP_EXPECT(h, plan.value().merged_face_draw_count == pp::document::cube_face_count);
|
||||
PP_EXPECT(h, plan.value().visited_layer_count == 4U);
|
||||
PP_EXPECT(h, plan.value().visible_layer_count == 2U);
|
||||
PP_EXPECT(h, plan.value().face_payload_count == 2U);
|
||||
PP_EXPECT(h, plan.value().layer_depth_draw_count == 2U);
|
||||
PP_EXPECT(h, plan.value().uses_perspective_camera);
|
||||
PP_EXPECT(h, plan.value().requires_renderer_readback);
|
||||
}
|
||||
|
||||
void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
{
|
||||
RecordingRenderDevice device;
|
||||
@@ -1050,6 +1125,8 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
pp::paint_renderer::DocumentLayerEquirectangularPngExportRequest {});
|
||||
const auto no_document_frames = pp::paint_renderer::export_document_animation_frames_equirectangular_pngs(
|
||||
pp::paint_renderer::DocumentAnimationFrameEquirectangularPngExportRequest {});
|
||||
const auto no_document_depth = plan_document_depth_export_render(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {});
|
||||
|
||||
const AnimationFrame root_frames[] {
|
||||
{ .duration_ms = 100, .face_pixels = {} },
|
||||
@@ -1077,6 +1154,17 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
.document = &document.value(),
|
||||
.frame_index = 1,
|
||||
});
|
||||
const auto bad_frame_depth = plan_document_depth_export_render(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 1,
|
||||
});
|
||||
const auto bad_extent_depth = plan_document_depth_export_render(
|
||||
pp::paint_renderer::DocumentDepthExportRenderPlanRequest {
|
||||
.document = &document.value(),
|
||||
.frame_index = 0,
|
||||
.output_extent = Extent2D {},
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !no_document.ok());
|
||||
PP_EXPECT(h, no_document.status().code == StatusCode::invalid_argument);
|
||||
@@ -1088,10 +1176,16 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, no_document_layers.status().code == StatusCode::invalid_argument);
|
||||
PP_EXPECT(h, !no_document_frames.ok());
|
||||
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, !bad_frame.ok());
|
||||
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_frame_readiness.ok());
|
||||
PP_EXPECT(h, bad_frame_readiness.status().code == StatusCode::out_of_range);
|
||||
PP_EXPECT(h, !bad_frame_depth.ok());
|
||||
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, device.commands().empty());
|
||||
}
|
||||
|
||||
@@ -1448,6 +1542,7 @@ int main()
|
||||
harness.run(
|
||||
"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("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