Remove Deref and DerefMut impls on Buffer
#313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
&mut [u32]as a buffer format is kinda weird and has confusing interactions with endianess, see #109. I'd like to move towards exposing buffer data in different formats instead:Buffer::data(&mut self) -> &mut [u8], useful when working with different pixel formats, see Pixel format API design #98.Buffer::data(&mut self) -> &mut [Pixel]see AddPixelstruct andDEFAULT_PIXEL_FORMATconstant #289.Removing the
Deref/DerefMutas done in this PR should make it easier to reduce our "dependency" onu32as the pixel type in the future. Users would instead explicitly use the newBuffer::pixelsor the accessors added in #312 (which this PR builds upon).Finally, the current
Deref[Mut]impls are not zero-cost on all backends (and is kinda hard to make it so on Linux because ofBufferDispatch), making them be a potential invisible performance cliff.(The
BorrowStackhack could maybe be used to fix some of this, as was done on Wayland, but it requires the stored state to be&mut Tinstead ofT, and it adds 2*pointer size toBuffer<'_>which is kinda annoying. I've removed it in this PR because I believe it will no longer be necessary).