pub const G2D_VERSION_MAJOR: u32 = 2;
pub const G2D_VERSION_MINOR: u32 = 5;
pub const G2D_VERSION_PATCH: u32 = 0;
pub const g2d_format_G2D_RGB565: g2d_format = 0;
pub const g2d_format_G2D_RGBA8888: g2d_format = 1;
pub const g2d_format_G2D_RGBX8888: g2d_format = 2;
pub const g2d_format_G2D_BGRA8888: g2d_format = 3;
pub const g2d_format_G2D_BGRX8888: g2d_format = 4;
pub const g2d_format_G2D_BGR565: g2d_format = 5;
pub const g2d_format_G2D_ARGB8888: g2d_format = 6;
pub const g2d_format_G2D_ABGR8888: g2d_format = 7;
pub const g2d_format_G2D_XRGB8888: g2d_format = 8;
pub const g2d_format_G2D_XBGR8888: g2d_format = 9;
pub const g2d_format_G2D_RGB888: g2d_format = 10;
pub const g2d_format_G2D_BGR888: g2d_format = 11;
pub const g2d_format_G2D_RGBA5551: g2d_format = 12;
pub const g2d_format_G2D_RGBX5551: g2d_format = 13;
pub const g2d_format_G2D_BGRA5551: g2d_format = 14;
pub const g2d_format_G2D_BGRX5551: g2d_format = 15;
pub const g2d_format_G2D_RGBA1010102: g2d_format = 16;
pub const g2d_format_G2D_GRAY10: g2d_format = 18;
pub const g2d_format_G2D_GRAY8: g2d_format = 19;
pub const g2d_format_G2D_NV12: g2d_format = 20;
pub const g2d_format_G2D_I420: g2d_format = 21;
pub const g2d_format_G2D_YV12: g2d_format = 22;
pub const g2d_format_G2D_NV21: g2d_format = 23;
pub const g2d_format_G2D_YUYV: g2d_format = 24;
pub const g2d_format_G2D_YVYU: g2d_format = 25;
pub const g2d_format_G2D_UYVY: g2d_format = 26;
pub const g2d_format_G2D_VYUY: g2d_format = 27;
pub const g2d_format_G2D_NV16: g2d_format = 28;
pub const g2d_format_G2D_NV61: g2d_format = 29;
pub type g2d_format = ::std::os::raw::c_uint;
pub const g2d_blend_func_G2D_ZERO: g2d_blend_func = 0;
pub const g2d_blend_func_G2D_ONE: g2d_blend_func = 1;
pub const g2d_blend_func_G2D_SRC_ALPHA: g2d_blend_func = 2;
pub const g2d_blend_func_G2D_ONE_MINUS_SRC_ALPHA: g2d_blend_func = 3;
pub const g2d_blend_func_G2D_DST_ALPHA: g2d_blend_func = 4;
pub const g2d_blend_func_G2D_ONE_MINUS_DST_ALPHA: g2d_blend_func = 5;
pub const g2d_blend_func_G2D_PRE_MULTIPLIED_ALPHA: g2d_blend_func = 16;
pub const g2d_blend_func_G2D_DEMULTIPLY_OUT_ALPHA: g2d_blend_func = 32;
pub type g2d_blend_func = ::std::os::raw::c_uint;
pub const g2d_cap_mode_G2D_BLEND: g2d_cap_mode = 0;
pub const g2d_cap_mode_G2D_DITHER: g2d_cap_mode = 1;
pub const g2d_cap_mode_G2D_GLOBAL_ALPHA: g2d_cap_mode = 2;
pub const g2d_cap_mode_G2D_BLEND_DIM: g2d_cap_mode = 3;
pub const g2d_cap_mode_G2D_BLUR: g2d_cap_mode = 4;
pub const g2d_cap_mode_G2D_YUV_BT_601: g2d_cap_mode = 5;
pub const g2d_cap_mode_G2D_YUV_BT_709: g2d_cap_mode = 6;
pub const g2d_cap_mode_G2D_YUV_BT_601FR: g2d_cap_mode = 7;
pub const g2d_cap_mode_G2D_YUV_BT_709FR: g2d_cap_mode = 8;
pub const g2d_cap_mode_G2D_WARPING: g2d_cap_mode = 9;
pub type g2d_cap_mode = ::std::os::raw::c_uint;
pub const g2d_feature_G2D_SCALING: g2d_feature = 0;
pub const g2d_feature_G2D_ROTATION: g2d_feature = 1;
pub const g2d_feature_G2D_SRC_YUV: g2d_feature = 2;
pub const g2d_feature_G2D_DST_YUV: g2d_feature = 3;
pub const g2d_feature_G2D_MULTI_SOURCE_BLT: g2d_feature = 4;
pub const g2d_feature_G2D_FAST_CLEAR: g2d_feature = 5;
pub const g2d_feature_G2D_WARP_DEWARP: g2d_feature = 6;
pub type g2d_feature = ::std::os::raw::c_uint;
pub const g2d_rotation_G2D_ROTATION_0: g2d_rotation = 0;
pub const g2d_rotation_G2D_ROTATION_90: g2d_rotation = 1;
pub const g2d_rotation_G2D_ROTATION_180: g2d_rotation = 2;
pub const g2d_rotation_G2D_ROTATION_270: g2d_rotation = 3;
pub const g2d_rotation_G2D_FLIP_H: g2d_rotation = 4;
pub const g2d_rotation_G2D_FLIP_V: g2d_rotation = 5;
pub type g2d_rotation = ::std::os::raw::c_uint;
pub const g2d_cache_mode_G2D_CACHE_CLEAN: g2d_cache_mode = 0;
pub const g2d_cache_mode_G2D_CACHE_FLUSH: g2d_cache_mode = 1;
pub const g2d_cache_mode_G2D_CACHE_INVALIDATE: g2d_cache_mode = 2;
pub type g2d_cache_mode = ::std::os::raw::c_uint;
pub const g2d_hardware_type_G2D_HARDWARE_2D: g2d_hardware_type = 0;
pub const g2d_hardware_type_G2D_HARDWARE_VG: g2d_hardware_type = 1;
pub const g2d_hardware_type_G2D_HARDWARE_DPU_V1: g2d_hardware_type = 2;
pub const g2d_hardware_type_G2D_HARDWARE_DPU_V2: g2d_hardware_type = 3;
pub const g2d_hardware_type_G2D_HARDWARE_PXP_V1: g2d_hardware_type = 4;
pub const g2d_hardware_type_G2D_HARDWARE_PXP_V2: g2d_hardware_type = 5;
pub type g2d_hardware_type = ::std::os::raw::c_uint;
pub const g2d_status_G2D_STATUS_FAIL: g2d_status = -1;
pub const g2d_status_G2D_STATUS_OK: g2d_status = 0;
pub const g2d_status_G2D_STATUS_NOT_SUPPORTED: g2d_status = 1;
pub type g2d_status = ::std::os::raw::c_int;
pub type g2d_phys_addr_t = ::std::os::raw::c_ulong;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct g2d_surface {
pub format: g2d_format,
pub planes: [g2d_phys_addr_t; 3usize],
pub left: ::std::os::raw::c_int,
pub top: ::std::os::raw::c_int,
pub right: ::std::os::raw::c_int,
pub bottom: ::std::os::raw::c_int,
#[doc = "< buffer stride, in Pixels"]
pub stride: ::std::os::raw::c_int,
#[doc = "< surface width, in Pixels"]
pub width: ::std::os::raw::c_int,
#[doc = "< surface height, in Pixels"]
pub height: ::std::os::raw::c_int,
#[doc = "< alpha blending parameters"]
pub blendfunc: g2d_blend_func,
#[doc = "< value is 0 ~ 255"]
pub global_alpha: ::std::os::raw::c_int,
pub clrcolor: ::std::os::raw::c_int,
pub rot: g2d_rotation,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct g2d_surface_pair {
pub s: g2d_surface,
pub d: g2d_surface,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct g2d_buf {
pub buf_handle: *mut ::std::os::raw::c_void,
pub buf_vaddr: *mut ::std::os::raw::c_void,
pub buf_paddr: g2d_phys_addr_t,
pub buf_size: ::std::os::raw::c_int,
}
#[derive(Debug)]
pub struct g2d {
__library: ::libloading::Library,
pub g2d_open: Result<
unsafe extern "C" fn(handle: *mut *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_close: Result<
unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_make_current: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
type_: g2d_hardware_type,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_clear: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
area: *mut g2d_surface,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_blit: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
src: *mut g2d_surface,
dst: *mut g2d_surface,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_copy: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
d: *mut g2d_buf,
s: *mut g2d_buf,
size: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_multi_blit: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
sp: *mut *mut g2d_surface_pair,
layers: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_query_hardware: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
type_: g2d_hardware_type,
available: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_query_feature: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
feature: g2d_feature,
available: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_query_cap: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
cap: g2d_cap_mode,
enable: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_enable: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
cap: g2d_cap_mode,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_disable: Result<
unsafe extern "C" fn(
handle: *mut ::std::os::raw::c_void,
cap: g2d_cap_mode,
) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_cache_op: Result<
unsafe extern "C" fn(buf: *mut g2d_buf, op: g2d_cache_mode) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_alloc: Result<
unsafe extern "C" fn(
size: ::std::os::raw::c_int,
cacheable: ::std::os::raw::c_int,
) -> *mut g2d_buf,
::libloading::Error,
>,
pub g2d_free: Result<
unsafe extern "C" fn(buf: *mut g2d_buf) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_flush: Result<
unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
::libloading::Error,
>,
pub g2d_finish: Result<
unsafe extern "C" fn(handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int,
::libloading::Error,
>,
}
impl g2d {
pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
where
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
Self::from_library(library)
}
pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
where
L: Into<::libloading::Library>,
{
let __library = library.into();
let g2d_open = __library.get(b"g2d_open\0").map(|sym| *sym);
let g2d_close = __library.get(b"g2d_close\0").map(|sym| *sym);
let g2d_make_current = __library.get(b"g2d_make_current\0").map(|sym| *sym);
let g2d_clear = __library.get(b"g2d_clear\0").map(|sym| *sym);
let g2d_blit = __library.get(b"g2d_blit\0").map(|sym| *sym);
let g2d_copy = __library.get(b"g2d_copy\0").map(|sym| *sym);
let g2d_multi_blit = __library.get(b"g2d_multi_blit\0").map(|sym| *sym);
let g2d_query_hardware = __library.get(b"g2d_query_hardware\0").map(|sym| *sym);
let g2d_query_feature = __library.get(b"g2d_query_feature\0").map(|sym| *sym);
let g2d_query_cap = __library.get(b"g2d_query_cap\0").map(|sym| *sym);
let g2d_enable = __library.get(b"g2d_enable\0").map(|sym| *sym);
let g2d_disable = __library.get(b"g2d_disable\0").map(|sym| *sym);
let g2d_cache_op = __library.get(b"g2d_cache_op\0").map(|sym| *sym);
let g2d_alloc = __library.get(b"g2d_alloc\0").map(|sym| *sym);
let g2d_free = __library.get(b"g2d_free\0").map(|sym| *sym);
let g2d_flush = __library.get(b"g2d_flush\0").map(|sym| *sym);
let g2d_finish = __library.get(b"g2d_finish\0").map(|sym| *sym);
Ok(g2d {
__library,
g2d_open,
g2d_close,
g2d_make_current,
g2d_clear,
g2d_blit,
g2d_copy,
g2d_multi_blit,
g2d_query_hardware,
g2d_query_feature,
g2d_query_cap,
g2d_enable,
g2d_disable,
g2d_cache_op,
g2d_alloc,
g2d_free,
g2d_flush,
g2d_finish,
})
}
pub unsafe fn g2d_open(
&self,
handle: *mut *mut ::std::os::raw::c_void,
) -> ::std::os::raw::c_int {
(self
.g2d_open
.as_ref()
.expect("Expected function, got error."))(handle)
}
pub unsafe fn g2d_close(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
(self
.g2d_close
.as_ref()
.expect("Expected function, got error."))(handle)
}
pub unsafe fn g2d_make_current(
&self,
handle: *mut ::std::os::raw::c_void,
type_: g2d_hardware_type,
) -> ::std::os::raw::c_int {
(self
.g2d_make_current
.as_ref()
.expect("Expected function, got error."))(handle, type_)
}
pub unsafe fn g2d_clear(
&self,
handle: *mut ::std::os::raw::c_void,
area: *mut g2d_surface,
) -> ::std::os::raw::c_int {
(self
.g2d_clear
.as_ref()
.expect("Expected function, got error."))(handle, area)
}
pub unsafe fn g2d_blit(
&self,
handle: *mut ::std::os::raw::c_void,
src: *mut g2d_surface,
dst: *mut g2d_surface,
) -> ::std::os::raw::c_int {
(self
.g2d_blit
.as_ref()
.expect("Expected function, got error."))(handle, src, dst)
}
pub unsafe fn g2d_copy(
&self,
handle: *mut ::std::os::raw::c_void,
d: *mut g2d_buf,
s: *mut g2d_buf,
size: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
(self
.g2d_copy
.as_ref()
.expect("Expected function, got error."))(handle, d, s, size)
}
pub unsafe fn g2d_multi_blit(
&self,
handle: *mut ::std::os::raw::c_void,
sp: *mut *mut g2d_surface_pair,
layers: ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
(self
.g2d_multi_blit
.as_ref()
.expect("Expected function, got error."))(handle, sp, layers)
}
pub unsafe fn g2d_query_hardware(
&self,
handle: *mut ::std::os::raw::c_void,
type_: g2d_hardware_type,
available: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
(self
.g2d_query_hardware
.as_ref()
.expect("Expected function, got error."))(handle, type_, available)
}
pub unsafe fn g2d_query_feature(
&self,
handle: *mut ::std::os::raw::c_void,
feature: g2d_feature,
available: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
(self
.g2d_query_feature
.as_ref()
.expect("Expected function, got error."))(handle, feature, available)
}
pub unsafe fn g2d_query_cap(
&self,
handle: *mut ::std::os::raw::c_void,
cap: g2d_cap_mode,
enable: *mut ::std::os::raw::c_int,
) -> ::std::os::raw::c_int {
(self
.g2d_query_cap
.as_ref()
.expect("Expected function, got error."))(handle, cap, enable)
}
pub unsafe fn g2d_enable(
&self,
handle: *mut ::std::os::raw::c_void,
cap: g2d_cap_mode,
) -> ::std::os::raw::c_int {
(self
.g2d_enable
.as_ref()
.expect("Expected function, got error."))(handle, cap)
}
pub unsafe fn g2d_disable(
&self,
handle: *mut ::std::os::raw::c_void,
cap: g2d_cap_mode,
) -> ::std::os::raw::c_int {
(self
.g2d_disable
.as_ref()
.expect("Expected function, got error."))(handle, cap)
}
pub unsafe fn g2d_cache_op(
&self,
buf: *mut g2d_buf,
op: g2d_cache_mode,
) -> ::std::os::raw::c_int {
(self
.g2d_cache_op
.as_ref()
.expect("Expected function, got error."))(buf, op)
}
pub unsafe fn g2d_alloc(
&self,
size: ::std::os::raw::c_int,
cacheable: ::std::os::raw::c_int,
) -> *mut g2d_buf {
(self
.g2d_alloc
.as_ref()
.expect("Expected function, got error."))(size, cacheable)
}
pub unsafe fn g2d_free(&self, buf: *mut g2d_buf) -> ::std::os::raw::c_int {
(self
.g2d_free
.as_ref()
.expect("Expected function, got error."))(buf)
}
pub unsafe fn g2d_flush(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
(self
.g2d_flush
.as_ref()
.expect("Expected function, got error."))(handle)
}
pub unsafe fn g2d_finish(&self, handle: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
(self
.g2d_finish
.as_ref()
.expect("Expected function, got error."))(handle)
}
}