pub trait PixelOps {
type Guard: PixelGuard;
// Required methods
fn guard(&self) -> Self::Guard;
unsafe fn fill(&self, dst: *mut u32, color: u32, count: usize);
unsafe fn blit(&self, dst: *mut u32, src: *const u32, count: usize);
unsafe fn blend(
&self,
dst: *mut u32,
src: *const u32,
alpha: u8,
count: usize,
);
unsafe fn fill_nt(&self, dst: *mut u32, color: u32, count: usize);
unsafe fn blit_nt(&self, dst: *mut u32, src: *const u32, count: usize);
}Expand description
Raw 32-bit pixel operations.
§Safety contract
Implementations may assume, for every method, that:
dstpoints tocountwritableu32values;srcpoints tocountreadableu32values;- the two ranges do not overlap.
The methods stay unsafe fn even though the trait is safe: constructing
a bad implementation is harmless as long as every call site upholds the
contract, and Canvas is the only caller.
Required Associated Types§
Sourcetype Guard: PixelGuard
type Guard: PixelGuard
RAII state saved around a drawing call (FPU/SSE registers in the kernel, nothing on the host).
Required Methods§
Sourcefn guard(&self) -> Self::Guard
fn guard(&self) -> Self::Guard
Acquire the guard. Kept separate from the operations so the compiler can drop it at the end of the drawing call.
Sourceunsafe fn blend(&self, dst: *mut u32, src: *const u32, alpha: u8, count: usize)
unsafe fn blend(&self, dst: *mut u32, src: *const u32, alpha: u8, count: usize)
Blend src over dst with a constant alpha (0 = keep dst,
255 = take src), channel by channel including the top byte.
§Safety
See the trait-level contract.
Sourceunsafe fn fill_nt(&self, dst: *mut u32, color: u32, count: usize)
unsafe fn fill_nt(&self, dst: *mut u32, color: u32, count: usize)
Non-temporal variant of Self::fill, for write-combining memory.
§Safety
See the trait-level contract, plus: dst must be write-combining
memory, and the caller must issue a fence before the result is read.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".