Export equirectangular PNGs through paint renderer

This commit is contained in:
2026-06-05 20:31:35 +02:00
parent ebc84373e6
commit 77268a28fb
8 changed files with 378 additions and 19 deletions

View File

@@ -255,7 +255,10 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
recording backend. It also covers the shared recording backend. It also covers the shared
`prepare_document_frame_export_readiness` report consumed by CLI and live `prepare_document_frame_export_readiness` report consumed by CLI and live
export-readiness bridges, including the recorded upload command summary and export-readiness bridges, including the recorded upload command summary and
pure six-face PNG export bytes encoded through `pp_assets`. pure six-face PNG export bytes encoded through `pp_assets`. The compositor
tests now also cover equirectangular PNG export from that same composited
document frame using the shader-equivalent cube sampling policy and
`pp_assets` PNG encoding.
- `pano_cli simulate-document-export` exposes the same pure document-to-PPI - `pano_cli simulate-document-export` exposes the same pure document-to-PPI
export, asset-level decode, and document reimport path through JSON export, asset-level decode, and document reimport path through JSON
automation and is covered by `pano_cli_simulate_document_export_smoke`. automation and is covered by `pano_cli_simulate_document_export_smoke`.
@@ -284,8 +287,10 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
Cube-face export writes the pure document/renderer PNG bytes through the Cube-face export writes the pure document/renderer PNG bytes through the
app-core write/publish executor to the planned retained face filename set and app-core write/publish executor to the planned retained face filename set and
falls back to `Canvas::export_cube_faces` if snapshot capture, PNG generation, falls back to `Canvas::export_cube_faces` if snapshot capture, PNG generation,
or file writing fails. Equirectangular, layer, animation-frame, depth, and or file writing fails. PNG equirectangular export writes a pure
video export remain on retained writer paths. document/paint-renderer equirectangular PNG before falling back to the
retained writer; JPEG/XMP equirectangular export, layer, animation-frame,
depth, and video export remain on retained writer paths.
- `pano_cli save-document-project` writes that pure document export to a PPI - `pano_cli save-document-project` writes that pure document export to a PPI
file and is covered by `pano_cli_save_document_project_roundtrip_smoke`, file and is covered by `pano_cli_save_document_project_roundtrip_smoke`,
which inspects and loads the generated file. which inspects and loads the generated file.
@@ -1124,11 +1129,13 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
exports, Web prepared-file handoff, and legacy `Canvas` export execution while exports, Web prepared-file handoff, and legacy `Canvas` export execution while
retained renderer/document/platform ownership is tracked by `DEBT-0043`. retained renderer/document/platform ownership is tracked by `DEBT-0043`.
Equirectangular, layer, animation-frame, and cube-face execution now prepare Equirectangular, layer, animation-frame, and cube-face execution now prepare
the document snapshot plus shared paint-renderer export-readiness report before those the document snapshot plus shared paint-renderer export-readiness report
retained calls; cube-face export writes pure face-PNG bytes to the app-core before retained calls; cube-face export writes pure face-PNG bytes to the
planned legacy work-directory face paths through the app-core write/publish app-core planned legacy work-directory face paths through the app-core
executor before falling back to the retained writer, and depth export remains write/publish executor before falling back to the retained writer, PNG
on the older retained path. It equirectangular export writes the pure document/paint-renderer
equirectangular PNG before retained fallback, and JPEG/XMP, collection, and
depth exports remain on older retained paths. It
also bridges timelapse and animation MP4 export picker-selected paths while also bridges timelapse and animation MP4 export picker-selected paths while
preserving desktop worker-thread timelapse behavior, mobile/Web save preserving desktop worker-thread timelapse behavior, mobile/Web save
callbacks, `App::rec_export`, animation `Canvas::export_anim_mp4`, and callbacks, `App::rec_export`, animation `Canvas::export_anim_mp4`, and

View File

