Skip to content

Commit 7140e44

Browse files
authored
Allow reading from buffers (#320)
Disallowing reading is overly restrictive, and we don't use write-combined memory anywhere yet anyhow.
1 parent 34ce03b commit 7140e44

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

src/lib.rs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -271,33 +271,9 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> HasWindowHandle for Surface<D, W>
271271
///
272272
/// # Reading buffer data
273273
///
274-
/// Reading from buffer data may perform very poorly, as the underlying storage of zero-copy
275-
/// buffers, where implemented, may set options optimized for CPU writes, that allows them to bypass
276-
/// certain caches and avoid cache pollution.
277-
///
278-
/// As such, when rendering, you should always set the pixel in its entirety:
279-
///
280-
/// ```
281-
/// # use softbuffer::Pixel;
282-
/// # let pixel = &mut Pixel::default();
283-
/// # let (red, green, blue) = (0x11, 0x22, 0x33);
284-
/// *pixel = Pixel::new_rgb(red, green, blue);
285-
/// ```
286-
///
287-
/// Instead of e.g. something like:
288-
///
289-
/// ```
290-
/// # use softbuffer::Pixel;
291-
/// # let pixel = &mut Pixel::default();
292-
/// # let (red, green, blue) = (0x11, 0x22, 0x33);
293-
/// // DISCOURAGED!
294-
/// *pixel = Pixel::default(); // Clear
295-
/// pixel.r |= red;
296-
/// pixel.g |= green;
297-
/// pixel.b |= blue;
298-
/// ```
299-
///
300-
/// To discourage reading from the buffer, `&self -> &[u8]` methods are intentionally not provided.
274+
/// The API of this is simplified for writing to buffer data, so various `&self -> &[X]` methods are
275+
/// intentionally not provided. You can still read from the buffer data via. the `&mut self` methods
276+
/// though.
301277
///
302278
/// # Platform dependent behavior
303279
///

0 commit comments

Comments
 (0)