mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update WR (gl/es runtime table, scroll roots).
This commit is contained in:
parent
9d72e89ce3
commit
fe75382bcb
19 changed files with 212 additions and 174 deletions
|
@ -21,7 +21,7 @@ debugmozjs = ["libservo/debugmozjs"]
|
|||
compositing = {path = "../../components/compositing"}
|
||||
devtools = {path = "../../components/devtools"}
|
||||
euclid = "0.11"
|
||||
gleam = "0.2.8"
|
||||
gleam = "0.4"
|
||||
glutin_app = {path = "../glutin"}
|
||||
libc = "0.2"
|
||||
libservo = {path = "../../components/servo"}
|
||||
|
|
|
@ -48,47 +48,49 @@ pub static mut DISPLAY: *mut c_void = 0 as *mut c_void;
|
|||
#[derive(Clone)]
|
||||
pub struct Window {
|
||||
cef_browser: RefCell<Option<CefBrowser>>,
|
||||
size: TypedSize2D<u32, DevicePixel>
|
||||
size: TypedSize2D<u32, DevicePixel>,
|
||||
gl: Rc<gl::Gl>,
|
||||
}
|
||||
|
||||
#[cfg(target_os="macos")]
|
||||
fn load_gl() {
|
||||
fn load_gl() -> Rc<gl::Gl> {
|
||||
const RTLD_DEFAULT: *mut c_void = (-2isize) as usize as *mut c_void;
|
||||
|
||||
extern {
|
||||
fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
|
||||
}
|
||||
|
||||
gl::load_with(|s| {
|
||||
unsafe {
|
||||
unsafe {
|
||||
gl::GlFns::load_with(|s| {
|
||||
let c_str = CString::new(s).unwrap();
|
||||
dlsym(RTLD_DEFAULT, c_str.as_ptr()) as *const c_void
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os="linux")]
|
||||
fn load_gl() {
|
||||
fn load_gl() -> Rc<gl::Gl> {
|
||||
extern {
|
||||
fn glXGetProcAddress(symbol: *const c_char) -> *mut c_void;
|
||||
}
|
||||
|
||||
gl::load_with(|s| {
|
||||
unsafe {
|
||||
unsafe {
|
||||
gl::GlFns::load_with(|s| {
|
||||
let c_str = CString::new(s).unwrap();
|
||||
glXGetProcAddress(c_str.as_ptr()) as *const c_void
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
/// Creates a new window.
|
||||
pub fn new(width: u32, height: u32) -> Rc<Window> {
|
||||
load_gl();
|
||||
let gl = load_gl();
|
||||
|
||||
Rc::new(Window {
|
||||
cef_browser: RefCell::new(None),
|
||||
size: TypedSize2D::new(width, height)
|
||||
size: TypedSize2D::new(width, height),
|
||||
gl: gl,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -170,6 +172,10 @@ impl Window {
|
|||
}
|
||||
|
||||
impl WindowMethods for Window {
|
||||
fn gl(&self) -> Rc<gl::Gl> {
|
||||
self.gl.clone()
|
||||
}
|
||||
|
||||
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel> {
|
||||
let browser = self.cef_browser.borrow();
|
||||
match *browser {
|
||||
|
|
|
@ -12,12 +12,12 @@ path = "lib.rs"
|
|||
bitflags = "0.7"
|
||||
compositing = {path = "../../components/compositing"}
|
||||
euclid = "0.11"
|
||||
gleam = "0.2.8"
|
||||
gleam = "0.4"
|
||||
log = "0.3.5"
|
||||
msg = {path = "../../components/msg"}
|
||||
net_traits = {path = "../../components/net_traits"}
|
||||
script_traits = {path = "../../components/script_traits"}
|
||||
servo-glutin = "0.9"
|
||||
servo-glutin = "0.10"
|
||||
servo_geometry = {path = "../../components/geometry"}
|
||||
servo_config = {path = "../../components/config"}
|
||||
servo_url = {path = "../../components/url"}
|
||||
|
|
|
@ -191,6 +191,8 @@ pub struct Window {
|
|||
/// The list of keys that have been pressed but not yet released, to allow providing
|
||||
/// the equivalent ReceivedCharacter data as was received for the press event.
|
||||
pressed_key_map: RefCell<Vec<(ScanCode, char)>>,
|
||||
|
||||
gl: Rc<gl::Gl>,
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
|
@ -259,14 +261,34 @@ impl Window {
|
|||
WindowKind::Window(glutin_window)
|
||||
};
|
||||
|
||||
Window::load_gl_functions(&window_kind);
|
||||
let gl = match window_kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
match gl::GlType::default() {
|
||||
gl::GlType::Gl => {
|
||||
unsafe {
|
||||
gl::GlFns::load_with(|s| window.get_proc_address(s) as *const _)
|
||||
}
|
||||
}
|
||||
gl::GlType::Gles => {
|
||||
unsafe {
|
||||
gl::GlesFns::load_with(|s| window.get_proc_address(s) as *const _)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WindowKind::Headless(..) => {
|
||||
unsafe {
|
||||
gl::GlFns::load_with(|s| HeadlessContext::get_proc_address(s))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if opts::get().headless {
|
||||
// Print some information about the headless renderer that
|
||||
// can be useful in diagnosing CI failures on build machines.
|
||||
println!("{}", gl::get_string(gl::VENDOR));
|
||||
println!("{}", gl::get_string(gl::RENDERER));
|
||||
println!("{}", gl::get_string(gl::VERSION));
|
||||
println!("{}", gl.get_string(gl::VENDOR));
|
||||
println!("{}", gl.get_string(gl::RENDERER));
|
||||
println!("{}", gl.get_string(gl::VERSION));
|
||||
}
|
||||
|
||||
let window = Window {
|
||||
|
@ -281,11 +303,12 @@ impl Window {
|
|||
|
||||
pending_key_event_char: Cell::new(None),
|
||||
pressed_key_map: RefCell::new(vec![]),
|
||||
gl: gl.clone(),
|
||||
};
|
||||
|
||||
gl::clear_color(0.6, 0.6, 0.6, 1.0);
|
||||
gl::clear(gl::COLOR_BUFFER_BIT);
|
||||
gl::finish();
|
||||
gl.clear_color(0.6, 0.6, 0.6, 1.0);
|
||||
gl.clear(gl::COLOR_BUFFER_BIT);
|
||||
gl.finish();
|
||||
window.present();
|
||||
|
||||
Rc::new(window)
|
||||
|
@ -321,24 +344,6 @@ impl Window {
|
|||
GlRequest::Specific(Api::OpenGlEs, (3, 0))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
fn load_gl_functions(window_kind: &WindowKind) {
|
||||
match window_kind {
|
||||
&WindowKind::Window(ref window) => {
|
||||
gl::load_with(|s| window.get_proc_address(s) as *const c_void);
|
||||
}
|
||||
&WindowKind::Headless(..) => {
|
||||
gl::load_with(|s| {
|
||||
HeadlessContext::get_proc_address(s)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
fn load_gl_functions(_: &WindowKind) {
|
||||
}
|
||||
|
||||
fn handle_window_event(&self, event: glutin::Event) -> bool {
|
||||
match event {
|
||||
Event::ReceivedCharacter(ch) => {
|
||||
|
@ -784,6 +789,10 @@ fn create_window_proxy(window: &Window) -> Option<glutin::WindowProxy> {
|
|||
}
|
||||
|
||||
impl WindowMethods for Window {
|
||||
fn gl(&self) -> Rc<gl::Gl> {
|
||||
self.gl.clone()
|
||||
}
|
||||
|
||||
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel> {
|
||||
match self.kind {
|
||||
WindowKind::Window(ref window) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue