diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index 39eb09315f1966fd014b9e50d8220cb145a6eac9..ad141febe27629bf818bef8d7e26a4133ae39669 100644 --- a/graphic/graphic_2d/native_drawing/drawing_region.h +++ b/graphic/graphic_2d/native_drawing/drawing_region.h @@ -40,6 +40,7 @@ * @version 1.0 */ +#include "drawing_error_code.h" #include "drawing_types.h" #ifdef __cplusplus @@ -89,6 +90,18 @@ typedef enum { */ OH_Drawing_Region* OH_Drawing_RegionCreate(void); +/** + * @brief Overriding the class Region equals operator. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param from Indicates source of comparison object. + * @param to Indicates comparison object. + * @return Returns compare result. + * @since 14 + * @version 1.0 + */ +bool OH_Drawing_RegionEquals(OH_Drawing_Region* from, OH_Drawing_Region* to); + /** * @brief Determines whether the region contains the specified coordinates. * @@ -102,6 +115,31 @@ OH_Drawing_Region* OH_Drawing_RegionCreate(void); */ bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y); +/** + * @brief Determines whether the region contains the rect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object. + * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @return Returns true if the region is a rect and contains the rect; returns false otherwise. + * @since 14 + * @version 1.0 + */ +bool OH_Drawing_RegionQuickContains(OH_Drawing_Region* region, const OH_Drawing_Rect* rect); + +/** + * @brief Determines whether two regions does not intersect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param other Indicates the pointer to an OH_Drawing_Region object. + * @return Returns true if the region is empty, or not intersect; returns false otherwise. + * @since 14 + * @version 1.0 + */ +bool OH_Drawing_RegionQuickReject(OH_Drawing_Region* region, const OH_Drawing_Region* other); + + /** * @brief Combines two regions. * @@ -115,6 +153,36 @@ bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y); */ bool OH_Drawing_RegionOp(OH_Drawing_Region* region, const OH_Drawing_Region* other, OH_Drawing_RegionOpMode op); +/** + * @brief Combines regions and rect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param rect Indicates the pointer to an OH_Drawing_Rect object. + * @param dst Indicates the pointer to an OH_Drawing_Region object. + * @param op Indicates the operation to apply to combine. + * @return Returns true if constructed region is not empty; returns false otherwise. + * @since 14 + * @version 1.0 + */ +bool OH_Drawing_RegionOpWithRect(OH_Drawing_Region* region, const OH_Drawing_Rect* rect, + const OH_Drawing_Region* dst, OH_Drawing_RegionOpMode op); + +/** + * @brief Get the external rect with the smallest region. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object. + * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if region or rect is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RegionGetBounds(OH_Drawing_Region* region, OH_Drawing_Rect* rect); + + /** * @brief Sets the region to the specified rect. * @@ -140,6 +208,23 @@ bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, const OH_Drawing_Rect* */ bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* path, const OH_Drawing_Region* clip); +/** + * @brief Translates by dx along the x-axis and dy along the y-axis, and assign the result to the dst region. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param dx Indicates the distance to translate on x-axis. + * @param dy Indicates the distance to translate on y-axis. + * @param dst Indicates the pointer to an OH_Drawing_Region object. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if region or dst is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RegionTranslate(OH_Drawing_Region* region, + int32_t x, int32_t y, OH_Drawing_Region* dst); + /** * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 3f0f7905b62de328131d4b4575952e30497f76c1..9edc86c6bd0f0deba9c8bffdc8a0c9955c7fa172 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1154,6 +1154,30 @@ "first_introduced": "12", "name": "OH_Drawing_RegionSetRect" }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionTranslate" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionEquals" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionQuickContains" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionQuickReject" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionOpWithRect" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionGetBounds" + }, { "first_introduced": "12", "name": "OH_Drawing_SetTypographyTextFontFamily"