From e0865a803680d49a85254748c8dc69ae721e23ca Mon Sep 17 00:00:00 2001 From: wangwei Date: Tue, 22 Oct 2024 14:40:04 +0800 Subject: [PATCH] ww_region_interface Signed-off-by: wangwei Change-Id: I7dc659e3453941e7bb3a315607824f3fab99e7e1 --- .../native_drawing/drawing_region.h | 98 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 24 +++++ 2 files changed, 122 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index 39eb09315..9af1f846e 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 3f0f7905b..a9c7fe57d 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" -- Gitee