use Proxy;
use protocol::wl_surface::WlSurface;
use std::os::raw::c_void;
use wayland_sys::client::wl_proxy;
use wayland_sys::egl::*;
pub fn is_available() -> bool {
is_lib_available()
}
unsafe impl Send for WlEglSurface {}
unsafe impl Sync for WlEglSurface {}
pub struct WlEglSurface {
ptr: *mut wl_egl_window,
}
impl WlEglSurface {
pub fn new(surface: &Proxy<WlSurface>, width: i32, height: i32) -> WlEglSurface {
unsafe { WlEglSurface::new_from_raw(surface.c_ptr(), width, height) }
}
pub unsafe fn new_from_raw(surface: *mut wl_proxy, width: i32, height: i32) -> WlEglSurface {
let ptr = ffi_dispatch!(
WAYLAND_EGL_HANDLE,
wl_egl_window_create,
surface,
width,
height
);
WlEglSurface { ptr: ptr }
}
pub fn get_size(&self) -> (i32, i32) {
let mut w = 0i32;
let mut h = 0i32;
unsafe {
ffi_dispatch!(
WAYLAND_EGL_HANDLE,
wl_egl_window_get_attached_size,
self.ptr,
&mut w as *mut i32,
&mut h as *mut i32
);
}
(w, h)
}
pub fn resize(&self, width: i32, height: i32, dx: i32, dy: i32) {
unsafe {
ffi_dispatch!(
WAYLAND_EGL_HANDLE,
wl_egl_window_resize,
self.ptr,
width,
height,
dx,
dy
)
}
}
pub fn ptr(&self) -> *const c_void {
self.ptr as *const c_void
}
}
impl Drop for WlEglSurface {
fn drop(&mut self) {
unsafe {
ffi_dispatch!(WAYLAND_EGL_HANDLE, wl_egl_window_destroy, self.ptr);
}
}
}