Skip to main content

CustomContent

Trait CustomContent 

Source
pub trait CustomContent:
    Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn prepare(
        &self,
        backend: &dyn Any,
        size: Size<DevicePixels>,
    ) -> Result<Box<dyn Any>>;

    // Provided methods
    fn image_color_transform(&self) -> [[f32; 4]; 3] { ... }
    fn image_source_size(&self) -> Option<Size<DevicePixels>> { ... }
    fn image_sample_opacity(&self) -> f32 { ... }
    fn image_color_mode(&self) -> ImageColorMode { ... }
    fn image_linear_adjustments(&self) -> Option<LinearImagePaint> { ... }
    fn prepare_in_frame(
        &self,
        backend: &dyn Any,
        request: &PreparationRequest,
        _frame: &PreparationFrame,
    ) -> Result<Box<dyn Any>> { ... }
    fn prepare_with_request(
        &self,
        backend: &dyn Any,
        request: &PreparationRequest,
    ) -> Result<Box<dyn Any>> { ... }
}
Expand description

An immutable, replayable description of independent GPU content. Backend contexts and outputs use checked type erasure; backend crates define their concrete types. Implementations must not submit or present GPU work.

Required Methods§

Source

fn prepare( &self, backend: &dyn Any, size: Size<DevicePixels>, ) -> Result<Box<dyn Any>>

Prepare content on the host device. Return an explicit error for unsupported backends.

Provided Methods§

Source

fn image_color_transform(&self) -> [[f32; 4]; 3]

Encoded-sRGB RGB affine rows, applied after sampling/unassociation and before coverage/opacity. Alpha is preserved. Identity keeps legacy output.

Source

fn image_source_size(&self) -> Option<Size<DevicePixels>>

Actual dimensions of an immutable source-sized texture. A large virtual destination need not allocate a destination-sized preparation target. Only valid for retained source-sized outputs, without geometry coverage.

Source

fn image_sample_opacity(&self) -> f32

Sampling visibility independent of preparation. Zero permits warming a source without compositing it over a progressive fallback.

Source

fn image_color_mode(&self) -> ImageColorMode

Source color interpretation and explicit output policy.

Source

fn image_linear_adjustments(&self) -> Option<LinearImagePaint>

Linear matrix and vignette in the declared working primaries. Replaces encoded image_color_transform; does not change source identity.

Source

fn prepare_in_frame( &self, backend: &dyn Any, request: &PreparationRequest, _frame: &PreparationFrame, ) -> Result<Box<dyn Any>>

Prepare within shared scene-frame admission. Existing producers retain their request-aware behavior without a new required implementation.

Source

fn prepare_with_request( &self, backend: &dyn Any, request: &PreparationRequest, ) -> Result<Box<dyn Any>>

Prepare using logical geometry and the renderer’s exact raster extent. Existing producers receive the same physical size through prepare. Request-aware producers may override this without changing submission.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§