pub struct SwapChain<Device: DeviceAPI>(Arc<Mutex<SwapChainData<Device>>>);
Expand description
A thread-safe swap chain.
Tuple Fields§
§0: Arc<Mutex<SwapChainData<Device>>>
Implementations§
source§impl<Device: DeviceAPI> SwapChain<Device>
impl<Device: DeviceAPI> SwapChain<Device>
fn lock(&self) -> MutexGuard<'_, SwapChainData<Device>>
sourcepub fn swap_buffers(
&self,
device: &mut Device,
context: &mut Device::Context,
preserve_buffer: PreserveBuffer<'_>,
) -> Result<(), Error>
pub fn swap_buffers( &self, device: &mut Device, context: &mut Device::Context, preserve_buffer: PreserveBuffer<'_>, ) -> Result<(), Error>
Swap the back and front buffers.
Called by the producer.
Returns an error if context
is not the producer context for this swap chain.
sourcepub fn take_attachment_from(
&self,
device: &mut Device,
context: &mut Device::Context,
other: &SwapChain<Device>,
) -> Result<(), Error>
pub fn take_attachment_from( &self, device: &mut Device, context: &mut Device::Context, other: &SwapChain<Device>, ) -> Result<(), Error>
Swap the attached swap chain.
Called by the producer.
Returns an error if context
is not the producer context for both swap chains.
Returns an error if this swap chain is attached, or the other swap chain is detached.
sourcepub fn resize(
&self,
device: &mut Device,
context: &mut Device::Context,
size: Size2D<i32>,
) -> Result<(), Error>
pub fn resize( &self, device: &mut Device, context: &mut Device::Context, size: Size2D<i32>, ) -> Result<(), Error>
Resize the swap chain.
This creates a new back buffer of the appropriate size,
and destroys the old one.
Called by the producer.
Returns an error if context
is not the producer context for this swap chain.
sourcepub fn take_surface_texture(
&self,
device: &Device,
context: &mut Device::Context,
) -> Result<Device::SurfaceTexture, Error>
pub fn take_surface_texture( &self, device: &Device, context: &mut Device::Context, ) -> Result<Device::SurfaceTexture, Error>
Take the current back buffer. Called by a producer.
sourcepub fn recycle_surface_texture(
&self,
device: &Device,
context: &mut Device::Context,
surface_texture: Device::SurfaceTexture,
) -> Result<(), Error>
pub fn recycle_surface_texture( &self, device: &Device, context: &mut Device::Context, surface_texture: Device::SurfaceTexture, ) -> Result<(), Error>
Recycle the current back buffer. Called by a producer.
sourcepub fn take_pending_surface(&self) -> Option<Device::Surface>
pub fn take_pending_surface(&self) -> Option<Device::Surface>
Take the current front buffer.
Returns None
if there is no current front buffer.
Called by a consumer.
sourcepub fn clear_surface(
&self,
device: &mut Device,
context: &mut Device::Context,
gl: &Gl,
color: [f32; 4],
) -> Result<(), Error>
pub fn clear_surface( &self, device: &mut Device, context: &mut Device::Context, gl: &Gl, color: [f32; 4], ) -> Result<(), Error>
Clear the current back buffer.
Called by the producer.
Returns an error if context
is not the producer context for this swap chain.
sourcepub fn is_attached(&self) -> bool
pub fn is_attached(&self) -> bool
Is this the attached swap chain?
sourcepub fn destroy(
&self,
device: &mut Device,
context: &mut Device::Context,
) -> Result<(), Error>
pub fn destroy( &self, device: &mut Device, context: &mut Device::Context, ) -> Result<(), Error>
Destroy the swap chain.
Called by the producer.
Returns an error if context
is not the producer context for this swap chain.
sourcepub fn create_attached(
device: &mut Device,
context: &mut Device::Context,
surface_access: SurfaceAccess,
) -> Result<SwapChain<Device>, Error>
pub fn create_attached( device: &mut Device, context: &mut Device::Context, surface_access: SurfaceAccess, ) -> Result<SwapChain<Device>, Error>
Create a new attached swap chain
sourcepub fn create_detached(
device: &mut Device,
context: &mut Device::Context,
surface_access: SurfaceAccess,
size: Size2D<i32>,
) -> Result<SwapChain<Device>, Error>
pub fn create_detached( device: &mut Device, context: &mut Device::Context, surface_access: SurfaceAccess, size: Size2D<i32>, ) -> Result<SwapChain<Device>, Error>
Create a new detached swap chain
Trait Implementations§
source§impl<Device> SwapChainAPI for SwapChain<Device>
impl<Device> SwapChainAPI for SwapChain<Device>
source§fn take_surface(&self) -> Option<Device::Surface>
fn take_surface(&self) -> Option<Device::Surface>
Take the current front buffer. Returns the most recent recycled surface if there is no current front buffer. Called by a consumer.
source§fn recycle_surface(&self, surface: Device::Surface)
fn recycle_surface(&self, surface: Device::Surface)
Recycle the current front buffer. Called by a consumer.