@@ -24,8 +24,8 @@ and validation command.
| Capability | Current Area | Target Owner | Required Tests | | Capability | Current Area | Target Owner | Required Tests |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| PNG/JPEG import | `Image`, `Canvas` import paths | `pp_assets`, `pp_document` | Fixture import, malformed file | | PNG/JPEG import | `Image`, `Canvas` import paths | `pp_assets`, `pp_document` | Fixture import, malformed file |
| PNG/JPEG export | `Canvas`, `Image`, export dialogs | `pp_assets`, `pp_paint_renderer`, `pp_app_core` | Golden output tolerance, export start/target planning tests, live export-adapter document snapshot readiness through the shared paint-renderer export report | | PNG/JPEG export | `Canvas`, `Image`, export dialogs | `pp_assets`, `pp_paint_renderer`, `pp_app_core` | Golden output tolerance, export start/target planning tests, live export-adapter document snapshot readiness through the shared paint-renderer export report, pure cube-face PNG writer, pure equirectangular PNG writer, JPEG/XMP parity still retained |
| Equirectangular import/export | `Canvas`, shaders, RTT, export dialogs | `pp_paint_renderer`, `pp_app_core` | Tiny cube/equirect golden, app-core file target tests, live export-adapter renderer-upload/face-PNG readiness report | | Equirectangular import/export | `Canvas`, shaders, RTT, export dialogs | `pp_paint_renderer`, `pp_app_core` | Tiny cube/equirect golden, app-core file target tests, live export-adapter renderer-upload/face-PNG readiness report, pure document-frame equirectangular PNG export and live PNG writer fallback, JPEG/XMP retained until metadata parity is owned |
| Cube face export | `Canvas` fallback | `pp_paint_renderer`, `pp_app_core` | Pure six-face document frame composite, renderer texture-upload bridge, shared export-readiness report, app-core face filename planning and write/publish service execution, payload-complete canvas-snapshot renderer-upload and face-PNG automation, live document/renderer face-PNG writer with retained Canvas fallback, OpenGL command-plan coverage, six-face golden set | | Cube face export | `Canvas` fallback | `pp_paint_renderer`, `pp_app_core` | Pure six-face document frame composite, renderer texture-upload bridge, shared export-readiness report, app-core face filename planning and write/publish service execution, payload-complete canvas-snapshot renderer-upload and face-PNG automation, live document/renderer face-PNG writer with retained Canvas fallback, OpenGL command-plan coverage, six-face golden set |
| Depth export | `Canvas`, grid tools | `pp_paint_renderer` | Float/readback validation | | Depth export | `Canvas`, grid tools | `pp_paint_renderer` | Float/readback validation |

File diff suppressed because one or more lines are too long

View File

@@ -689,8 +689,11 @@ prepare the same payload-bearing document snapshot and shared renderer export
readiness report. Cube-face export writes those readiness report. Cube-face export writes those
document/renderer-owned PNG bytes through a tested app-core write/publish document/renderer-owned PNG bytes through a tested app-core write/publish
executor using the app-core-planned legacy face filenames when available and executor using the app-core-planned legacy face filenames when available and
falls back to retained `Canvas::export_cube_faces` on snapshot/write failure; falls back to retained `Canvas::export_cube_faces` on snapshot/write failure.
the other export workflows still delegate to retained `Canvas` writers after PNG equirectangular export now uses the same document/composite payload to
generate an equirectangular PNG through `pp_paint_renderer` before the retained
fallback. JPEG/XMP equirectangular export, layer collections, animation-frame
collections, depth, and video still delegate to retained `Canvas` writers after
readiness reporting. readiness reporting.
`pano_cli plan-image-import` exposes app-core planning for File > Import image `pano_cli plan-image-import` exposes app-core planning for File > Import image
route decisions, including wide equirectangular images, legacy vertical cube route decisions, including wide equirectangular images, legacy vertical cube
@@ -2531,9 +2534,12 @@ Results:
reports. Cube-face export now writes the pure document/renderer PNG bytes to reports. Cube-face export now writes the pure document/renderer PNG bytes to
the `pp_app_core` planned legacy face filenames through a tested the `pp_app_core` planned legacy face filenames through a tested
write/publish service executor before falling back to retained `Canvas` write/publish service executor before falling back to retained `Canvas`
execution on failure. Equirectangular, layer, animation-frame, depth, and execution on failure. PNG equirectangular export now writes a
video export remain on their prior retained writer paths; actual broader `pp_paint_renderer` equirectangular PNG from the same composited document
writer replacement remains tracked under export debt. frame before falling back to retained `Canvas` execution; JPEG/XMP,
layer, animation-frame, depth, and video export remain on their prior
retained writer paths. Actual broader writer replacement remains tracked
under export debt.
- Snapshot creation now rejects invalid embedded RGBA8 face payloads before - Snapshot creation now rejects invalid embedded RGBA8 face payloads before
document export or history can persist malformed state. document export or history can persist malformed state.
- Package-smoke wrappers validate the Windows CMake app executable/runtime - Package-smoke wrappers validate the Windows CMake app executable/runtime

View File

