diff --git a/components/webrender_surfman/lib.rs b/components/webrender_surfman/lib.rs index 533614256c1..472aabbad18 100644 --- a/components/webrender_surfman/lib.rs +++ b/components/webrender_surfman/lib.rs @@ -159,6 +159,23 @@ impl WebrenderSurfman { }) } + /// Invoke a closure with the surface associated with the current front buffer. + /// This can be used to create a surfman::SurfaceTexture to blit elsewhere. + pub fn with_front_buffer Surface>(&self, mut f: F) { + let ref mut device = self.0.device.borrow_mut(); + let ref mut context = self.0.context.borrow_mut(); + let surface = device + .unbind_surface_from_context(context) + .unwrap() + .unwrap(); + let surface = f(device, surface); + device.bind_surface_to_context(context, surface).unwrap(); + } + + pub fn device(&self) -> std::cell::Ref { + self.0.device.borrow() + } + pub fn connection(&self) -> Connection { let ref device = self.0.device.borrow(); device.connection()