Skip to content

Commit

Permalink
Add drawing API-12 new modules
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Jul 17, 2024
1 parent 2514d12 commit e440e1f
Show file tree
Hide file tree
Showing 27 changed files with 790 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ done
DRAWING_font_collection_ADDITIONAL_ARGS=("--raw-line=use crate::drawing::text_declaration::*;")
DRAWING_text_typography_ADDITIONAL_ARGS=("--raw-line=use crate::drawing::text_declaration::*;" )
DRAWING_register_font_ADDITIONAL_ARGS=("--raw-line=use crate::drawing::text_declaration::*;" )
DRAWING_image_filter_ADDITIONAL_ARGS=("--raw-line=use crate::drawing::shader_effect::*;")
DRAWING_font_mgr_ADDITIONAL_ARGS=("--raw-line=use crate::drawing::text_typography::*;" )

for abs_drawing_header in "${OHOS_SYSROOT_DIR}/usr/include/native_drawing"/* ; do
drawing_header=$(basename "${abs_drawing_header}")
Expand Down
25 changes: 25 additions & 0 deletions src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,28 @@ pub mod shader_effect;
pub mod text_blob;
#[cfg(feature = "api-11")]
pub mod typeface;

#[cfg(feature = "api-12")]
pub mod color_space;
#[cfg(feature = "api-12")]
pub mod error_code;
#[cfg(feature = "api-12")]
pub mod font_mgr;
#[cfg(feature = "api-12")]
pub mod gpu_context;
#[cfg(feature = "api-12")]
pub mod image;
#[cfg(feature = "api-12")]
pub mod image_filter;
#[cfg(feature = "api-12")]
pub mod memory_stream;
#[cfg(feature = "api-12")]
pub mod path_effect;
#[cfg(feature = "api-12")]
pub mod pixel_map;
#[cfg(feature = "api-12")]
pub mod sampling_options;
#[cfg(feature = "api-12")]
pub mod shadow_layer;
#[cfg(feature = "api-12")]
pub mod surface;
2 changes: 2 additions & 0 deletions src/drawing/color_space.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod color_space_api12;
pub use color_space_api12::*;
30 changes: 30 additions & 0 deletions src/drawing/color_space/color_space_api12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* automatically generated by rust-bindgen 0.69.4 */

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::drawing::types::*;

