Skip to main content

DynamicTexturePlatform

Trait DynamicTexturePlatform 

Source
pub trait DynamicTexturePlatform: Send + Sync {
    // Required methods
    fn create_texture(
        &self,
        id: DynamicTextureId,
        size: Size<DevicePixels>,
        bytes: &[u8],
    ) -> Result<()>;
    fn update_texture(
        &self,
        id: DynamicTextureId,
        bounds: Bounds<DevicePixels>,
        bytes: &[u8],
    ) -> Result<()>;
    fn remove_texture(&self, id: DynamicTextureId);
}
Expand description

The GPU side of dynamic textures, implemented by the platform crates that can upload into an existing texture.

Every method receives tightly packed BGRA8 rows — the caller repacks strided input, so the backend never sees row padding.

Required Methods§

Source

fn create_texture( &self, id: DynamicTextureId, size: Size<DevicePixels>, bytes: &[u8], ) -> Result<()>

Allocates a texture of size for id and uploads bytes into it.

Source

fn update_texture( &self, id: DynamicTextureId, bounds: Bounds<DevicePixels>, bytes: &[u8], ) -> Result<()>

Uploads bytes for bounds — relative to the texture’s own origin — into the texture allocated for id.

May fail while the platform still holds earlier staged uploads, for example when the window has not drawn to drain them. A refused upload leaves the texture’s previous contents in place.

Source

fn remove_texture(&self, id: DynamicTextureId)

Releases the texture allocated for id.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§