pub struct Surface { /* private fields */ }
Expand description
The surface used to draw to.
The surface represents a rectangle on screen that can be drawn to. It’s created from a
Display
and a window, and can be used to draw to the window.
Example
use theo::{Display, RenderContext};
// Create a new display.
let mut display = unsafe { Display::new(&my_display) }.unwrap();
// Use the display to create a new window.
let mut window_builder = WindowBuilder::new()
.with_transparency(display.supports_transparency());
if cfg!(using_x11) {
if let Some(visual) = display.x11_visual() {
unsafe {
window_builder = window_builder.with_x11_visual(visual.as_ptr());
}
}
}
// Create the window.
let window = window_builder.build();
// Use the window to create a new theo surface.
let mut surface = unsafe {
display.make_surface(
&window,
window.width(),
window.height(),
).await.unwrap()
};
// Use the surface to create a new render context.
let mut context = RenderContext::new(
&mut display,
&mut surface,
window.width(),
window.height(),
).unwrap();
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Surface
impl !Send for Surface
impl !Sync for Surface
impl Unpin for Surface
impl !UnwindSafe for Surface
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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.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, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.