Skip to content

Commit 7e46179

Browse files
authored
egl: add openharmony support
1 parent 0d80a76 commit 7e46179

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Added `Device::drm_device_node_path()` and `Device::drm_render_device_node_path()` getters to EGL via `EGL_EXT_device_drm`.
1010
- Added support for `DrmDisplayHandle` in EGL's `Display::with_device()` using `EGL_DRM_MASTER_FD_EXT` from `EGL_EXT_device_drm`.
1111
- Properly set up OpenGL-specific stuff on the `NSView`, instead of relying on Winit to do it.
12+
- Added `OpenHarmony` platform support with EGL.
1213

1314
# Version 0.32.0
1415

glutin/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ wayland = ["wayland-sys", "egl"]
2323
bitflags = "2.2.1"
2424
libloading = { version = "0.8.0", optional = true }
2525
once_cell = "1.13"
26-
raw-window-handle = "0.6"
26+
raw-window-handle = "0.6.2"
2727

2828
[target.'cfg(windows)'.dependencies]
2929
glutin_egl_sys = { version = "0.7.0", path = "../glutin_egl_sys", optional = true }

glutin/build.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ fn main() {
55
cfg_aliases! {
66
// Systems.
77
android_platform: { target_os = "android" },
8+
ohos_platform: { target_env = "ohos" },
89
wasm_platform: { target_family = "wasm" },
910
macos_platform: { target_os = "macos" },
1011
ios_platform: { target_os = "ios" },
1112
apple: { any(ios_platform, macos_platform) },
12-
free_unix: { all(unix, not(apple), not(android_platform)) },
13+
free_unix: { all(unix, not(apple), not(android_platform), not(ohos_platform)) },
1314

1415
// Native displays.
1516
x11_platform: { all(feature = "x11", free_unix, not(wasm_platform)) },

glutin/src/api/egl/display.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,9 @@ impl Display {
441441
RawDisplayHandle::Xlib(XlibDisplayHandle { display, .. }) => {
442442
display.map_or(egl::DEFAULT_DISPLAY as *mut _, |d| d.as_ptr())
443443
},
444-
RawDisplayHandle::Android(_) => egl::DEFAULT_DISPLAY as *mut _,
444+
RawDisplayHandle::Android(_) | RawDisplayHandle::Ohos(_) => {
445+
egl::DEFAULT_DISPLAY as *mut _
446+
},
445447
_ => {
446448
return Err(
447449
ErrorKind::NotSupported("provided display handle is not supported").into()

glutin/src/api/egl/surface.rs

+11
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ enum NativeWindow {
456456
#[cfg(android_platform)]
457457
Android(*mut ffi::c_void),
458458

459+
#[cfg(ohos_platform)]
460+
Ohos(*mut ffi::c_void),
461+
459462
#[cfg(windows)]
460463
Win32(isize),
461464

@@ -498,6 +501,10 @@ impl NativeWindow {
498501
RawWindowHandle::AndroidNdk(window_handle) => {
499502
Self::Android(window_handle.a_native_window.as_ptr())
500503
},
504+
#[cfg(ohos_platform)]
505+
RawWindowHandle::OhosNdk(window_handle) => {
506+
Self::Ohos(window_handle.native_window.as_ptr())
507+
},
501508
#[cfg(windows)]
502509
RawWindowHandle::Win32(window_handle) => Self::Win32(window_handle.hwnd.get() as _),
503510
#[cfg(free_unix)]
@@ -542,6 +549,8 @@ impl NativeWindow {
542549
Self::Win32(hwnd) => hwnd,
543550
#[cfg(android_platform)]
544551
Self::Android(a_native_window) => a_native_window,
552+
#[cfg(ohos_platform)]
553+
Self::Ohos(native_window) => native_window,
545554
#[cfg(free_unix)]
546555
Self::Gbm(gbm_surface) => gbm_surface,
547556
}
@@ -573,6 +582,8 @@ impl NativeWindow {
573582
Self::Win32(hwnd) => *hwnd as *const ffi::c_void as *mut _,
574583
#[cfg(android_platform)]
575584
Self::Android(a_native_window) => *a_native_window,
585+
#[cfg(ohos_platform)]
586+
Self::Ohos(native_window) => *native_window,
576587
#[cfg(free_unix)]
577588
Self::Gbm(gbm_surface) => *gbm_surface,
578589
}

0 commit comments

Comments
 (0)