mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Auto merge of #27766 - jdm:embedding-blit, r=asajeffrey
Embedding support for offscreen-rendering The current embedding API assumes it should render directly to a native widget at all times. These changes expose an option to render to an offscreen surface when starting the engine, as well as a new WebrenderSurfman API for temporarily acquiring the surface corresponding to the front buffer so it can be used for blitting purposes. Demonstrated to work in https://github.com/jdm/servo-embedding-example. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors
This commit is contained in:
commit
c7f4eba3db
3 changed files with 51 additions and 9 deletions
|
@ -162,6 +162,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<F: FnMut(&Device, Surface) -> 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<Device> {
|
||||
self.0.device.borrow()
|
||||
}
|
||||
|
||||
pub fn connection(&self) -> Connection {
|
||||
let ref device = self.0.device.borrow();
|
||||
device.connection()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue