Skip to content

Conversation

@madsmtm
Copy link
Member

@madsmtm madsmtm commented Jan 23, 2026

In #313, I added a note that reading from the pixel buffer is discouraged, because I wanted to set kIOSurfaceMapWriteCombineCache on macOS once I got around to implementing proper IOSurface support. See e.g. the following links for a few places where it's used in the wild:

I thought this was fine, because I couldn't see a use-case where you'd need to read from the pixel buffer, but that was perhaps a bit hasty, I found at least one use-case: converting the alpha mode (premultiplying components or making the alpha channel opaque) by modifying the buffer in-place in a separate step before presenting it buffer.

This means that the argument for only having the mutable version instead of distinct pixels/pixels_mut, pixel_rows/pixel_rows_mut and pixels_iter/pixels_iter_mut methods is a bit weaker.

WDYT? Should we provide both immutable and mutable methods on Buffer<'_>?

To allow reading from the buffer by default.
@madsmtm madsmtm added documentation Improvements or additions to documentation enhancement New feature or request DS - CoreGraphics macOS/iOS/tvOS/watchOS/visionOS backend labels Jan 23, 2026
@madsmtm madsmtm changed the title Add API for making buffers write-only and allow reading from them by default Add API for making buffers write-only, and allow reading from them by default Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation DS - CoreGraphics macOS/iOS/tvOS/watchOS/visionOS backend enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

2 participants