Use raw handles to create surfman context instead (#29871)

This commit is contained in:
Ngo Iok Ui (Wu Yu Wei) 2023-08-03 18:54:30 +08:00 committed by GitHub
parent d90e3078a6
commit 3fea90a231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 13 deletions

13
Cargo.lock generated
View file

@ -5322,6 +5322,7 @@ dependencies = [
"libc", "libc",
"libservo", "libservo",
"log", "log",
"raw-window-handle 0.5.0",
"servo-media", "servo-media",
"shellwords", "shellwords",
"sig", "sig",
@ -6049,9 +6050,9 @@ dependencies = [
[[package]] [[package]]
name = "surfman" name = "surfman"
version = "0.6.0" version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4ebdfa54ba49e91f713e232973ca44ac493aa98e6fbf1366772ffdf9b9ddb3f" checksum = "23cf77d20c00c8355323883b3ab476057430bd4c752c6b5cff4fabc9aa5786e9"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"cfg_aliases", "cfg_aliases",
@ -6079,9 +6080,9 @@ dependencies = [
[[package]] [[package]]
name = "surfman-chains" name = "surfman-chains"
version = "0.7.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b51e9d68bff975cc81ed92995691c9522c49a0531900b6548e7c5bbb8681cc79" checksum = "896f2c9668d2b6b1cc6634bcba84b6e80147c2c9243dfde6dedf782756f9a19c"
dependencies = [ dependencies = [
"euclid", "euclid",
"fnv", "fnv",
@ -7073,7 +7074,7 @@ dependencies = [
[[package]] [[package]]
name = "webxr" name = "webxr"
version = "0.0.1" version = "0.0.1"
source = "git+https://github.com/servo/webxr#a5824ed9674d60a507c8b8f8511cfdbbd68c92c6" source = "git+https://github.com/servo/webxr#8be0c295d966ad9334fc9ad828d966ac14b21eac"
dependencies = [ dependencies = [
"android_injected_glue", "android_injected_glue",
"bindgen", "bindgen",
@ -7093,7 +7094,7 @@ dependencies = [
[[package]] [[package]]
name = "webxr-api" name = "webxr-api"
version = "0.0.1" version = "0.0.1"
source = "git+https://github.com/servo/webxr#a5824ed9674d60a507c8b8f8511cfdbbd68c92c6" source = "git+https://github.com/servo/webxr#8be0c295d966ad9334fc9ad828d966ac14b21eac"
dependencies = [ dependencies = [
"euclid", "euclid",
"ipc-channel", "ipc-channel",

View file

@ -67,8 +67,8 @@ smallvec = "1.9"
sparkle = "0.1.25" sparkle = "0.1.25"
string_cache = "0.8" string_cache = "0.8"
string_cache_codegen = "0.5" string_cache_codegen = "0.5"
surfman = "0.6" surfman = "0.7"
surfman-chains = "0.7" surfman-chains = "0.8"
surfman-chains-api = "0.2" surfman-chains-api = "0.2"
thin-slice = "0.1.0" thin-slice = "0.1.0"
time = "0.1.41" time = "0.1.41"

View file

@ -55,9 +55,10 @@ lazy_static = { workspace = true }
libc = { workspace = true } libc = { workspace = true }
libservo = { path = "../../components/servo" } libservo = { path = "../../components/servo" }
log = { workspace = true } log = { workspace = true }
raw-window-handle = "0.5"
servo-media = { git = "https://github.com/servo/media" } servo-media = { git = "https://github.com/servo/media" }
shellwords = "1.0.0" shellwords = "1.0.0"
surfman = { workspace = true, features = ["sm-winit", "sm-x11"] } surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle"] }
tinyfiledialogs = "3.0" tinyfiledialogs = "3.0"
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] } webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] }
winit = "0.28.3" winit = "0.28.3"

View file

@ -14,7 +14,7 @@ use euclid::{
#[cfg(any(target_os = "linux", target_os = "windows"))] #[cfg(any(target_os = "linux", target_os = "windows"))]
use winit::window::Icon; use winit::window::Icon;
use winit::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode}; use winit::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use servo::keyboard_types::{Key, KeyState, KeyboardEvent}; use servo::keyboard_types::{Key, KeyState, KeyboardEvent};
use servo::compositing::windowing::{AnimationState, MouseWindowEvent, EmbedderEvent}; use servo::compositing::windowing::{AnimationState, MouseWindowEvent, EmbedderEvent};
use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods}; use servo::compositing::windowing::{EmbedderCoordinates, WindowMethods};
@ -30,7 +30,6 @@ use servo::webrender_surfman::WebrenderSurfman;
use servo_media::player::context::{GlApi, GlContext as PlayerGLContext, NativeDisplay}; use servo_media::player::context::{GlApi, GlContext as PlayerGLContext, NativeDisplay};
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::Rc; use std::rc::Rc;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use surfman::platform::generic::multi::connection::NativeConnection; use surfman::platform::generic::multi::connection::NativeConnection;
@ -125,13 +124,15 @@ impl Window {
let inner_size = Size2D::new(width, height); let inner_size = Size2D::new(width, height);
// Initialize surfman // Initialize surfman
let display_handle = winit_window.raw_display_handle();
let connection = let connection =
Connection::from_winit_window(&winit_window).expect("Failed to create connection"); Connection::from_raw_display_handle(display_handle).expect("Failed to create connection");
let adapter = connection let adapter = connection
.create_adapter() .create_adapter()
.expect("Failed to create adapter"); .expect("Failed to create adapter");
let window_handle = winit_window.raw_window_handle();
let native_widget = connection let native_widget = connection
.create_native_widget_from_winit_window(&winit_window) .create_native_widget_from_rwh(window_handle)
.expect("Failed to create native widget"); .expect("Failed to create native widget");
let surface_type = SurfaceType::Widget { native_widget }; let surface_type = SurfaceType::Widget { native_widget };
let webrender_surfman = WebrenderSurfman::create(&connection, &adapter, surface_type) let webrender_surfman = WebrenderSurfman::create(&connection, &adapter, surface_type)