pub struct Surface { /* private fields */ }
Expand description
Represents a surface on the screen.
Creating a Surface
is platform-specific.
Implementations
sourceimpl Surface
impl Surface
sourcepub unsafe fn from_handle(
instance: Arc<Instance>,
handle: SurfaceKHR,
api: SurfaceApi,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Self
pub unsafe fn from_handle(
instance: Arc<Instance>,
handle: SurfaceKHR,
api: SurfaceApi,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Self
Creates a Surface
from a raw handle.
Safety
handle
must be a valid Vulkan object handle created frominstance
.handle
must have been created fromapi
.- The window object that
handle
was created from must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub fn headless(
instance: Arc<Instance>,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub fn headless(
instance: Arc<Instance>,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
with no backing window or display.
Presenting to a headless surface does nothing, so this is mostly useless in itself. However, it may be useful for testing, and it is available for future extensions to layer on top of.
sourcepub fn from_display_plane(
display_mode: &DisplayMode,
plane: &DisplayPlane
) -> Result<Arc<Self>, SurfaceCreationError>
pub fn from_display_plane(
display_mode: &DisplayMode,
plane: &DisplayPlane
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a DisplayPlane
.
Panics
- Panics if
display_mode
andplane
don’t belong to the same physical device. - Panics if
plane
doesn’t support the display ofdisplay_mode
.
sourcepub unsafe fn from_android<W>(
instance: Arc<Instance>,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_android<W>(
instance: Arc<Instance>,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from an Android window.
Safety
window
must be a valid AndroidANativeWindow
handle.- The object referred to by
window
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_directfb<D, S>(
instance: Arc<Instance>,
dfb: *const D,
surface: *const S,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_directfb<D, S>(
instance: Arc<Instance>,
dfb: *const D,
surface: *const S,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a DirectFB surface.
Safety
dfb
must be a valid DirectFBIDirectFB
handle.surface
must be a valid DirectFBIDirectFBSurface
handle.- The object referred to by
dfb
andsurface
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_fuchsia_image_pipe(
instance: Arc<Instance>,
image_pipe_handle: zx_handle_t,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_fuchsia_image_pipe(
instance: Arc<Instance>,
image_pipe_handle: zx_handle_t,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from an Fuchsia ImagePipe.
Safety
image_pipe_handle
must be a valid Fuchsiazx_handle_t
handle.- The object referred to by
image_pipe_handle
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_ggp_stream_descriptor(
instance: Arc<Instance>,
stream_descriptor: GgpStreamDescriptor,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_ggp_stream_descriptor(
instance: Arc<Instance>,
stream_descriptor: GgpStreamDescriptor,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a Google Games Platform stream descriptor.
Safety
stream_descriptor
must be a valid Google Games PlatformGgpStreamDescriptor
handle.- The object referred to by
stream_descriptor
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_metal<L>(
instance: Arc<Instance>,
layer: *const L,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_metal<L>(
instance: Arc<Instance>,
layer: *const L,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a Metal CAMetalLayer
.
Safety
layer
must be a valid MetalCAMetalLayer
handle.- The object referred to by
layer
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_qnx_screen<C, W>(
instance: Arc<Instance>,
context: *const C,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_qnx_screen<C, W>(
instance: Arc<Instance>,
context: *const C,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a QNX Screen window.
Safety
context
must be a valid QNX Screen_screen_context
handle.window
must be a valid QNX Screen_screen_window
handle.- The object referred to by
window
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_vi<W>(
instance: Arc<Instance>,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_vi<W>(
instance: Arc<Instance>,
window: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a code:nn::code:vi::code:Layer
.
Safety
window
must be a validnn::vi::NativeWindowHandle
handle.- The object referred to by
window
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_wayland<D, S>(
instance: Arc<Instance>,
display: *const D,
surface: *const S,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_wayland<D, S>(
instance: Arc<Instance>,
display: *const D,
surface: *const S,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a Wayland window.
The window’s dimensions will be set to the size of the swapchain.
Safety
display
must be a valid Waylandwl_display
handle.surface
must be a valid Waylandwl_surface
handle.- The objects referred to by
display
andsurface
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_win32<I, W>(
instance: Arc<Instance>,
hinstance: *const I,
hwnd: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_win32<I, W>(
instance: Arc<Instance>,
hinstance: *const I,
hwnd: *const W,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from a Win32 window.
The surface’s min, max and current extent will always match the window’s dimensions.
Safety
hinstance
must be a valid Win32HINSTANCE
handle.hwnd
must be a valid Win32HWND
handle.- The objects referred to by
hwnd
andhinstance
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_xcb<C>(
instance: Arc<Instance>,
connection: *const C,
window: xcb_window_t,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_xcb<C>(
instance: Arc<Instance>,
connection: *const C,
window: xcb_window_t,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from an XCB window.
The surface’s min, max and current extent will always match the window’s dimensions.
Safety
connection
must be a valid X11xcb_connection_t
handle.window
must be a valid X11xcb_window_t
handle.- The objects referred to by
connection
andwindow
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub unsafe fn from_xlib<D>(
instance: Arc<Instance>,
display: *const D,
window: Window,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
pub unsafe fn from_xlib<D>(
instance: Arc<Instance>,
display: *const D,
window: Window,
object: Option<Arc<dyn Any + Send + Sync>>
) -> Result<Arc<Self>, SurfaceCreationError>
Creates a Surface
from an Xlib window.
The surface’s min, max and current extent will always match the window’s dimensions.
Safety
display
must be a valid XlibDisplay
handle.window
must be a valid XlibWindow
handle.- The objects referred to by
display
andwindow
must outlive the createdSurface
. Theobject
parameter can be used to ensure this.
sourcepub fn api(&self) -> SurfaceApi
pub fn api(&self) -> SurfaceApi
Returns the windowing API that was used to construct the surface.