Skip to content

Commit

Permalink
drawing: Update bindings to API-13
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Jan 8, 2025
1 parent 6365999 commit 93be4c1
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 3 deletions.
5 changes: 5 additions & 0 deletions components/drawing/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v0.2.1 (2025-01-08)

- Update bindings for API-13


## v0.2.0 (2025-01-04)

- Internal changes to binding generation
Expand Down
4 changes: 3 additions & 1 deletion components/drawing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ohos-drawing-sys"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
description = "Bindings to the `native_drawing` API of OpenHarmony OS"
license = "Apache-2.0"
Expand All @@ -25,6 +25,8 @@ api-10 = []
api-11 = ["api-10"]
## Bindings for OpenHarmony API-level 12.
api-12 = ["api-11"]
## Bindings for OpenHarmony API-level 13.
api-13 = ["api-12"]
## Document available features when building the documentation
document-features = ["dep:document-features"]

Expand Down
25 changes: 25 additions & 0 deletions components/drawing/src/canvas/canvas_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1282,4 +1282,29 @@ extern "C" {
canvas: *mut OH_Drawing_Canvas,
imageInfo: *mut OH_Drawing_Image_Info,
) -> OH_Drawing_ErrorCode;
/// Replay drawing command.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `canvas` - Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
///
/// `recordCmd` - Indicates the pointer to an <b>OH_Drawing_RecordCmd</b> object.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if canvas or recordCmd is nullptr.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_CanvasDrawRecordCmd(
canvas: *mut OH_Drawing_Canvas,
recordCmd: *mut OH_Drawing_RecordCmd,
) -> OH_Drawing_ErrorCode;
}
11 changes: 11 additions & 0 deletions components/drawing/src/error_code/error_code_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ impl OH_Drawing_ErrorCode {
pub const OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE: OH_Drawing_ErrorCode =
OH_Drawing_ErrorCode(26200001);
}
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl OH_Drawing_ErrorCode {
/// mem allocate failed.
///
/// Available since API-level: 13
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub const OH_DRAWING_ERROR_ALLOCATION_FAILED: OH_Drawing_ErrorCode =
OH_Drawing_ErrorCode(26200002);
}
#[repr(transparent)]
/// Enumerates error codes of drawing.
///
Expand Down
4 changes: 4 additions & 0 deletions components/drawing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ pub mod shadow_layer;
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
pub mod surface;

#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub mod record_cmd;
3 changes: 3 additions & 0 deletions components/drawing/src/record_cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#[allow(unused_imports)]
mod record_cmd_ffi;
pub use record_cmd_ffi::*;
131 changes: 131 additions & 0 deletions components/drawing/src/record_cmd/record_cmd_ffi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// automatically generated by rust-bindgen 0.71.1

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

#[allow(unused_imports)]
#[cfg(feature = "api-12")]
use crate::error_code::OH_Drawing_ErrorCode;

