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

View file

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

View file

@ -55,9 +55,10 @@ lazy_static = { workspace = true }
libc = { workspace = true }
libservo = { path = "../../components/servo" }
log = { workspace = true }
raw-window-handle = "0.5"
servo-media = { git = "https://github.com/servo/media" }
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"
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] }
winit = "0.28.3"

View file

@ -14,7 +14,7 @@ use euclid::{
#[cfg(any(target_os = "linux", target_os = "windows"))]
use winit::window::Icon;
use winit::event::{ElementState, KeyboardInput, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use servo::keyboard_types::{Key, KeyState, KeyboardEvent};
use servo::compositing::windowing::{AnimationState, MouseWindowEvent, EmbedderEvent};
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 std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::rc::Rc;
#[cfg(target_os = "linux")]
use surfman::platform::generic::multi::connection::NativeConnection;
@ -125,13 +124,15 @@ impl Window {
let inner_size = Size2D::new(width, height);
// Initialize surfman
let display_handle = winit_window.raw_display_handle();
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
.create_adapter()
.expect("Failed to create adapter");
let window_handle = winit_window.raw_window_handle();
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");
let surface_type = SurfaceType::Widget { native_widget };
let webrender_surfman = WebrenderSurfman::create(&connection, &adapter, surface_type)