mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Make headless window set current GL context before compositing.
This commit is contained in:
parent
39d13d1fc8
commit
72413bd371
1 changed files with 23 additions and 18 deletions
|
@ -17,6 +17,8 @@ use servo::webrender_api::units::{DeviceIntRect, DeviceIntSize};
|
||||||
use servo_media::player::context as MediaPlayerCtxt;
|
use servo_media::player::context as MediaPlayerCtxt;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
|
use std::cell::RefCell;
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -28,8 +30,8 @@ use std::rc::Rc;
|
||||||
struct HeadlessContext {
|
struct HeadlessContext {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
_context: osmesa_sys::OSMesaContext,
|
context: osmesa_sys::OSMesaContext,
|
||||||
_buffer: Vec<u32>,
|
buffer: RefCell<Vec<u32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||||
|
@ -57,24 +59,11 @@ impl HeadlessContext {
|
||||||
|
|
||||||
assert!(!context.is_null());
|
assert!(!context.is_null());
|
||||||
|
|
||||||
let mut buffer = vec![0; (width * height) as usize];
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let ret = osmesa_sys::OSMesaMakeCurrent(
|
|
||||||
context,
|
|
||||||
buffer.as_mut_ptr() as *mut _,
|
|
||||||
gl::UNSIGNED_BYTE,
|
|
||||||
width as i32,
|
|
||||||
height as i32,
|
|
||||||
);
|
|
||||||
assert_ne!(ret, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
HeadlessContext {
|
HeadlessContext {
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
_context: context,
|
context: context,
|
||||||
_buffer: buffer,
|
buffer: RefCell::new(vec![0; (width * height) as usize]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +185,23 @@ impl WindowMethods for Window {
|
||||||
self.animation_state.set(state);
|
self.animation_state.set(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_for_composite(&self) { }
|
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||||
|
fn prepare_for_composite(&self) {
|
||||||
|
unsafe {
|
||||||
|
let mut buffer = self.context.buffer.borrow_mut();
|
||||||
|
let ret = osmesa_sys::OSMesaMakeCurrent(
|
||||||
|
self.context.context,
|
||||||
|
buffer.as_mut_ptr() as *mut _,
|
||||||
|
gl::UNSIGNED_BYTE,
|
||||||
|
self.context.width as i32,
|
||||||
|
self.context.height as i32,
|
||||||
|
);
|
||||||
|
assert_ne!(ret, 0);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||||
|
fn prepare_for_composite(&self) {}
|
||||||
|
|
||||||
fn get_gl_context(&self) -> MediaPlayerCtxt::GlContext {
|
fn get_gl_context(&self) -> MediaPlayerCtxt::GlContext {
|
||||||
MediaPlayerCtxt::GlContext::Unknown
|
MediaPlayerCtxt::GlContext::Unknown
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue