Add surface methods to RenderingContext (#32933)

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2024-08-05 19:21:36 +09:00 committed by GitHub
parent 45aa296b26
commit 4d49b04668
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,6 +90,22 @@ impl RenderingContext {
Ok(RenderingContext(Rc::new(data)))
}
pub fn create_surface(
&self,
surface_type: SurfaceType<NativeWidget>,
) -> Result<Surface, Error> {
let device = &mut self.0.device.borrow_mut();
let context = &self.0.context.borrow();
let surface_access = SurfaceAccess::GPUOnly;
device.create_surface(&context, surface_access, surface_type)
}
pub fn destroy_surface(&self, mut surface: Surface) -> Result<(), Error> {
let device = &self.0.device.borrow();
let context = &mut self.0.context.borrow_mut();
device.destroy_surface(context, &mut surface)
}
pub fn create_surface_texture(&self, surface: Surface) -> Result<SurfaceTexture, Error> {
let device = &self.0.device.borrow();
let context = &mut self.0.context.borrow_mut();