From 670e03bd149ac057b46fcb5df0bce5771c7335b6 Mon Sep 17 00:00:00 2001 From: liuwei Date: Tue, 29 Oct 2024 14:53:29 +0800 Subject: [PATCH] drawing interface RectF upload Signed-off-by: liuwei Change-Id: Ib5d97fb38ed96ab51526674fde8ad76555ab6b97 --- .../graphic_2d/native_drawing/drawing_rect.h | 74 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 20 +++++ 2 files changed, 94 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h index e07abff68..9ba6b89dc 100644 --- a/graphic/graphic_2d/native_drawing/drawing_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_rect.h @@ -40,6 +40,7 @@ * @version 1.0 */ +#include "drawing_error_code.h" #include "drawing_types.h" #ifdef __cplusplus @@ -72,6 +73,20 @@ OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float */ bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other); +/** + * @brief Gets whether the rectangle is empty. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rect Indicates the pointer to an OH_Drawing_Rect object. + * @param isEmpty Indicates the result of function. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rect or isEmpty is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectIsEmpty(const OH_Drawing_Rect* rect, bool* isEmpty); + /** * @brief Sets rect to the union of rect and other. * @@ -204,6 +219,65 @@ float OH_Drawing_RectGetWidth(OH_Drawing_Rect*); */ void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst); +/** +* @brief Sets the dst integer Rect by rounding this rectangle's coordinates to their nearest integer values. +* +* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing +* @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 rect is nullptr. +* @since 14 +* @version 1.0 +*/ +OH_Drawing_ErrorCode OH_Drawing_RectRound(OH_Drawing_Rect* rect); + +/** +* @brief Sets the dst integer Rect by rounding "out" this rectangle, +* choosing the floor of top and left, and the ceiling of right and bottom. +* +* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing +* @param sRect Indicates the pointer to an OH_Drawing_Rect object. +* @param dRect 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 sRect or dRect is nullptr. +* @since 14 +* @version 1.0 +*/ +OH_Drawing_ErrorCode OH_Drawing_RectRoundOut(OH_Drawing_Rect* sRect, OH_Drawing_Rect* dRect); + +/** + * @brief Offsets the rectangle by adding dx to its left and right coordinates, + * and adding dy to its top and bottom coordinates. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param rect Indicates the pointer to an OH_Drawing_Rect object. + * @param dx Indicates the amount to add to the rectangle's left and right coordinates. + * @param dy Indicates the amount to add to the rectangle's top and bottom coordinates. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rect is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectOffset(OH_Drawing_Rect* rect, float dx, float dy); + +/** + * @brief Swaps the rectangle left and right if the left is greater than right; + * and swaps the rectangle top and bottom if the top is greater than bottom. + * If the edges are already correct, then nothing is done. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @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 rect is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_RectSort(OH_Drawing_Rect* rect); + /** * @brief Destroys an OH_Drawing_Rect 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 e81640a3f..3f9016c43 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -559,10 +559,18 @@ "first_introduced": "12", "name": "OH_Drawing_RectIntersect" }, + { + "first_introduced": "14", + "name": "OH_Drawing_RectIsEmpty" + }, { "first_introduced": "12", "name": "OH_Drawing_RectJoin" }, + { + "first_introduced": "14", + "name": "OH_Drawing_RectSort" + }, { "first_introduced": "12", "name": "OH_Drawing_RectSetLeft" @@ -607,6 +615,18 @@ "first_introduced": "12", "name": "OH_Drawing_RectCopy" }, + { + "first_introduced": "14", + "name": "OH_Drawing_RectRound" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RectRoundOut" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_RectOffset" + }, { "name": "OH_Drawing_RectDestroy" }, { "name": "OH_Drawing_RoundRectCreate" }, { -- Gitee