extern "C" {
/** @brief Creates an <b>OH_Drawing_ColorSpace</b> object that represents the SRGB color space.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@return Returns the pointer to the <b>OH_Drawing_ColorSpace</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_ColorSpaceCreateSrgb() -> *mut OH_Drawing_ColorSpace;
/** @brief Creates an <b>OH_Drawing_ColorSpace</b> object with the SRGB primaries, but a linear (1.0) gamma.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@return Returns the pointer to the <b>OH_Drawing_ColorSpace</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_ColorSpaceCreateSrgbLinear() -> *mut OH_Drawing_ColorSpace;
/** @brief Destroy an <b>OH_Drawing_ColorSpace</b> object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_ColorSpace Indicates the pointer to an <b>OH_Drawing_ColorSpace</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_ColorSpaceDestroy(arg1: *mut OH_Drawing_ColorSpace);
}
3 changes: 3 additions & 0 deletions src/drawing/error_code.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#[allow(unused_imports)]
mod error_code_api12;
pub use error_code_api12::*;
38 changes: 38 additions & 0 deletions src/drawing/error_code/error_code_api12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* automatically generated by rust-bindgen 0.69.4 */

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::drawing::types::*;

impl OH_Drawing_ErrorCode {
/// @error Operation completed successfully.
pub const OH_DRAWING_SUCCESS: OH_Drawing_ErrorCode = OH_Drawing_ErrorCode(0);
}
impl OH_Drawing_ErrorCode {
/// @error Permission verification failed.
pub const OH_DRAWING_ERROR_NO_PERMISSION: OH_Drawing_ErrorCode = OH_Drawing_ErrorCode(201);
}
impl OH_Drawing_ErrorCode {
/// @error Invalid input parameter. For example, the pointer in the parameter is a nullptr.
pub const OH_DRAWING_ERROR_INVALID_PARAMETER: OH_Drawing_ErrorCode = OH_Drawing_ErrorCode(401);
}
impl OH_Drawing_ErrorCode {
/// @error The parameter is not in the valid range.
pub const OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE: OH_Drawing_ErrorCode =
OH_Drawing_ErrorCode(26200001);
}
#[repr(transparent)]
/** @brief Enumerates error codes of drawing.
@since 12*/
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct OH_Drawing_ErrorCode(pub ::core::ffi::c_uint);
extern "C" {
/** @brief Obtains the error code of the drawing module.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@return Returns the error code.
@since 12
@version 1.0*/
pub fn OH_Drawing_ErrorCodeGet() -> OH_Drawing_ErrorCode;
}
2 changes: 2 additions & 0 deletions src/drawing/font_mgr.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod font_mgr_api12;
pub use font_mgr_api12::*;
169 changes: 169 additions & 0 deletions src/drawing/font_mgr/font_mgr_api12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/* automatically generated by rust-bindgen 0.69.4 */

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::drawing::text_typography::*;
use crate::drawing::types::*;

extern "C" {
/** @brief Creates an <b>OH_Drawing_FontMgr</b> object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@return Returns the pointer to the <b>OH_Drawing_FontMgr</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrCreate() -> *mut OH_Drawing_FontMgr;
/** @brief Releases the memory occupied by an <b>OH_Drawing_FontMgr</b> object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrDestroy(arg1: *mut OH_Drawing_FontMgr);
/** @brief Gets the count of font families.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@return Returns the count of font families.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrGetFamilyCount(arg1: *mut OH_Drawing_FontMgr) -> ::core::ffi::c_int;
/** @brief Gets the font family name by the index.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@param index Indicates the index to get the font family name.
@return Returns the font family name corresponding to the index value.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrGetFamilyName(
arg1: *mut OH_Drawing_FontMgr,
index: ::core::ffi::c_int,
) -> *mut ::core::ffi::c_char;
/** @brief Releases the memory occupied by font family name.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param familyName Indicates the font family name.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrDestroyFamilyName(familyName: *mut ::core::ffi::c_char);
/** @brief Creates an <b>OH_Drawing_FontStyleSet</b> object by <b>OH_Drawing_FontMgr</b> object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@param index Indicates the index used to get the font style set object from the font manager object.
@return Returns the pointer to the <b>OH_Drawing_FontStyleSet</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrCreateFontStyleSet(
arg1: *mut OH_Drawing_FontMgr,
index: ::core::ffi::c_int,
) -> *mut OH_Drawing_FontStyleSet;
/** @brief Releases the memory occupied by an <b>OH_Drawing_FontStyleSet</b> object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrDestroyFontStyleSet(arg1: *mut OH_Drawing_FontStyleSet);
/** @brief Get the pointer to an <b>OH_Drawing_FontStyleSet</b> object for the given font style set family name.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@param familyName Indicates the family name of a font style set to be matched.
@return Returns the pointer to the <b>OH_Drawing_FontStyleSet</b> object matched.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrMatchFamily(
arg1: *mut OH_Drawing_FontMgr,
familyName: *const ::core::ffi::c_char,
) -> *mut OH_Drawing_FontStyleSet;
/** @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object based on the given font style and family name.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@param familyName Indicates the family name of a font style set to be matched.
@param OH_Drawing_FontStyleStruct Indicates an <b>OH_Drawing_FontStyleStruct</b> object.
@return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrMatchFamilyStyle(
arg1: *mut OH_Drawing_FontMgr,
familyName: *const ::core::ffi::c_char,
fontStyle: OH_Drawing_FontStyleStruct,
) -> *mut OH_Drawing_Typeface;
/** @brief Get the pointer to an <b>OH_Drawing_Typeface</b> object for the given character.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontMgr Indicates the pointer to an <b>OH_Drawing_FontMgr</b> object.
@param familyName Indicates the family name of a font style set to be matched.
@param OH_Drawing_FontStyleStruct Indicates an <b>OH_Drawing_FontStyleStruct</b> object.
@param bcp47 Indicates an array of languages which indicate the language of character.
@param bcp47Count Indicates the array size of bcp47.
@param character Indicates a UTF8 value to be matched.
@return Returns the pointer to the <b>OH_Drawing_Typeface</b> object matched.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontMgrMatchFamilyStyleCharacter(
arg1: *mut OH_Drawing_FontMgr,
familyName: *const ::core::ffi::c_char,
fontStyle: OH_Drawing_FontStyleStruct,
bcp47: *mut *const ::core::ffi::c_char,
bcp47Count: ::core::ffi::c_int,
character: i32,
) -> *mut OH_Drawing_Typeface;
/** @brief Create a typeface for the given index.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
@param index Indicates the index of the typeface in this fontStyleSet.
@return If successful, return a pointer to <b>OH_Drawing_Typeface</b> object; if failed, return nullptr.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontStyleSetCreateTypeface(
arg1: *mut OH_Drawing_FontStyleSet,
index: ::core::ffi::c_int,
) -> *mut OH_Drawing_Typeface;
/** @brief Get font style for the specified typeface.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
@param index Indicates the index of the typeface in this fontStyleSet.
@param styleName Indicates the style name returned.
@return Return the <b>OH_Drawing_FontStyleStruct<b> structure.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontStyleSetGetStyle(
arg1: *mut OH_Drawing_FontStyleSet,
index: i32,
styleName: *mut *mut ::core::ffi::c_char,
) -> OH_Drawing_FontStyleStruct;
/** @brief Releases the memory styleName string.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param styleName Indicates the pointer to a string type.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontStyleSetFreeStyleName(styleName: *mut *mut ::core::ffi::c_char);
/** @brief Get the closest matching typeface.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
@param fontStyleStruct Indicates the <b>OH_Drawing_FontStyleStruct</b> structure.
@return A pointer to matched <b>OH_Drawing_Typeface</b>.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontStyleSetMatchStyle(
arg1: *mut OH_Drawing_FontStyleSet,
fontStyleStruct: OH_Drawing_FontStyleStruct,
) -> *mut OH_Drawing_Typeface;
/** @brief Get the count of typeface.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_FontStyleSet Indicates the pointer to an <b>OH_Drawing_FontStyleSet</b> object.
@return The count of typeface in this font style set.
@since 12
@version 1.0*/
pub fn OH_Drawing_FontStyleSetCount(arg1: *mut OH_Drawing_FontStyleSet) -> ::core::ffi::c_int;
}
2 changes: 2 additions & 0 deletions src/drawing/gpu_context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod gpu_context_api12;
pub use gpu_context_api12::*;
36 changes: 36 additions & 0 deletions src/drawing/gpu_context/gpu_context_api12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* automatically generated by rust-bindgen 0.69.4 */

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::drawing::types::*;

/** @brief Defines the options about GPU context.
@since 12
@version 1.0*/
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct OH_Drawing_GpuContextOptions {
/// If true this allows path mask textures to be cached
pub allowPathMaskCaching: bool,
}
extern "C" {
/** @brief Creates an <b>OH_Drawing_GpuContext</b> object, whose GPU backend context is GL.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_GpuContextOptions Indicates the GPU context options.
@return Returns the pointer to the <b>OH_Drawing_GpuContext</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_GpuContextCreateFromGL(
arg1: OH_Drawing_GpuContextOptions,
) -> *mut OH_Drawing_GpuContext;
/** @brief Destroys an <b>OH_Drawing_GpuContext</b> object and reclaims the memory occupied by the object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_GpuContext Indicates the pointer to an <b>OH_Drawing_GpuContext</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_GpuContextDestroy(arg1: *mut OH_Drawing_GpuContext);
}
2 changes: 2 additions & 0 deletions src/drawing/image.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod image_api12;
pub use image_api12::*;
62 changes: 62 additions & 0 deletions src/drawing/image/image_api12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/* automatically generated by rust-bindgen 0.69.4 */

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::drawing::types::*;

extern "C" {
/** @brief Creates an <b>OH_Drawing_Image</b> object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@return Returns the pointer to the <b>OH_Drawing_Image</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_ImageCreate() -> *mut OH_Drawing_Image;
/** @brief Destroys an <b>OH_Drawing_Image</b> object and reclaims the memory occupied by the object.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Image Indicates the pointer to an <b>OH_Drawing_Image</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_ImageDestroy(arg1: *mut OH_Drawing_Image);
/** @brief Rebuilds an <b>OH_Drawing_Image</b> object, sharing or copying bitmap pixels.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Image Indicates the pointer to an <b>OH_Drawing_Image</b> object.
@param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object.
@return Returns true if successed.
@since 12
@version 1.0*/
pub fn OH_Drawing_ImageBuildFromBitmap(
arg1: *mut OH_Drawing_Image,
arg2: *mut OH_Drawing_Bitmap,
) -> bool;
/** @brief Gets pixel count in each row of image.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Image Indicates the pointer to an <b>OH_Drawing_Image</b> object.
@return Returns the width.
@since 12
@version 1.0*/
pub fn OH_Drawing_ImageGetWidth(arg1: *mut OH_Drawing_Image) -> i32;
/** @brief Gets pixel row count of image.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Image Indicates the pointer to an <b>OH_Drawing_Image</b> object.
@return Returns the height.
@since 12
@version 1.0*/
pub fn OH_Drawing_ImageGetHeight(arg1: *mut OH_Drawing_Image) -> i32;
/** @brief Gets the image info.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Image Indicates the pointer to an <b>OH_Drawing_Image</b> object.
@param OH_Drawing_Image_Info Indicates the pointer to an <b>OH_Drawing_Image_Info</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_ImageGetImageInfo(
arg1: *mut OH_Drawing_Image,
arg2: *mut OH_Drawing_Image_Info,
);
}
2 changes: 2 additions & 0 deletions src/drawing/image_filter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod image_filter_api12;
pub use image_filter_api12::*;
Loading

0 comments on commit e440e1f

Please sign in to comment.