pub struct WindowRenderingContext {
size: Cell<PhysicalSize<u32>>,
surfman_context: SurfmanRenderingContext,
}
Expand description
A RenderingContext
that uses the surfman
library to render to a
raw-window-handle
identified window. surfman
will attempt to create an
OpenGL context and surface for this window. This is a simple implementation
of the RenderingContext
crate, but by default it paints to the entire window
surface.
If you would like to paint to only a portion of the window, consider using
OffscreenRenderingContext
by calling WindowRenderingContext::offscreen_context
.
Fields§
§size: Cell<PhysicalSize<u32>>
§surfman_context: SurfmanRenderingContext
Implementations§
Source§impl WindowRenderingContext
impl WindowRenderingContext
pub fn new( display_handle: DisplayHandle<'_>, window_handle: WindowHandle<'_>, size: PhysicalSize<u32>, ) -> Result<WindowRenderingContext, Error>
pub fn offscreen_context( self: &Rc<WindowRenderingContext>, size: PhysicalSize<u32>, ) -> OffscreenRenderingContext
Sourcepub fn take_window(&self) -> Result<(), Error>
pub fn take_window(&self) -> Result<(), Error>
Stop rendering to the window that was used to create this WindowRenderingContext
or last set with Self::set_window
.
TODO: This should be removed once WebView
s can replace their RenderingContext
s.
Sourcepub fn set_window(
&self,
window_handle: WindowHandle<'_>,
size: PhysicalSize<u32>,
) -> Result<(), Error>
pub fn set_window( &self, window_handle: WindowHandle<'_>, size: PhysicalSize<u32>, ) -> Result<(), Error>
Replace the window that this WindowRenderingContext
renders to and give it a new
size.
TODO: This should be removed once WebView
s can replace their RenderingContext
s.
pub fn surfman_details( &self, ) -> (RefMut<'_, Device<Device<Device, Device>, Device>>, RefMut<'_, Context<Device<Device, Device>, Device>>)
Trait Implementations§
Source§impl RenderingContext for WindowRenderingContext
impl RenderingContext for WindowRenderingContext
Source§fn prepare_for_rendering(&self)
fn prepare_for_rendering(&self)
RenderingContext
to be rendered upon by Servo. For instance,
by binding a framebuffer to the current OpenGL context.Source§fn read_to_image(
&self,
source_rectangle: Box2D<i32, DevicePixel>,
) -> Option<ImageBuffer<Rgba<u8>, Vec<u8>>>
fn read_to_image( &self, source_rectangle: Box2D<i32, DevicePixel>, ) -> Option<ImageBuffer<Rgba<u8>, Vec<u8>>>
Renderingcontext
] into an in-memory image. If the
image cannot be read (for instance, if no rendering has taken place yet), then
None
is returned. Read moreSource§fn size(&self) -> PhysicalSize<u32>
fn size(&self) -> PhysicalSize<u32>
RenderingContext
.Source§fn resize(&self, size: PhysicalSize<u32>)
fn resize(&self, size: PhysicalSize<u32>)
Source§fn present(&self)
fn present(&self)
Source§fn make_current(&self) -> Result<(), Error>
fn make_current(&self) -> Result<(), Error>
Source§fn gleam_gl_api(&self) -> Rc<dyn Gl>
fn gleam_gl_api(&self) -> Rc<dyn Gl>
gleam
version of the OpenGL or GLES API.Source§fn glow_gl_api(&self) -> Arc<Context>
fn glow_gl_api(&self) -> Arc<Context>
Source§fn create_texture(
&self,
surface: Surface<Device<Device, Device>, Device>,
) -> Option<(SurfaceTexture<Device<Device, Device>, Device>, u32, Size2D<i32, UnknownUnit>)>
fn create_texture( &self, surface: Surface<Device<Device, Device>, Device>, ) -> Option<(SurfaceTexture<Device<Device, Device>, Device>, u32, Size2D<i32, UnknownUnit>)>
None
.Source§fn destroy_texture(
&self,
surface_texture: SurfaceTexture<Device<Device, Device>, Device>,
) -> Option<Surface<Device<Device, Device>, Device>>
fn destroy_texture( &self, surface_texture: SurfaceTexture<Device<Device, Device>, Device>, ) -> Option<Surface<Device<Device, Device>, Device>>
None
.Source§fn connection(&self) -> Option<Connection<Device<Device, Device>, Device>>
fn connection(&self) -> Option<Connection<Device<Device, Device>, Device>>
None
.Source§fn size2d(&self) -> Size2D<u32, DevicePixel>
fn size2d(&self) -> Size2D<u32, DevicePixel>
RenderingContext
as Size2D
.Auto Trait Implementations§
impl !Freeze for WindowRenderingContext
impl !RefUnwindSafe for WindowRenderingContext
impl !Send for WindowRenderingContext
impl !Sync for WindowRenderingContext
impl Unpin for WindowRenderingContext
impl !UnwindSafe for WindowRenderingContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more