From 869c398a633a6fa5edfec6d30224835451456e77 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sat, 21 Sep 2024 09:25:18 +0800 Subject: [PATCH 1/5] feat: add openharmony support --- glutin/build.rs | 3 ++- glutin/src/api/egl/display.rs | 2 +- glutin/src/api/egl/surface.rs | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/glutin/build.rs b/glutin/build.rs index c8eab1b931..b5f34354b0 100644 --- a/glutin/build.rs +++ b/glutin/build.rs @@ -5,11 +5,12 @@ fn main() { cfg_aliases! { // Systems. android_platform: { target_os = "android" }, + ohos_platform: { target_env = "ohos" }, wasm_platform: { target_family = "wasm" }, macos_platform: { target_os = "macos" }, ios_platform: { target_os = "ios" }, apple: { any(ios_platform, macos_platform) }, - free_unix: { all(unix, not(apple), not(android_platform)) }, + free_unix: { all(unix, not(apple), not(android_platform), not(ohos_platform)) }, // Native displays. x11_platform: { all(feature = "x11", free_unix, not(wasm_platform)) }, diff --git a/glutin/src/api/egl/display.rs b/glutin/src/api/egl/display.rs index 3cc47653bb..1a282eb6d5 100644 --- a/glutin/src/api/egl/display.rs +++ b/glutin/src/api/egl/display.rs @@ -441,7 +441,7 @@ impl Display { RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => { display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()) }, - RawDisplayHandle::Android(_) => egl::DEFAULT_DISPLAY as *mut _, + RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => egl::DEFAULT_DISPLAY as *mut _, _ => { return Err( ErrorKind::NotSupported("provided display handle is not supported").into() diff --git a/glutin/src/api/egl/surface.rs b/glutin/src/api/egl/surface.rs index 800d911c01..222e033b74 100644 --- a/glutin/src/api/egl/surface.rs +++ b/glutin/src/api/egl/surface.rs @@ -456,6 +456,9 @@ enum NativeWindow { #[cfg(android_platform)] Android(*mut ffi::c_void), + #[cfg(ohos_platform)] + Ohos(*mut ffi::c_void), + #[cfg(windows)] Win32(isize), @@ -498,6 +501,10 @@ impl NativeWindow { RawWindowHandle::AndroidNdk(window_handle) => { Self::Android(window_handle.a_native_window.as_ptr()) }, + #[cfg(ohos_platform)] + RawWindowHandle::OhosNdk(window_handle) => { + Self::Ohos(window_handle.native_window.as_ptr()) + }, #[cfg(windows)] RawWindowHandle::Win32(window_handle) => Self::Win32(window_handle.hwnd.get() as _), #[cfg(free_unix)] @@ -542,6 +549,8 @@ impl NativeWindow { Self::Win32(hwnd) => hwnd, #[cfg(android_platform)] Self::Android(a_native_window) => a_native_window, + #[cfg(ohos_platform)] + Self::Ohos(native_window) => native_window, #[cfg(free_unix)] Self::Gbm(gbm_surface) => gbm_surface, } @@ -573,6 +582,8 @@ impl NativeWindow { Self::Win32(hwnd) => *hwnd as *const ffi::c_void as *mut _, #[cfg(android_platform)] Self::Android(a_native_window) => *a_native_window, + #[cfg(ohos_platform)] + Self::Ohos(native_window) => *native_window, #[cfg(free_unix)] Self::Gbm(gbm_surface) => *gbm_surface, } From c88450eda3780b2e8753aa6ec45d79ee7a165519 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sat, 21 Sep 2024 09:49:33 +0800 Subject: [PATCH 2/5] docs: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3fe94f63b..842f82efa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Added `Device::drm_device_node_path()` and `Device::drm_render_device_node_path()` getters to EGL via `EGL_EXT_device_drm`. - Added support for `DrmDisplayHandle` in EGL's `Display::with_device()` using `EGL_DRM_MASTER_FD_EXT` from `EGL_EXT_device_drm`. - Properly set up OpenGL-specific stuff on the `NSView`, instead of relying on Winit to do it. +- Add `OpenHarmony` platform support. # Version 0.32.0 From 3174680cefb5bbe49047031fcd734d18ca0ed8bf Mon Sep 17 00:00:00 2001 From: richerfu Date: Sat, 21 Sep 2024 09:59:41 +0800 Subject: [PATCH 3/5] chore: format code --- glutin/src/api/egl/display.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glutin/src/api/egl/display.rs b/glutin/src/api/egl/display.rs index 1a282eb6d5..4c2454d467 100644 --- a/glutin/src/api/egl/display.rs +++ b/glutin/src/api/egl/display.rs @@ -441,7 +441,9 @@ impl Display { RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => { display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr()) }, - RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => egl::DEFAULT_DISPLAY as *mut _, + RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => { + egl::DEFAULT_DISPLAY as *mut _ + }, _ => { return Err( ErrorKind::NotSupported("provided display handle is not supported").into() From ad38b1755a73a39884688cca1a1a8bc7f8b3de6a Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 22 Sep 2024 10:32:21 +0800 Subject: [PATCH 4/5] docs: update docs --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 842f82efa3..8428fa085b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - Added `Device::drm_device_node_path()` and `Device::drm_render_device_node_path()` getters to EGL via `EGL_EXT_device_drm`. - Added support for `DrmDisplayHandle` in EGL's `Display::with_device()` using `EGL_DRM_MASTER_FD_EXT` from `EGL_EXT_device_drm`. - Properly set up OpenGL-specific stuff on the `NSView`, instead of relying on Winit to do it. -- Add `OpenHarmony` platform support. +- Added `OpenHarmony` platform support with EGL. # Version 0.32.0 From a4f4591320020b88406b73e155c1080edcf94a76 Mon Sep 17 00:00:00 2001 From: richerfu Date: Sun, 22 Sep 2024 11:31:03 +0800 Subject: [PATCH 5/5] chore: upgrade raw-window-handle to 0.6.2 --- glutin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 0ed20244c5..ff9251eef4 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -23,7 +23,7 @@ wayland = ["wayland-sys", "egl"] bitflags = "2.2.1" libloading = { version = "0.8.0", optional = true } once_cell = "1.13" -raw-window-handle = "0.6" +raw-window-handle = "0.6.2" [target.'cfg(windows)'.dependencies] glutin_egl_sys = { version = "0.7.0", path = "../glutin_egl_sys", optional = true }