Struct gbm_rs::Surface
[−]
[src]
pub struct Surface { /* fields omitted */ }
Analogous to gbm_surface
Represents an area where a buffer object will be displayed.
Methods
impl Surface
[src]
fn new(
dev: &Device,
width: u32,
height: u32,
format: u32,
flags: u32
) -> Option<Surface>
dev: &Device,
width: u32,
height: u32,
format: u32,
flags: u32
) -> Option<Surface>
Allocate a Surface object
Arguments
dev: The Device returned from Device::from_fd()
width: The width for the surface
height: The height for the surface
format: The fourcc code for the surface
flags: A bitmask of the flags for this surface
Returns
A newly allocated surface.
If an error occurs during allocation None
will be returned.
Example
let surface = gbm::Surface::new(&device, 1920, 1080, gbm::format::XRGB8888, // GBM_FORMAT_XRGB8888 gbm::USE_SCANOUT | gbm::USE_RENDERING).unwrap();
fn has_free_buffers(&self) -> bool
Returns whether or not a surface has free (non-locked) buffers
Before starting a new frame, the surface must have a buffer available for rendering. Initially, a gbm surface will have a free buffer, but after one of more buffers have been locked, the application must check for a free buffer before rendering.
If a surface doesn't have a free buffer, the application must
return a buffer to the surface using release_buffer()
and after that, the application can query for free buffers again.
Returns
true
if the surface has free buffers, false
otherwise
fn lock_front_buffer(&self) -> Option<BufferObject>
Lock rendering to the surface's current front buffer until it is
released with release_ buffer()
This function must be called exactly once after calling eglSwapBuffers. Calling it before any eglSwapBuffer has happend on the surface or two or more times after eglSwapBuffers is an error. A new BufferObject representing the new front buffer is returned. On multiple invocations, all the returned BufferObjects must be released in order to release the actual surface buffer.
Returns
A buffer object that should be released with release_buffer()
when no longer needed.
If an error occurs this function returns None
.
Example
// Render something let buffer = surface.lock_front_buffer().unwrap(); // Output to the screen, etc. surface.release_buffer(buffer);
fn release_buffer(&self, bo: BufferObject)
Release a locked buffer obtained lock_front_buffer()
Returns the underlying buffer to the Surface. Releasing a BufferObject
will typically has_free_buffer()
return true and thus
allow rendering the next frame, but not always. The implementation
may choose to destroy the BufferObject immediately or reuse it, in which case
the user data associated with it is unchanged.
Arguments
bo: The BufferObject to be released
fn c_struct(&self) -> *const gbm_surface
Returns the gbm_surface for the Surface
Returns
A pointer to the gbm_surface used to create the Surface.