feat(libcairo): write image surfaces to PNG streams #18382
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18382"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by bipinkrish on 2026-11-11T13:03:43Z.
What
Implement
cairo_surface_write_to_png_stream(A3FLVZ4FHbY) for Cairo image surfaces and subsurfaces. The writer handles the eight image formats, restores straight alpha, preserves 16-bit output for floating-point images, and stops at the first error returned by the guest System V callback. Subsurfaces use the pixel rectangle computed at creation and retain the underlying image.Extend the shared PNG encoder with optional 16-bit samples and a white background chunk. Cairo uses these options to match native image metadata. The encoder buffers the stream before calling the writer, so compression and callback chunk sizes can differ from native Cairo. PS5 behavior remains unmeasured.
Tested
Ubuntu 24.04.4 x86-64, Release. All 12 Cairo and PNG CTests passed with
ctest --test-dir build -R '^(guest_cairo_.*|decoder_png|guest_png_(enc|dec))$' --output-on-failure.Compared 587 synthetic cases against Cairo 1.18.0. PNG dimensions, color types, bit depths, white background payloads and every reconstructed sample matched for the eight image formats. Coverage included padded and negative strides, scaled and clipped subsurfaces, and nested crops. CRCs validated, callback failures propagated at the requested call with the same status, and the surface status stayed successful.
Applied the production NID patcher to the built library and repeated the 587 cases through the resolved
A3FLVZ4FHbYexport.Public header audit passed. Conventions passed against upstream
main. The tested branch was based on2ecc68bda26and merged cleanly in a merge-tree check against1e8dfd69d55and the sibling Cairo geometry branch.Ran
tools/pr_overlap.pyagainst 1,982 open PR heads. Manually reviewed #14212, #15208, #16895 and #16954. The shared lines are the Cairo debt summary, neighboring debt rows and the adjacent pattern declaration. Those PRs leave this PNG writer stub in place.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T16:07:15Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
65fa4e73c9:tools/check_conventions.pypassed;git diff --checkclean.guest_cairo_png_testsbuilt cleanly.guest_cairo_png):core/Decoder/Png/include/Decoder/Png.hpp,core/Decoder/Png/src/Png.cpp,core/libs/prx/libcairo/Export.cpp,core/libs/prx/libcairo/Surface.cpp,core/libs/prx/libcairo/include/InventoryExports.hpp,core/libs/prx/libcairo/include/Surface.hppreverted tomain, the new tests do not build/link without the change; restoring it makes them build and pass.Looks Good To Me