extern "C" {
/// Creates an <b>OH_Drawing_RecordCmdUtils</b> object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
///
/// # Returns
///
/// Returns the pointer to the <b>OH_Drawing_RecordCmdUtils</b> object created.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_RecordCmdUtilsCreate() -> *mut OH_Drawing_RecordCmdUtils;
/// Destroys an <b>OH_Drawing_RecordCmdUtils</b> object and reclaims the memory occupied by the object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `recordCmdUtils` - Indicates the pointer to an <b>OH_Drawing_RecordCmdUtils</b> object.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if recordCmdUtils is nullptr.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_RecordCmdUtilsDestroy(
recordCmdUtils: *mut OH_Drawing_RecordCmdUtils,
) -> OH_Drawing_ErrorCode;
/// Get the canvas that records the drawing command.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `recordCmdUtils` - Indicates the pointer to an <b>OH_Drawing_RecordCmdUtils</b> object.
///
/// `width` - Width of canvas object.
///
/// `height` - Height of canvas object.
///
/// `canvas` - Indicates a secondary pointer to an <b>OH_Drawing_Canvas</b>object.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if recordCmdUtils or canvas is nullptr,
/// width less than or equal to 0 or height less than or equal to 0.
/// Returns [`OH_DRAWING_ERROR_ALLOCATION_FAILED`] if no memory.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_RecordCmdUtilsBeginRecording(
recordCmdUtils: *mut OH_Drawing_RecordCmdUtils,
width: i32,
height: i32,
canvas: *mut *mut OH_Drawing_Canvas,
) -> OH_Drawing_ErrorCode;
/// Finish the recording and get the recording command object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `recordCmdUtils` - Indicates the pointer to an <b>OH_Drawing_RecordCmdUtils</b> object.
///
/// `recordCmd` - Indicates a secondary pointer to an <b>OH_Drawing_RecordCmd</b> object.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if recordCmdUtils or recordCmd is nullptr.
/// Returns [`OH_DRAWING_ERROR_ALLOCATION_FAILED`] if no memory.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_RecordCmdUtilsFinishRecording(
recordCmdUtils: *mut OH_Drawing_RecordCmdUtils,
recordCmd: *mut *mut OH_Drawing_RecordCmd,
) -> OH_Drawing_ErrorCode;
/// Destroys an <b>OH_Drawing_RecordCmd</b> object and reclaims the memory occupied by the object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `recordCmd` - Indicates the pointer to an <b>OH_Drawing_RecordCmd</b> object.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if recordCmd is nullptr.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_RecordCmdDestroy(
recordCmd: *mut OH_Drawing_RecordCmd,
) -> OH_Drawing_ErrorCode;
}
21 changes: 21 additions & 0 deletions components/drawing/src/text_typography/text_typography_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,27 @@ extern "C" {
///
/// Version: 1.1
pub fn OH_Drawing_TypographyGetLongestLine(arg1: *mut OH_Drawing_Typography) -> f64;
/// Obtains the width of the longest line with indent. You are advised to
/// round up the return value in actual use. When the text content is empty, the
/// minimum float value, that is, 0.0, is returned.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `OH_Drawing_Typography` - Pointer to an <b>OH_Drawing_Typography</b> object, which is obtained by
/// [`OH_Drawing_CreateTypography`].
///
/// # Returns
///
/// Returns the width of the longest line with indent.
///
/// Available since API-level: 13
///
/// Version: 1.1
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_TypographyGetLongestLineWithIndent(arg1: *mut OH_Drawing_Typography) -> f64;
/// Gets the min intrinsic width.
///
///
Expand Down
129 changes: 127 additions & 2 deletions components/drawing/src/typeface/typeface_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_Drawing_TypefaceCreateDefault() -> *mut OH_Drawing_Typeface;
/// Creates a <b>OH_Drawing_Typeface</b> object by file.
/// Creates an <b>OH_Drawing_Typeface</b> object by file.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
Expand All @@ -48,7 +48,64 @@ extern "C" {
path: *const ::core::ffi::c_char,
index: ::core::ffi::c_int,
) -> *mut OH_Drawing_Typeface;
/// Creates a <b>OH_Drawing_Typeface</b> object by given a stream. If the stream is not a valid
/// Creates an <b>OH_Drawing_Typeface</b> object with the specified font arguments from a file.
/// If the <b>OH_Drawing_Typeface</b> object does not support the variations described in fontArguments,
/// this function creates an <b>OH_Drawing_Typeface</b> object without font arguments.
/// In this case, this function provides the same capability as [`OH_Drawing_TypefaceCreateFromFile`].
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `path` - Indicates the file path.
///
/// `fontArguments` - Indicates the pointer to an <b>OH_Drawing_FontArguments</b> object.
///
/// # Returns
///
/// Returns the pointer to the <b>OH_Drawing_Typeface</b> object created.
/// If nullptr is returned, the creation fails.
/// The possible cause of the failure is that the available memory is empty,
/// or either path or fontArguments is nullptr, or the path is invalid.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_TypefaceCreateFromFileWithArguments(
path: *const ::core::ffi::c_char,
fontArguments: *const OH_Drawing_FontArguments,
) -> *mut OH_Drawing_Typeface;
/// Creates an <b>OH_Drawing_Typeface</b> object with the specified font arguments from
/// an existing <b>OH_Drawing_Typeface</b> object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `current` - Indicates the existing <b>OH_Drawing_Typeface</b> object.
///
/// `fontArguments` - Indicates the pointer to an <b>OH_Drawing_FontArguments</b> object.
///
/// # Returns
///
/// Returns the pointer to the <b>OH_Drawing_Typeface</b> object created.
/// If nullptr is returned, the creation fails.
/// The possible cause of the failure is that the available memory is empty,
/// or either current or fontArguments is nullptr,
/// or current does not support the variations described in fontArguments.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_TypefaceCreateFromCurrent(
current: *const OH_Drawing_Typeface,
fontArguments: *const OH_Drawing_FontArguments,
) -> *mut OH_Drawing_Typeface;
/// Creates an <b>OH_Drawing_Typeface</b> object by given a stream. If the stream is not a valid
/// font file, returns nullptr. Ownership of the stream is transferred, so the caller must not reference
/// it or free it again.
///
Expand Down Expand Up @@ -87,4 +144,72 @@ extern "C" {
#[cfg(feature = "api-11")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
pub fn OH_Drawing_TypefaceDestroy(arg1: *mut OH_Drawing_Typeface);
/// Creates an <b>OH_Drawing_FontArguments</b> object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
///
/// # Returns
///
/// Returns the pointer to the <b>OH_Drawing_FontArguments</b> object created.
/// If nullptr is returned, the creation fails.
/// The possible cause of the failure is that the available memory is empty.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_FontArgumentsCreate() -> *mut OH_Drawing_FontArguments;
/// Adds a font variation axis for an <b>OH_Drawing_FontArguments</b> object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `fontArguments` - Indicates the pointer to an <b>OH_Drawing_FontArguments</b> object.
///
/// `axis` - Indicates the axis tag, which must contain four ASCII characters.
///
/// `value` - Indicates the value of the axis field.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if either fontArguments or axis is nullptr,
/// or the length of axis is not 4.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_FontArgumentsAddVariation(
fontArguments: *mut OH_Drawing_FontArguments,
axis: *const ::core::ffi::c_char,
value: f32,
) -> OH_Drawing_ErrorCode;
/// Destroys an <b>OH_Drawing_FontArguments</b> object and reclaims the memory occupied by the object.
///
///
/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
/// # Arguments
///
/// `fontArguments` - Indicates the pointer to an <b>OH_Drawing_FontArguments</b> object.
///
/// # Returns
///
/// Returns the error code.
/// Returns [`OH_DRAWING_SUCCESS`] if the operation is successful.
/// Returns [`OH_DRAWING_ERROR_INVALID_PARAMETER`] if fontArguments is nullptr.
///
/// Available since API-level: 13
///
/// Version: 1.0
#[cfg(feature = "api-13")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-13")))]
pub fn OH_Drawing_FontArgumentsDestroy(
fontArguments: *mut OH_Drawing_FontArguments,
) -> OH_Drawing_ErrorCode;
}
Loading

0 comments on commit 93be4c1

Please sign in to comment.