EffectImage
struct · ferroui-base · v0.5.0
struct EffectImage
A handle of an image that a shader effect samples: the value of an image
parameter of a custom effect
(EffectParameterValue::Image).
It is cheap to clone (an Arc), Send and Sync, and compares by
identity: two handles are equal when they are clones of one handle (or
both empty), whatever the pixels. The default is the empty handle, an
image of no pixels, which a program samples as transparent.
The handle holds a counted reference to the framework's bitmap (the
platform bitmap of a Bitmap, a
RenderTargetBitmap capture of a page), so the bitmap lives while a
handle does. The bitmap is treated as immutable: a backend uploads it once
and draws the upload until the handle is released (a bitmap whose
version changes is uploaded
again).
let page = Bitmap::from_stream(&mut stream)?;
let effect = MaskTransitionEffect { to_page: EffectImage::new(&page), progress: 0.5, ..Default::default() };
visual.set_effect(Some(ImmutableCustomEffect::new(effect).into()));
Members
empty
const fn empty() -> Self
The empty handle: no image; sampled as transparent.
new
fn new(bitmap: &dyn IBitmap) -> Self
A handle of bitmap: another counted reference to its platform
bitmap, so the bitmap lives while the handle does.
Panics
Panics when the bitmap has been disposed.
is_empty
fn is_empty(self: &Self) -> bool
Whether the handle is the empty one.
id
fn id(self: &Self) -> u64
The identity of the handle: the same for its clones, never given to another image; 0 for the empty handle. What the backends key their uploads by.
pixel_size
fn pixel_size(self: &Self) -> PixelSize
The size of the image in device pixels (zero for the empty handle).
version
fn version(self: &Self) -> i32
The version of the pixels of the bitmap
(IBitmapImpl::version); 0 for the empty handle.
downgrade
fn downgrade(self: &Self) -> EffectImageWeak
A weak handle, which does not keep the image: what a backend keeps with what it made of the image, to know when to release it.
pixels
fn pixels(self: &Self) -> Option<EffectImagePixels>
The pixels of the image as premultiplied RGBA, read once per version
of the bitmap: what the CPU references sample and a backend that
uploads pixels uploads. None for the empty handle and for a bitmap
whose pixels cannot be read on the processor (a texture of a device).
release_generation
fn release_generation() -> u64
How many image handles were released so far (the last clone of each dropped). A backend that keeps uploads by identity looks for the dead weak handles of its entries when this changes, on the thread that owns the uploads.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceKeyObjectPropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedErasedDestructorIntoEitherFrom<EffectImage>From<&EffectImage>CloneDefaultPartialEqEqHashDebug
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.