From af02084df308fed17b901f354ffc85f8fa874dc7 Mon Sep 17 00:00:00 2001 From: liuwei793 Date: Mon, 14 Oct 2024 17:21:15 +0800 Subject: [PATCH] =?UTF-8?q?matrix=E6=96=B0=E5=A2=9Endk=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liuwei793 Change-Id: Ib29d63fb6f276880a701ac10549f4d60beec054a --- .../native_drawing/drawing_matrix.h | 70 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 16 +++++ 2 files changed, 86 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index f56827d85..35959efc9 100644 --- a/graphic/graphic_2d/native_drawing/drawing_matrix.h +++ b/graphic/graphic_2d/native_drawing/drawing_matrix.h @@ -164,6 +164,44 @@ typedef enum { bool OH_Drawing_MatrixSetRectToRect(OH_Drawing_Matrix*, const OH_Drawing_Rect* src, const OH_Drawing_Rect* dst, OH_Drawing_ScaleToFit stf); +/** + * @brief Sets the transformation matrix to rotate around a specified point (px, py) using the given specified sine and + * cosine. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param sinValue Indicates the sine of the angle of rotation. + * @param cosValue Indicates the cosine of the angle of rotation. + * @param px Indicates the x-coordinate of the point around which to rotate. + * @param py Indicates the y-coordinate of the point around which to rotate. + * @return Returns an error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the cMatrix is nullptr. + * + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixSetSinCos( + OH_Drawing_Matrix* cMatrix, float sinValue, float cosValue, float px, float py); + +/** + * @brief Sets the transformation matrix to apply the given tilt factor (kx, ky) at the specified point (px, py). + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cMatrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param kx Indicates the skew factor in the x direction. + * @param ky Indicates the skew factor in the y direction. + * @param px Indicates the x-coordinate of the point around which to skew. + * @param py Indicates the y-coordinate of the point around which to skew. + * @return Returns an error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the cMatrix is nullptr. + * + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixSetSkew(OH_Drawing_Matrix* cMatrix, float kx, float ky, float px, float py); + /** * @brief Sets matrix to matrix multiplied by matrix constructed from rotating by degrees * about pivot point(px, py), positive degrees rotates clockwise. @@ -326,6 +364,22 @@ void OH_Drawing_MatrixPostScale(OH_Drawing_Matrix*, float sx, float sy, float px */ void OH_Drawing_MatrixPostTranslate(OH_Drawing_Matrix*, float dx, float dy); +/** + * @brief Determines whether a rectangle will be mapped to another rectangle after the specified matrix transformation. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cMatrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param mapping Indicates a pointer to a boolean variable that will be set to true if the rectangle will map + * to another rectangle, or false otherwise. + * @return Returns an error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the cMatrix or mapping is nullptr. + * + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixRectStaysRect(const OH_Drawing_Matrix* cMatrix, bool* mapping); + /** * @brief Reset matrix to identity, which has no effect on mapped point, sets matrix to: * | 1 0 0 | @@ -480,6 +534,22 @@ void OH_Drawing_MatrixMapPoints(const OH_Drawing_Matrix*, const OH_Drawing_Point */ bool OH_Drawing_MatrixMapRect(const OH_Drawing_Matrix*, const OH_Drawing_Rect* src, OH_Drawing_Rect* dst); +/** + * @brief Determines whether the specified transformation matrix is an affine transformation. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cMatrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param affine Indicates a pointer to a boolean variable that will be set to true if the matrix is affine, + * or false otherwise. + * @return Returns an error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if the cMatrix is or affine is nullptr. + * + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixIsAffine(const OH_Drawing_Matrix* cMatrix, bool* affine); + /** * @brief Returns true if the first matrix equals the second matrix. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index e81640a3f..f23d6275b 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -325,6 +325,18 @@ "first_introduced": "12", "name": "OH_Drawing_MatrixSetRectToRect" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixSetSinCos" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixSetSkew" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixRectStaysRect" + }, { "first_introduced": "12", "name": "OH_Drawing_MatrixReset" @@ -363,6 +375,10 @@ "name": "OH_Drawing_MatrixSetPolyToPoly" }, { "name": "OH_Drawing_MatrixInvert" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixIsAffine" + }, { "name": "OH_Drawing_MatrixIsEqual" }, { "name": "OH_Drawing_MatrixIsIdentity" }, { "name": "OH_Drawing_MatrixDestroy" }, -- Gitee