Skip to content

Commit 8766dfc

Browse files
committed
Use the mozangle crate
1 parent 27be710 commit 8766dfc

File tree

5 files changed

+28
-92
lines changed

5 files changed

+28
-92
lines changed

Cargo.lock

+21-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

direct-composition/Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ authors = ["Simon Sapin <simon.sapin@exyr.org>"]
66
[target.'cfg(windows)'.dependencies]
77
winapi = {version = "0.3", features = ["winerror", "d3d11", "dcomp"]}
88

9-
# For the `main.rs` demo
109
[dependencies]
1110
euclid = "0.16"
1211
gleam = "0.4"
12+
mozangle = {version = "0.1", features = ["egl"]}
1313
webrender = {path = "../webrender"}
1414
winit = "0.10"
15-
16-
[build-dependencies]
17-
gl_generator = "0.9.0"

direct-composition/build.rs

-44
This file was deleted.

direct-composition/src/egl.rs

+4-42
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
use std::ffi::CString;
2-
use std::os::raw::{c_void, c_long};
1+
use std::os::raw::c_void;
32
use std::ptr;
43
use std::rc::Rc;
5-
use winapi;
4+
use mozangle::egl::ffi::*;
65
use winapi::um::d3d11::ID3D11Device;
76
use winapi::um::d3d11::ID3D11Texture2D;
87

9-
pub fn get_proc_address(name: &str) -> *const c_void {
10-
let name = CString::new(name.as_bytes()).unwrap();
11-
unsafe {
12-
GetProcAddress(name.as_ptr()) as *const _ as _
13-
}
14-
}
8+
pub use mozangle::egl::get_proc_address;
159

1610
pub struct SharedEglThings {
1711
device: EGLDeviceEXT,
@@ -39,7 +33,7 @@ impl SharedEglThings {
3933
pub unsafe fn new(d3d_device: *mut ID3D11Device) -> Rc<Self> {
4034
let device = eglCreateDeviceANGLE(
4135
D3D11_DEVICE_ANGLE,
42-
d3d_device,
36+
d3d_device as *mut c_void,
4337
ptr::null(),
4438
).check();
4539
let display = GetPlatformDisplayEXT(
@@ -174,35 +168,3 @@ impl Check for types::EGLBoolean {
174168
self
175169
}
176170
}
177-
178-
// Adapted from https://github.com/tomaka/glutin/blob/1f3b8360cb/src/api/egl/ffi.rs
179-
#[allow(non_camel_case_types)] pub type khronos_utime_nanoseconds_t = khronos_uint64_t;
180-
#[allow(non_camel_case_types)] pub type khronos_uint64_t = u64;
181-
#[allow(non_camel_case_types)] pub type khronos_ssize_t = c_long;
182-
pub type EGLint = i32;
183-
pub type EGLNativeDisplayType = *const c_void;
184-
pub type EGLNativePixmapType = *const c_void;
185-
pub type EGLNativeWindowType = winapi::shared::windef::HWND;
186-
pub type NativeDisplayType = EGLNativeDisplayType;
187-
pub type NativePixmapType = EGLNativePixmapType;
188-
pub type NativeWindowType = EGLNativeWindowType;
189-
190-
include!(concat!(env!("OUT_DIR"), "/egl_bindings.rs"));
191-
192-
193-
// Adapted from https://chromium.googlesource.com/angle/angle/+/master/include/EGL/eglext_angle.h
194-
type EGLDeviceEXT = *mut c_void;
195-
const EXPERIMENTAL_PRESENT_PATH_ANGLE: types::EGLenum = 0x33A4;
196-
const EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE: types::EGLenum = 0x33A9;
197-
const D3D_TEXTURE_ANGLE: types::EGLenum = 0x33A3;
198-
const FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE: types::EGLenum = 0x33A6;
199-
200-
extern "C" {
201-
fn eglCreateDeviceANGLE(
202-
device_type: types::EGLenum,
203-
device: *mut ID3D11Device,
204-
attrib_list: *const types::EGLAttrib,
205-
) -> EGLDeviceEXT;
206-
207-
fn eglReleaseDeviceANGLE(device: EGLDeviceEXT) -> types::EGLBoolean;
208-
}

direct-composition/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#![cfg(windows)]
22

3-
extern crate winapi;
43
extern crate gleam;
4+
extern crate mozangle;
5+
extern crate winapi;
56

67
use com::{ComPtr, CheckHResult, as_ptr};
78
use std::ptr;

0 commit comments

Comments
 (0)