New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce the amount of EGL buffer swapping the ML port is doing #22044
Changes from all commits
File filter...
Jump to…
Reduce the amount of EGL buffer swapping the ML port is doing
- Loading branch information
| @@ -7,6 +7,11 @@ extern crate egl; | ||||
| extern crate servo; | ||||
| extern crate smallvec; | ||||
|
|
||||
| use egl::egl::EGLContext; | ||||
| use egl::egl::EGLDisplay; | ||||
| use egl::egl::EGLSurface; | ||||
| use egl::egl::MakeCurrent; | ||||
| use egl::egl::SwapBuffers; | ||||
| use egl::eglext::eglGetProcAddress; | ||||
| use servo::BrowserId; | ||||
| use servo::Servo; | ||||
| @@ -36,10 +41,6 @@ use std::os::raw::c_void; | ||||
| use std::path::PathBuf; | ||||
| use std::rc::Rc; | ||||
|
|
||||
| type EGLContext = *const c_void; | ||||
| type EGLSurface = *const c_void; | ||||
| type EGLDisplay = *const c_void; | ||||
|
|
||||
| type ServoInstance = *mut c_void; | ||||
|
|
||||
| #[repr(u32)] | ||||
| @@ -58,9 +59,9 @@ pub struct MLLogger(extern "C" fn (MLLogLevel, *const c_char)); | ||||
| const LOG_LEVEL: log::LevelFilter = log::LevelFilter::Info; | ||||
|
|
||||
| #[no_mangle] | ||||
| pub unsafe extern "C" fn init_servo(_ctxt: EGLContext, | ||||
| _surf: EGLSurface, | ||||
| _disp: EGLDisplay, | ||||
| pub unsafe extern "C" fn init_servo(ctxt: EGLContext, | ||||
| surf: EGLSurface, | ||||
| disp: EGLDisplay, | ||||
| logger: MLLogger, | ||||
| url: *const c_char, | ||||
| width: u32, | ||||
| @@ -77,7 +78,15 @@ pub unsafe extern "C" fn init_servo(_ctxt: EGLContext, | ||||
| }); | ||||
|
|
||||
| info!("OpenGL version {}", gl.get_string(gl::VERSION)); | ||||
| let window = Rc::new(WindowInstance::new(gl, width, height, hidpi)); | ||||
| let window = Rc::new(WindowInstance { | ||||
| ctxt: ctxt, | ||||
| surf: surf, | ||||
| disp: disp, | ||||
| gl: gl, | ||||
| width: width, | ||||
| height: height, | ||||
| hidpi: hidpi, | ||||
| }); | ||||
|
|
||||
| info!("Starting servo"); | ||||
| let mut servo = Box::new(Servo::new(window)); | ||||
| @@ -110,28 +119,23 @@ pub unsafe extern "C" fn discard_servo(servo: ServoInstance) { | ||||
| } | ||||
|
|
||||
| struct WindowInstance { | ||||
| ctxt: EGLContext, | ||||
| surf: EGLSurface, | ||||
| disp: EGLDisplay, | ||||
| gl: Rc<Gl>, | ||||
| width: u32, | ||||
| height: u32, | ||||
| hidpi: f32, | ||||
| } | ||||
|
|
||||
| impl WindowInstance { | ||||
| fn new(gl: Rc<Gl>, width: u32, height: u32, hidpi: f32) -> WindowInstance { | ||||
| WindowInstance { | ||||
| gl: gl, | ||||
| width: width, | ||||
| height: height, | ||||
| hidpi: hidpi, | ||||
| } | ||||
| } | ||||
| } | ||||
|
|
||||
| impl WindowMethods for WindowInstance { | ||||
| fn present(&self) { | ||||
| SwapBuffers(self.disp, self.surf); | ||||
| } | ||||
|
|
||||
| fn prepare_for_composite(&self, _w: Length<u32, DevicePixel>, _h: Length<u32, DevicePixel>) -> bool { | ||||
| MakeCurrent(self.disp, self.surf, self.surf, self.ctxt); | ||||
| self.gl.viewport(0, 0, self.width as i32, self.height as i32); | ||||
asajeffrey
Author
Member
|
||||
| let coordinates = window.get_coordinates(); |
Edit: Submitted a PR to remove the parameters #22048
Shouldn't this be using the w and h arguments instead?