From bd2d4596b0eacee380f6b71353c340aae49d0fd5 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Sun, 15 Nov 2020 11:14:43 -0500 Subject: [PATCH] Allow embedders to access front buffer surface. --- components/webrender_surfman/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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()