pub struct GlCompositor { /* private fields */ }Expand description
GPU-style compositor that manages surfaces and composites them to a back buffer.
Implementations§
Source§impl GlCompositor
impl GlCompositor
Sourcepub fn new(viewport_width: u32, viewport_height: u32) -> Self
pub fn new(viewport_width: u32, viewport_height: u32) -> Self
Create a new compositor with the given viewport dimensions.
Sourcepub fn set_clear_color(&mut self, color: u32)
pub fn set_clear_color(&mut self, color: u32)
Set the background clear colour.
Sourcepub fn surface_count(&self) -> usize
pub fn surface_count(&self) -> usize
Number of registered surfaces.
Sourcepub fn create_surface(&mut self, width: u32, height: u32) -> Option<SurfaceId>
pub fn create_surface(&mut self, width: u32, height: u32) -> Option<SurfaceId>
Create a new surface with the given dimensions.
Returns the surface ID, or None if the atlas is full.
Sourcepub fn destroy_surface(&mut self, id: SurfaceId) -> bool
pub fn destroy_surface(&mut self, id: SurfaceId) -> bool
Destroy a surface and free its atlas region.
Sourcepub fn update_surface(&mut self, id: SurfaceId, pixels: &[u32]) -> bool
pub fn update_surface(&mut self, id: SurfaceId, pixels: &[u32]) -> bool
Update a surface’s pixel data.
pixels must be exactly width * height ARGB8888 values.
Sourcepub fn set_surface_position(&mut self, id: SurfaceId, x: i32, y: i32)
pub fn set_surface_position(&mut self, id: SurfaceId, x: i32, y: i32)
Set a surface’s position.
Sourcepub fn set_surface_z_order(&mut self, id: SurfaceId, z: i32)
pub fn set_surface_z_order(&mut self, id: SurfaceId, z: i32)
Set a surface’s z-order.
Sourcepub fn set_surface_visible(&mut self, id: SurfaceId, visible: bool)
pub fn set_surface_visible(&mut self, id: SurfaceId, visible: bool)
Set a surface’s visibility.
Sourcepub fn set_surface_opacity(&mut self, id: SurfaceId, opacity: u8)
pub fn set_surface_opacity(&mut self, id: SurfaceId, opacity: u8)
Set a surface’s opacity.
Sourcepub fn composite(&mut self)
pub fn composite(&mut self)
Composite all visible surfaces to the back buffer.
Surfaces are drawn in z-order (lowest first). The back buffer is cleared before compositing.
Sourcepub fn get_surface(&self, id: SurfaceId) -> Option<&GlSurface>
pub fn get_surface(&self, id: SurfaceId) -> Option<&GlSurface>
Get a surface by ID.
Sourcepub fn get_surface_mut(&mut self, id: SurfaceId) -> Option<&mut GlSurface>
pub fn get_surface_mut(&mut self, id: SurfaceId) -> Option<&mut GlSurface>
Get a mutable reference to a surface by ID.