@@ -25,6 +25,19 @@ void show_export_success_dialog(
} }
} }
bool is_png_export_target(std::string_view path) noexcept
{
if (path.size() < 4U) {
return false;
}
const auto extension = path.substr(path.size() - 4U);
return extension[0] == '.'
&& (extension[1] == 'p' || extension[1] == 'P')
&& (extension[2] == 'n' || extension[2] == 'N')
&& (extension[3] == 'g' || extension[3] == 'G');
}
struct LegacyDocumentExportSnapshotReports { struct LegacyDocumentExportSnapshotReports {
pp::app::DocumentCanvasSnapshotResult snapshot; pp::app::DocumentCanvasSnapshotResult snapshot;
pp::paint_renderer::DocumentFrameFacePngExportResult face_pngs; pp::paint_renderer::DocumentFrameFacePngExportResult face_pngs;
@@ -174,6 +187,40 @@ pp::foundation::Status export_cube_faces_from_document_snapshot(
return pp::app::execute_document_cube_face_export_write(target.value(), payloads, services); return pp::app::execute_document_cube_face_export_write(target.value(), payloads, services);
} }
pp::foundation::Status export_equirectangular_png_from_document_snapshot(
App& app,
const pp::app::DocumentExportFileTarget& target,
const LegacyDocumentExportSnapshotReports& reports)
{
if (!is_png_export_target(target.path)) {
return pp::foundation::Status::invalid_argument(
"document snapshot equirectangular export currently supports PNG targets only");
}
auto exported = pp::paint_renderer::export_document_frame_equirectangular_png(reports.face_pngs.composite);
if (!exported) {
return exported.status();
}
auto exported_value = std::move(exported.value());
LOG(
"export-equirectangular document export PNG writer: %ux%u bytes=%llu facePayloads=%zu compositedLayerFaces=%zu",
exported_value.equirectangular_extent.width,
exported_value.equirectangular_extent.height,
static_cast<unsigned long long>(exported_value.encoded_bytes),
exported_value.face_payload_count,
exported_value.composited_layer_face_count);
const auto write_status = write_export_binary_file(
target.path,
std::span<const std::byte>(exported_value.png.data(), exported_value.png.size()));
if (!write_status.ok()) {
return write_status;
}
app.publish_exported_image(target.path);
return pp::foundation::Status::success();
}
class LegacyDocumentExportServices final : public pp::app::DocumentExportServices { class LegacyDocumentExportServices final : public pp::app::DocumentExportServices {
public: public:
explicit LegacyDocumentExportServices(App& app) noexcept explicit LegacyDocumentExportServices(App& app) noexcept
@@ -189,7 +236,34 @@ public:
void export_equirectangular(const pp::app::DocumentExportFileTarget& target) override void export_equirectangular(const pp::app::DocumentExportFileTarget& target) override
{ {
auto* app = &app_; auto* app = &app_;
prepare_legacy_document_export_snapshot_or_continue(app_, "export-equirectangular"); #if !__WEB__
if (is_png_export_target(target.path)) {
const auto prepared = prepare_legacy_document_export_snapshot(app_, "export-equirectangular");
if (prepared) {
const auto exported = export_equirectangular_png_from_document_snapshot(app_, target, prepared.value());
if (exported.ok()) {
show_export_success_dialog(
app_,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::equirectangular,
pp::app::document_export_equirectangular_platform_destination(),
app_.work_path));
return;
}
LOG(
"export-equirectangular document export writer retained legacy export after failure: %s",
exported.message);
} else {
LOG(
"export-equirectangular document export snapshot bridge retained legacy export after failure: %s",
prepared.status().message);
}
} else
#endif
{
prepare_legacy_document_export_snapshot_or_continue(app_, "export-equirectangular");
}
app_.canvas->m_canvas->export_equirectangular(target.path, [app, target] { app_.canvas->m_canvas->export_equirectangular(target.path, [app, target] {
#if __WEB__ #if __WEB__
app->ui_task([app, target] { app->ui_task([app, target] {

View File

@@ -4,6 +4,7 @@
#include "renderer_api/recording_renderer.h" #include "renderer_api/recording_renderer.h"
#include <algorithm> #include <algorithm>
#include <cmath>
#include <limits> #include <limits>
#include <utility> #include <utility>
@@ -115,6 +116,52 @@ namespace {
return static_cast<std::byte>(static_cast<std::uint8_t>(clamped * 255.0F + 0.5F)); return static_cast<std::byte>(static_cast<std::uint8_t>(clamped * 255.0F + 0.5F));
} }
struct CubeFaceSample {
std::size_t face_index = 0;
float s = 0.0F;
float t = 0.0F;
};
[[nodiscard]] CubeFaceSample panopainter_cube_face_sample(float x, float y, float z) noexcept
{
const auto ax = std::fabs(x);
const auto ay = std::fabs(y);
const auto az = std::fabs(z);
if (ax >= ay && ax >= az) {
if (x >= 0.0F) {
return CubeFaceSample { .face_index = 3U, .s = -z / ax, .t = -y / ax };
}
return CubeFaceSample { .face_index = 1U, .s = z / ax, .t = -y / ax };
}
if (ay >= ax && ay >= az) {
if (y >= 0.0F) {
return CubeFaceSample { .face_index = 5U, .s = x / ay, .t = z / ay };
}
return CubeFaceSample { .face_index = 4U, .s = x / ay, .t = -z / ay };
}
if (z >= 0.0F) {
return CubeFaceSample { .face_index = 2U, .s = x / az, .t = -y / az };
}
return CubeFaceSample { .face_index = 0U, .s = -x / az, .t = -y / az };
}
[[nodiscard]] pp::paint::Rgba sample_face_nearest(
const DocumentFaceCompositeResult& face,
float s,
float t) noexcept
{
const auto width = face.extent.width;
const auto height = face.extent.height;
const auto u = std::clamp((s + 1.0F) * 0.5F, 0.0F, 1.0F);
const auto v = std::clamp((t + 1.0F) * 0.5F, 0.0F, 1.0F);
const auto x = std::min(static_cast<std::uint32_t>(u * static_cast<float>(width)), width - 1U);
const auto y = std::min(static_cast<std::uint32_t>(v * static_cast<float>(height)), height - 1U);
return face.pixels[static_cast<std::size_t>(y) * width + x];
}
void append_rgba8_bytes(std::vector<std::byte>& bytes, std::span<const pp::paint::Rgba> pixels) void append_rgba8_bytes(std::vector<std::byte>& bytes, std::span<const pp::paint::Rgba> pixels)
{ {
bytes.clear(); bytes.clear();
@@ -481,6 +528,90 @@ pp::foundation::Result<DocumentFrameFacePngExportResult> export_document_frame_f
return pp::foundation::Result<DocumentFrameFacePngExportResult>::success(std::move(result)); return pp::foundation::Result<DocumentFrameFacePngExportResult>::success(std::move(result));
} }
pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>
export_document_frame_equirectangular_png(const DocumentFrameCompositeResult& composite)
{
const auto face_pixel_count = expected_pixel_count(composite.extent);
if (!face_pixel_count) {
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::failure(face_pixel_count.status());
}
for (const auto& face : composite.faces) {
if (face.extent.width != composite.extent.width || face.extent.height != composite.extent.height
|| face.pixels.size() != face_pixel_count.value()) {
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::failure(
pp::foundation::Status::invalid_argument("document equirectangular export requires complete cube faces"));
}
}
const auto output_width = static_cast<std::uint64_t>(composite.extent.width) * 4U;
const auto output_height = static_cast<std::uint64_t>(composite.extent.height) * 2U;
if (output_width > std::numeric_limits<std::uint32_t>::max()
|| output_height > std::numeric_limits<std::uint32_t>::max()) {
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::failure(
pp::foundation::Status::out_of_range("document equirectangular extent exceeds uint32"));
}
DocumentFrameEquirectangularPngExportResult result;
result.face_extent = composite.extent;
result.equirectangular_extent = pp::renderer::Extent2D {
.width = static_cast<std::uint32_t>(output_width),
.height = static_cast<std::uint32_t>(output_height),
};
result.face_payload_count = composite.face_payload_count;
result.composited_layer_face_count = composite.composited_layer_face_count;
const auto output_pixel_count = expected_pixel_count(result.equirectangular_extent);
if (!output_pixel_count) {
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::failure(output_pixel_count.status());
}
constexpr auto pi = 3.14159265358979323846F;
constexpr auto two_pi = 6.28318530717958647692F;
std::vector<pp::paint::Rgba> output(output_pixel_count.value());
for (std::uint32_t y = 0; y < result.equirectangular_extent.height; ++y) {
const auto v = (static_cast<float>(y) + 0.5F) / static_cast<float>(result.equirectangular_extent.height);
const auto angle_y = (1.0F - v) * pi;
const auto sin_y = std::sin(angle_y);
const auto cos_y = std::cos(angle_y);
for (std::uint32_t x = 0; x < result.equirectangular_extent.width; ++x) {
const auto u = (static_cast<float>(x) + 0.5F) / static_cast<float>(result.equirectangular_extent.width);
const auto angle_x = (1.25F - u) * two_pi;
const auto sample = panopainter_cube_face_sample(
sin_y * std::cos(angle_x),
cos_y,
sin_y * std::sin(angle_x));
output[static_cast<std::size_t>(y) * result.equirectangular_extent.width + x] =
sample_face_nearest(composite.faces[sample.face_index], sample.s, sample.t);
}
}
std::vector<std::uint8_t> rgba8;
append_rgba8_bytes(rgba8, output);
auto encoded = pp::assets::encode_png_rgba8(
result.equirectangular_extent.width,
result.equirectangular_extent.height,
rgba8);
if (!encoded) {
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::failure(encoded.status());
}
result.encoded_bytes = static_cast<std::uint64_t>(encoded.value().size());
result.png = std::move(encoded.value());
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::success(std::move(result));
}
pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>
export_document_frame_equirectangular_png(DocumentFrameCompositeRequest request)
{
auto composite = composite_document_frame(request);
if (!composite) {
return pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>::failure(composite.status());
}
return export_document_frame_equirectangular_png(composite.value());
}
pp::foundation::Result<DocumentFrameExportReadinessResult> prepare_document_frame_export_readiness( pp::foundation::Result<DocumentFrameExportReadinessResult> prepare_document_frame_export_readiness(
DocumentFrameCompositeRequest request) DocumentFrameCompositeRequest request)
{ {

View File

@@ -146,6 +146,15 @@ struct DocumentFrameFacePngExportResult {
std::uint64_t encoded_bytes = 0; std::uint64_t encoded_bytes = 0;
}; };
struct DocumentFrameEquirectangularPngExportResult {
pp::renderer::Extent2D face_extent {};
pp::renderer::Extent2D equirectangular_extent {};
std::vector<std::byte> png;
std::uint64_t encoded_bytes = 0;
std::size_t face_payload_count = 0;
std::size_t composited_layer_face_count = 0;
};
struct DocumentFrameExportReadinessResult { struct DocumentFrameExportReadinessResult {
RecordedDocumentFrameUploadResult recorded_upload {}; RecordedDocumentFrameUploadResult recorded_upload {};
DocumentFrameFacePngExportResult face_pngs {}; DocumentFrameFacePngExportResult face_pngs {};
@@ -172,6 +181,12 @@ struct DocumentFrameExportReadinessResult {
[[nodiscard]] pp::foundation::Result<DocumentFrameFacePngExportResult> export_document_frame_face_pngs( [[nodiscard]] pp::foundation::Result<DocumentFrameFacePngExportResult> export_document_frame_face_pngs(
DocumentFrameCompositeRequest request); DocumentFrameCompositeRequest request);
[[nodiscard]] pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>
export_document_frame_equirectangular_png(const DocumentFrameCompositeResult& composite);
[[nodiscard]] pp::foundation::Result<DocumentFrameEquirectangularPngExportResult>
export_document_frame_equirectangular_png(DocumentFrameCompositeRequest request);
[[nodiscard]] pp::foundation::Result<DocumentFrameExportReadinessResult> prepare_document_frame_export_readiness( [[nodiscard]] pp::foundation::Result<DocumentFrameExportReadinessResult> prepare_document_frame_export_readiness(
DocumentFrameCompositeRequest request); DocumentFrameCompositeRequest request);

View File

@@ -734,6 +734,120 @@ void prepares_document_frame_export_readiness_report(pp::tests::Harness& h)
} }
} }
void exports_document_frame_as_equirectangular_png(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 = 0,
.x = 0,
.y = 0,
.width = 1,
.height = 4,
.rgba8 = { 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255 },
},
LayerFacePixels {
.face_index = 1,
.x = 0,
.y = 0,
.width = 1,
.height = 4,
.rgba8 = { 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255 },
},
LayerFacePixels {
.face_index = 2,
.x = 0,
.y = 0,
.width = 1,
.height = 4,
.rgba8 = { 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255 },
},
LayerFacePixels {
.face_index = 3,
.x = 0,
.y = 0,
.width = 1,
.height = 4,
.rgba8 = { 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255 },
},
LayerFacePixels {
.face_index = 4,
.x = 0,
.y = 0,
.width = 1,
.height = 4,
.rgba8 = { 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255 },
},
LayerFacePixels {
.face_index = 5,
.x = 0,
.y = 0,
.width = 1,
.height = 4,
.rgba8 = { 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 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 = 4,
.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 exported = pp::paint_renderer::export_document_frame_equirectangular_png(
DocumentFrameCompositeRequest {
.document = &document.value(),
.frame_index = 0,
});
PP_EXPECT(h, exported);
if (!exported) {
return;
}
PP_EXPECT(h, exported.value().face_extent.width == 1U);
PP_EXPECT(h, exported.value().face_extent.height == 4U);
PP_EXPECT(h, exported.value().equirectangular_extent.width == 4U);
PP_EXPECT(h, exported.value().equirectangular_extent.height == 8U);
PP_EXPECT(h, exported.value().face_payload_count == pp::document::cube_face_count);
PP_EXPECT(h, exported.value().encoded_bytes > 0U);
const auto decoded = pp::assets::decode_png_rgba8(exported.value().png);
PP_EXPECT(h, decoded);
if (!decoded) {
return;
}
PP_EXPECT(h, decoded.value().width == 4U);
PP_EXPECT(h, decoded.value().height == 8U);
PP_EXPECT(h, decoded.value().pixels[0] == 255U);
PP_EXPECT(h, decoded.value().pixels[1] == 0U);
PP_EXPECT(h, decoded.value().pixels[2] == 255U);
const auto bottom = (static_cast<std::size_t>(decoded.value().height) - 1U)
* decoded.value().width * pp::document::rgba8_components;
PP_EXPECT(h, decoded.value().pixels[bottom] == 0U);
PP_EXPECT(h, decoded.value().pixels[bottom + 1U] == 255U);
PP_EXPECT(h, decoded.value().pixels[bottom + 2U] == 255U);
}
void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h) void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
{ {
RecordingRenderDevice device; RecordingRenderDevice device;
@@ -742,6 +856,8 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
pp::paint_renderer::DocumentFrameUploadRequest {}); pp::paint_renderer::DocumentFrameUploadRequest {});
const auto no_document_readiness = pp::paint_renderer::prepare_document_frame_export_readiness( const auto no_document_readiness = pp::paint_renderer::prepare_document_frame_export_readiness(
DocumentFrameCompositeRequest {}); DocumentFrameCompositeRequest {});
const auto no_document_equirect = pp::paint_renderer::export_document_frame_equirectangular_png(
DocumentFrameCompositeRequest {});
const AnimationFrame root_frames[] { const AnimationFrame root_frames[] {
{ .duration_ms = 100, .face_pixels = {} }, { .duration_ms = 100, .face_pixels = {} },
@@ -774,6 +890,8 @@ void document_frame_upload_rejects_invalid_requests(pp::tests::Harness& h)
PP_EXPECT(h, no_document.status().code == StatusCode::invalid_argument); PP_EXPECT(h, no_document.status().code == StatusCode::invalid_argument);
PP_EXPECT(h, !no_document_readiness.ok()); PP_EXPECT(h, !no_document_readiness.ok());
PP_EXPECT(h, no_document_readiness.status().code == StatusCode::invalid_argument); PP_EXPECT(h, no_document_readiness.status().code == StatusCode::invalid_argument);
PP_EXPECT(h, !no_document_equirect.ok());
PP_EXPECT(h, no_document_equirect.status().code == StatusCode::invalid_argument);
PP_EXPECT(h, !bad_frame.ok()); PP_EXPECT(h, !bad_frame.ok());
PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range); PP_EXPECT(h, bad_frame.status().code == StatusCode::out_of_range);
PP_EXPECT(h, !bad_frame_readiness.ok()); PP_EXPECT(h, !bad_frame_readiness.ok());
@@ -1129,6 +1247,7 @@ int main()
harness.run("records_document_frame_upload_report", records_document_frame_upload_report); 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("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("prepares_document_frame_export_readiness_report", prepares_document_frame_export_readiness_report);
harness.run("exports_document_frame_as_equirectangular_png", exports_document_frame_as_equirectangular_png);
harness.run("document_frame_upload_rejects_invalid_requests", document_frame_upload_rejects_invalid_requests); harness.run("document_frame_upload_rejects_invalid_requests", document_frame_upload_rejects_invalid_requests);
harness.run("detects_feedback_requirements", detects_feedback_requirements); harness.run("detects_feedback_requirements", detects_feedback_requirements);
harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths); harness.run("plans_stroke_composite_paths", plans_stroke_composite_paths);