Share document export readiness reporting

This commit is contained in:
2026-06-05 20:19:46 +02:00
parent 2d33f9d928
commit ebc84373e6
9 changed files with 181 additions and 87 deletions

View File

@@ -665,12 +665,83 @@ void exports_document_frame_faces_as_pngs(pp::tests::Harness& h)
}
}
void prepares_document_frame_export_readiness_report(pp::tests::Harness& h)
{
const AnimationFrame root_frames[] {
{ .duration_ms = 100, .face_pixels = {} },
};
const AnimationFrame layer_frames[] {
{
.duration_ms = 100,
.face_pixels = {
LayerFacePixels {
.face_index = 2,
.x = 0,
.y = 0,
.width = 1,
.height = 1,
.rgba8 = { 255, 128, 0, 255 },
},
},
},
};
const DocumentLayerConfig layers[] {
{
.name = "Paint",
.frames = std::span<const AnimationFrame>(layer_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);
if (!document) {
return;
}
const auto readiness = pp::paint_renderer::prepare_document_frame_export_readiness(
DocumentFrameCompositeRequest {
.document = &document.value(),
.frame_index = 0,
.clear_color = {},
});
PP_EXPECT(h, readiness);
if (!readiness) {
return;
}
PP_EXPECT(h, readiness.value().recorded_upload.upload.texture_count == pp::document::cube_face_count);
PP_EXPECT(h, readiness.value().recorded_upload.upload.uploaded_bytes == 24U);
PP_EXPECT(h, readiness.value().recorded_upload.command_count == 12U);
PP_EXPECT(h, readiness.value().recorded_upload.upload_command_count == pp::document::cube_face_count);
PP_EXPECT(h, readiness.value().recorded_upload.transition_command_count == pp::document::cube_face_count);
PP_EXPECT(h, readiness.value().face_pngs.face_count == pp::document::cube_face_count);
PP_EXPECT(h, readiness.value().face_pngs.encoded_bytes > 0U);
PP_EXPECT(h, readiness.value().face_pngs.composite.face_payload_count == 1U);
const auto decoded = pp::assets::decode_png_rgba8(readiness.value().face_pngs.face_pngs[2]);
PP_EXPECT(h, decoded);
if (decoded) {
PP_EXPECT(h, decoded.value().pixels[0] == 255U);
PP_EXPECT(h, decoded.value().pixels[1] == 128U);
PP_EXPECT(h, decoded.value().pixels[2] == 0U);
PP_EXPECT(h, decoded.value().pixels[3] == 255U);
}
}
void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
{
RecordingRenderDevice device;
const auto no_document = pp::paint_renderer::upload_document_frame_faces(
device,
pp::paint_renderer::DocumentFrameUploadRequest {});
const auto no_document_readiness = pp::paint_renderer::prepare_document_frame_export_readiness(
DocumentFrameCompositeRequest {});
const AnimationFrame root_frames[] {
{ .duration_ms = 100, .face_pixels = {} },
@@ -693,11 +764,20 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
.document = &document.value(),
.frame_index = 1,
});
const auto bad_frame_readiness = pp::paint_renderer::prepare_document_frame_export_readiness(
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, !no_document_readiness.ok());
PP_EXPECT(h, no_document_readiness.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, device.commands().empty());
}
@@ -1048,6 +1128,7 @@ int main()
harness.run("uploads_document_frame_faces_to_renderer_api", uploads_document_frame_faces_to_renderer_api);
harness.run("records_document_frame_upload_report", records_document_frame_upload_report);
harness.run("exports_document_frame_faces_as_pngs", exports_document_frame_faces_as_pngs);
harness.run("prepares_document_frame_export_readiness_report", prepares_document_frame_export_readiness_report);
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);