diff --git a/Cargo.lock b/Cargo.lock index acdf6dd5b24..1214b66ec53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6594,7 +6594,6 @@ dependencies = [ "euclid", "getopts", "gilrs", - "gl_generator", "gleam", "glow", "headers", diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index 91ae58ae0aa..2638c06dc7d 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -23,8 +23,6 @@ bench = false # must unconditionally add these dependencies. See https://github.com/rust-lang/cargo/issues/4932 [build-dependencies] vergen-git2 = { version = "1.0.2", features = ["build"] } -# Android and OpenHarmony -gl_generator = "0.14" # MacOS only cc = "1.2" diff --git a/ports/servoshell/build.rs b/ports/servoshell/build.rs index 43f62b1d9a1..cdedf953519 100644 --- a/ports/servoshell/build.rs +++ b/ports/servoshell/build.rs @@ -7,19 +7,8 @@ use std::fs::File; use std::io::Write; use std::path::Path; -use gl_generator::{Api, Fallbacks, Profile, Registry}; use vergen_git2::{Emitter, Git2Builder}; -// We can make this configurable in the future if different platforms start to have -// different needs. -fn generate_egl_bindings(out_dir: &Path) { - let mut file = File::create(out_dir.join("egl_bindings.rs")).unwrap(); - Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, []) - .write_bindings(gl_generator::StaticStructGenerator, &mut file) - .unwrap(); - println!("cargo:rustc-link-lib=EGL"); -} - fn emit_git_sha() -> Result<(), String> { let git_options = Git2Builder::default() .sha(true /* short */) @@ -55,7 +44,6 @@ fn main() -> Result<(), Box> { // Note: We can't use `#[cfg(windows)]`, since that would check the host platform // and not the target platform let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); - let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap(); if target_os == "windows" { #[cfg(windows)] @@ -72,8 +60,6 @@ fn main() -> Result<(), Box> { .file("platform/macos/count_threads.c") .compile("count_threads"); } else if target_os == "android" { - generate_egl_bindings(out); - // FIXME: We need this workaround since jemalloc-sys still links // to libgcc instead of libunwind, but Android NDK 23c and above // don't have libgcc. We can't disable jemalloc for Android as @@ -83,8 +69,6 @@ fn main() -> Result<(), Box> { let mut libgcc = File::create(out.join("libgcc.a")).unwrap(); libgcc.write_all(b"INPUT(-lunwind)").unwrap(); println!("cargo:rustc-link-search=native={}", out.display()); - } else if target_env == "ohos" { - generate_egl_bindings(out); } if let Err(error) = emit_git_sha() { diff --git a/ports/servoshell/egl/android.rs b/ports/servoshell/egl/android.rs index 951b3db8b86..02eb9640e18 100644 --- a/ports/servoshell/egl/android.rs +++ b/ports/servoshell/egl/android.rs @@ -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) }; } diff --git a/ports/servoshell/egl/android/simpleservo.rs b/ports/servoshell/egl/android/simpleservo.rs index d8ea39e8da1..1c110ad9a20 100644 --- a/ports/servoshell/egl/android/simpleservo.rs +++ b/ports/servoshell/egl/android/simpleservo.rs @@ -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, waker: Box, callbacks: Box, ) -> 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( diff --git a/ports/servoshell/egl/gl_glue.rs b/ports/servoshell/egl/gl_glue.rs deleted file mode 100644 index e0c9a3c564c..00000000000 --- a/ports/servoshell/egl/gl_glue.rs +++ /dev/null @@ -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; - -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 { - 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, - }) - } -} diff --git a/ports/servoshell/egl/mod.rs b/ports/servoshell/egl/mod.rs index b67dea98d1c..1f8a422d2ee 100644 --- a/ports/servoshell/egl/mod.rs +++ b/ports/servoshell/egl/mod.rs @@ -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; diff --git a/ports/servoshell/egl/ohos.rs b/ports/servoshell/egl/ohos.rs index e005eb0114c..03eed13aaf3 100644 --- a/ports/servoshell/egl/ohos.rs +++ b/ports/servoshell/egl/ohos.rs @@ -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 = diff --git a/ports/servoshell/egl/ohos/simpleservo.rs b/ports/servoshell/egl/ohos/simpleservo.rs index a29c9fa44fb..97e0e02f072 100644 --- a/ports/servoshell/egl/ohos/simpleservo.rs +++ b/ports/servoshell/egl/ohos/simpleservo.rs @@ -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, waker: Box, callbacks: Box, ) -> Result { @@ -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( diff --git a/ports/servoshell/egl/servo_glue.rs b/ports/servoshell/egl/servo_glue.rs index f94233d09cf..5bba384e420 100644 --- a/ports/servoshell/egl/servo_glue.rs +++ b/ports/servoshell/egl/servo_glue.rs @@ -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, #[cfg(feature = "webxr")] xr_discovery: Option, - #[allow(unused)] - gl: Rc, } impl ServoEmbedderCallbacks { pub(super) fn new( waker: Box, #[cfg(feature = "webxr")] xr_discovery: Option, - gl: Rc, ) -> Self { Self { waker, #[cfg(feature = "webxr")] xr_discovery, - gl, } } }