Plan depth export through document renderer
This commit is contained in:
@@ -683,6 +683,57 @@ export_document_frame_equirectangular_png(DocumentFrameCompositeRequest request)
|
||||
return export_document_frame_equirectangular_png(composite.value());
|
||||
}
|
||||
|
||||
pp::foundation::Result<DocumentDepthExportRenderPlan> plan_document_depth_export_render(
|
||||
DocumentDepthExportRenderPlanRequest request) noexcept
|
||||
{
|
||||
if (request.document == nullptr) {
|
||||
return pp::foundation::Result<DocumentDepthExportRenderPlan>::failure(
|
||||
pp::foundation::Status::invalid_argument("document depth export request requires a document"));
|
||||
}
|
||||
|
||||
if (request.frame_index >= request.document->frames().size()) {
|
||||
return pp::foundation::Result<DocumentDepthExportRenderPlan>::failure(
|
||||
pp::foundation::Status::out_of_range("document depth export frame index is outside the document"));
|
||||
}
|
||||
|
||||
const auto output_pixels = expected_pixel_count(request.output_extent);
|
||||
if (!output_pixels) {
|
||||
return pp::foundation::Result<DocumentDepthExportRenderPlan>::failure(output_pixels.status());
|
||||
}
|
||||
|
||||
DocumentDepthExportRenderPlan plan;
|
||||
plan.output_extent = request.output_extent;
|
||||
plan.merged_face_draw_count = pp::document::cube_face_count;
|
||||
plan.visited_layer_count = request.document->layers().size();
|
||||
|
||||
for (const auto& layer : request.document->layers()) {
|
||||
if (!layer.visible || layer.opacity == 0.0F || request.frame_index >= layer.frames.size()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
++plan.visible_layer_count;
|
||||
std::array<bool, pp::document::cube_face_count> layer_faces {};
|
||||
const auto& frame = layer.frames[request.frame_index];
|
||||
for (const auto& payload : frame.face_pixels) {
|
||||
if (payload.face_index >= pp::document::cube_face_count) {
|
||||
return pp::foundation::Result<DocumentDepthExportRenderPlan>::failure(
|
||||
pp::foundation::Status::out_of_range("document depth export face index is outside the cube"));
|
||||
}
|
||||
|
||||
layer_faces[payload.face_index] = true;
|
||||
++plan.face_payload_count;
|
||||
}
|
||||
|
||||
for (const auto has_payload : layer_faces) {
|
||||
if (has_payload) {
|
||||
++plan.layer_depth_draw_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pp::foundation::Result<DocumentDepthExportRenderPlan>::success(plan);
|
||||
}
|
||||
|
||||
pp::foundation::Result<DocumentLayerEquirectangularPngExportResult>
|
||||
export_document_layers_equirectangular_pngs(DocumentLayerEquirectangularPngExportRequest request)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user