1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use super::{AlphaFormat, PixelFormat};
use crate::{PixelSize, Vector};
/// A locked framebuffer: a block of pixel memory that can be read and
/// written until it is disposed, at which point its content is presented or
/// committed.
pub trait ILockedFramebuffer {
/// The address of the first pixel.
///
/// The memory is `row_bytes() * size().height` bytes long and stays valid
/// until [`dispose`](Self::dispose) is called.
fn address(&self) -> *mut u8;
/// Gives `access` the pixel memory as a slice of
/// `row_bytes() * size().height` bytes.
///
/// This is the safe counterpart of [`address`](Self::address). The
/// framebuffer must not be accessed again from within `access`.
fn with_data(&self, access: &mut dyn FnMut(&mut [u8]));
/// The framebuffer size in device pixels.
fn size(&self) -> PixelSize;
/// The number of bytes per row.
fn row_bytes(&self) -> i32;
/// The DPI of the underlying screen.
fn dpi(&self) -> Vector;
/// The pixel format.
fn format(&self) -> PixelFormat;
/// The alpha format.
fn alpha_format(&self) -> AlphaFormat;
/// Unlocks the framebuffer.
fn dispose(&self);
}