diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index 39eb09315f1966fd014b9e50d8220cb145a6eac9..9af1f846e4142f039d389909342289d35fb94bb2 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,21 @@ 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. + * @param res Indicates whether the the two regions are equal. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of from, to or res is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RegionEquals(OH_Drawing_Region* from, OH_Drawing_Region* to, bool* res); + /** * @brief Determines whether the region contains the specified coordinates. * @@ -102,6 +118,38 @@ 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 region Indicates the pointer to an OH_Drawing_Region object. + * @param rect Indicates the pointer to an OH_Drawing_Rect object. + * @param res Indicates whether the the region is equal contains the rect. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of region, rect or res is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RegionQuickContains(OH_Drawing_Region* region, + const OH_Drawing_Rect* rect, bool* res); + +/** + * @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. + * @param res Indicates whether the rectangle does not intersect with the region. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of region, other or res is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RegionQuickRejectWithRegion(OH_Drawing_Region* region, + const OH_Drawing_Region* other, bool* res); + /** * @brief Combines two regions. * @@ -115,6 +163,39 @@ 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 other Indicates the pointer to an OH_Drawing_Region object. + * @param op Indicates the operation to apply to combine. + * @param res Indicates whether the region is not empty. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if any of region, rect, other or res is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RegionOpWithRect(OH_Drawing_Region* region, const OH_Drawing_Rect* rect, + const OH_Drawing_Region* other, OH_Drawing_RegionOpMode op, bool* res); + +/** + * @brief Get the external rect with the smallest region. + * + * @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. + * @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 +221,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 dx, int32_t dy, 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..a9c7fe57dcb8c66f2393cde8d0caab3c2a853592 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_RegionEquals" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionQuickContains" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionQuickRejectWithRegion" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionOpWithRect" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionGetBounds" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RegionTranslate" + }, { "first_introduced": "12", "name": "OH_Drawing_SetTypographyTextFontFamily"