mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
servoshell: Remove duplicate egl bindings on android/ohos (#34716)
- The default value for SwapInterval is 1, so setting it to 1 changes nothing - We don't clear the screen immediately anymore, which was the only useage of the egl bindings this saves us from duplicated EGL bindings. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
65c65c9a6a
commit
0dd8798148
10 changed files with 6 additions and 110 deletions
|
@ -21,7 +21,6 @@ use simpleservo::{
|
|||
PromptResult, SERVO,
|
||||
};
|
||||
|
||||
use super::gl_glue;
|
||||
use super::host_trait::HostTrait;
|
||||
use super::servo_glue::{Coordinates, ServoGlue};
|
||||
|
||||
|
@ -142,9 +141,7 @@ pub extern "C" fn Java_org_servo_servoview_JNIServo_init<'local>(
|
|||
let wakeup = Box::new(WakeupCallback::new(callbacks_ref.clone(), &env));
|
||||
let callbacks = Box::new(HostCallbacks::new(callbacks_ref, &env));
|
||||
|
||||
if let Err(err) = gl_glue::init()
|
||||
.and_then(|egl_init| simpleservo::init(opts, egl_init.gl_wrapper, wakeup, callbacks))
|
||||
{
|
||||
if let Err(err) = simpleservo::init(opts, wakeup, callbacks) {
|
||||
throw(&mut env, err)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use servo::servo_config::{opts, pref};
|
|||
use servo::servo_url::ServoUrl;
|
||||
pub use servo::webrender_api::units::DeviceIntRect;
|
||||
use servo::webrender_traits::RenderingContext;
|
||||
use servo::{self, gl, Servo};
|
||||
use servo::{self, Servo};
|
||||
use surfman::{Connection, SurfaceType};
|
||||
|
||||
use crate::egl::android::resources::ResourceReaderInstance;
|
||||
|
@ -56,7 +56,6 @@ pub enum SurfmanIntegration {
|
|||
/// In the future, this will be done in multiple steps.
|
||||
pub fn init(
|
||||
mut init_opts: InitOptions,
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
callbacks: Box<dyn HostTrait>,
|
||||
) -> Result<(), &'static str> {
|
||||
|
@ -78,10 +77,6 @@ pub fn init(
|
|||
|
||||
let url = embedder_url.or(pref_url).or(blank_url).unwrap();
|
||||
|
||||
gl.clear_color(1.0, 1.0, 1.0, 1.0);
|
||||
gl.clear(gl::COLOR_BUFFER_BIT);
|
||||
gl.finish();
|
||||
|
||||
// Initialize surfman
|
||||
let connection = Connection::new().or(Err("Failed to create connection"))?;
|
||||
let adapter = connection
|
||||
|
@ -112,7 +107,6 @@ pub fn init(
|
|||
waker,
|
||||
#[cfg(feature = "webxr")]
|
||||
init_opts.xr_discovery,
|
||||
gl.clone(),
|
||||
));
|
||||
|
||||
let servo = Servo::new(
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
pub type ServoGl = std::rc::Rc<dyn servo::gl::Gl>;
|
||||
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
use log::info;
|
||||
use servo::gl::GlesFns;
|
||||
|
||||
pub type EGLNativeWindowType = *const libc::c_void;
|
||||
pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
|
||||
pub type khronos_uint64_t = u64;
|
||||
pub type khronos_ssize_t = libc::c_long;
|
||||
pub type EGLint = i32;
|
||||
pub type EGLContext = *const libc::c_void;
|
||||
pub type EGLNativeDisplayType = *const libc::c_void;
|
||||
pub type EGLNativePixmapType = *const libc::c_void;
|
||||
pub type NativeDisplayType = EGLNativeDisplayType;
|
||||
pub type NativePixmapType = EGLNativePixmapType;
|
||||
pub type NativeWindowType = EGLNativeWindowType;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
|
||||
|
||||
pub struct EGLInitResult {
|
||||
pub gl_wrapper: ServoGl,
|
||||
pub gl_context: EGLContext,
|
||||
pub display: EGLNativeDisplayType,
|
||||
}
|
||||
|
||||
pub fn init() -> Result<EGLInitResult, &'static str> {
|
||||
info!("Loading EGL...");
|
||||
unsafe {
|
||||
let egl = Egl;
|
||||
let display = egl.GetCurrentDisplay();
|
||||
egl.SwapInterval(display, 1);
|
||||
let egl = GlesFns::load_with(|addr| {
|
||||
let addr = CString::new(addr.as_bytes()).unwrap();
|
||||
let addr = addr.as_ptr();
|
||||
let egl = Egl;
|
||||
egl.GetProcAddress(addr) as *const c_void
|
||||
});
|
||||
info!("EGL loaded");
|
||||
Ok(EGLInitResult {
|
||||
gl_wrapper: egl,
|
||||
gl_context: Egl.GetCurrentContext(),
|
||||
display,
|
||||
})
|
||||
}
|
||||
}
|
|
@ -2,9 +2,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#[cfg(any(target_os = "android", target_env = "ohos"))]
|
||||
pub mod gl_glue;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
mod android;
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ use xcomponent_sys::{
|
|||
OH_NativeXComponent_GetKeyEventCode, OH_NativeXComponent_KeyAction, OH_NativeXComponent_KeyCode,
|
||||
};
|
||||
|
||||
use super::gl_glue;
|
||||
use super::host_trait::HostTrait;
|
||||
use super::servo_glue::ServoGlue;
|
||||
|
||||
|
@ -240,7 +239,6 @@ extern "C" fn on_surface_created_cb(xcomponent: *mut OH_NativeXComponent, window
|
|||
let wakeup = Box::new(WakeupCallback::new(tx));
|
||||
let callbacks = Box::new(HostCallbacks::new());
|
||||
|
||||
let egl_init = gl_glue::init().expect("egl::init() failed");
|
||||
let xc = xc_wrapper;
|
||||
let window = window_wrapper;
|
||||
let init_opts = if let Ok(ServoAction::Initialize(init_opts)) = rx.recv() {
|
||||
|
@ -248,15 +246,8 @@ extern "C" fn on_surface_created_cb(xcomponent: *mut OH_NativeXComponent, window
|
|||
} else {
|
||||
panic!("Servos GL thread received another event before it was initialized")
|
||||
};
|
||||
let mut servo = simpleservo::init(
|
||||
*init_opts,
|
||||
window.0,
|
||||
xc.0,
|
||||
egl_init.gl_wrapper,
|
||||
wakeup,
|
||||
callbacks,
|
||||
)
|
||||
.expect("Servo initialization failed");
|
||||
let mut servo = simpleservo::init(*init_opts, window.0, xc.0, wakeup, callbacks)
|
||||
.expect("Servo initialization failed");
|
||||
|
||||
info!("Surface created!");
|
||||
let native_vsync =
|
||||
|
|
|
@ -21,7 +21,7 @@ use servo::servo_config::opts;
|
|||
use servo::servo_config::opts::ArgumentParsingResult;
|
||||
use servo::servo_url::ServoUrl;
|
||||
use servo::webrender_traits::RenderingContext;
|
||||
use servo::{self, gl, Servo};
|
||||
use servo::{self, Servo};
|
||||
use surfman::{Connection, SurfaceType};
|
||||
|
||||
use crate::egl::host_trait::HostTrait;
|
||||
|
@ -37,7 +37,6 @@ pub fn init(
|
|||
options: InitOpts,
|
||||
native_window: *mut c_void,
|
||||
xcomponent: *mut OH_NativeXComponent,
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
callbacks: Box<dyn HostTrait>,
|
||||
) -> Result<ServoGlue, &'static str> {
|
||||
|
@ -92,10 +91,6 @@ pub fn init(
|
|||
|
||||
crate::prefs::register_user_prefs(&opts_matches);
|
||||
|
||||
gl.clear_color(1.0, 1.0, 1.0, 1.0);
|
||||
gl.clear(gl::COLOR_BUFFER_BIT);
|
||||
gl.finish();
|
||||
|
||||
// Initialize surfman
|
||||
let connection = Connection::new().or(Err("Failed to create connection"))?;
|
||||
let adapter = connection
|
||||
|
@ -139,7 +134,6 @@ pub fn init(
|
|||
waker,
|
||||
#[cfg(feature = "webxr")]
|
||||
None,
|
||||
gl.clone(),
|
||||
));
|
||||
|
||||
let servo = Servo::new(
|
||||
|
|
|
@ -28,7 +28,7 @@ use servo::servo_geometry::DeviceIndependentPixel;
|
|||
use servo::webrender_api::units::DevicePixel;
|
||||
use servo::webrender_api::ScrollLocation;
|
||||
use servo::webrender_traits::RenderingContext;
|
||||
use servo::{gl, Servo, TopLevelBrowsingContextId};
|
||||
use servo::{Servo, TopLevelBrowsingContextId};
|
||||
|
||||
use crate::egl::host_trait::HostTrait;
|
||||
|
||||
|
@ -660,21 +660,17 @@ pub(super) struct ServoEmbedderCallbacks {
|
|||
waker: Box<dyn EventLoopWaker>,
|
||||
#[cfg(feature = "webxr")]
|
||||
xr_discovery: Option<webxr::Discovery>,
|
||||
#[allow(unused)]
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
}
|
||||
|
||||
impl ServoEmbedderCallbacks {
|
||||
pub(super) fn new(
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
#[cfg(feature = "webxr")] xr_discovery: Option<webxr::Discovery>,
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
) -> Self {
|
||||
Self {
|
||||
waker,
|
||||
#[cfg(feature = "webxr")]
|
||||
xr_discovery,
|
||||
gl,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue