From db23e0a266b522989259848a48e9e533f878ae4b Mon Sep 17 00:00:00 2001 From: yejianlin Date: Sat, 12 Oct 2024 19:03:34 +0800 Subject: [PATCH] matrix ndk Signed-off-by: yejianlin Change-Id: I8e07fe539a6a8cfa944ddcec656b630f6bc3f5b6 --- .../native_drawing/drawing_matrix.h | 81 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 12 +++ 2 files changed, 93 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index f56827d85..eb5dc2d69 100644 --- a/graphic/graphic_2d/native_drawing/drawing_matrix.h +++ b/graphic/graphic_2d/native_drawing/drawing_matrix.h @@ -226,6 +226,40 @@ void OH_Drawing_MatrixPreRotate(OH_Drawing_Matrix*, float degree, float px, floa */ void OH_Drawing_MatrixPreScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py); +/** + * @brief Sets Matrix to Matrix multiplied by Matrix constructed from skewing by (kx, ky) + * about a pivot point at (px, py). + * Given: + * + * | A B C | | 1 kx dx | + * Matrix =| D E F |, K(kx, ky, px, py) = | ky 1 dy | + * | G H I | | 0 0 1 | + * + * where: + * + * dx = -kx * py + * dy = -ky * px + * + * sets Matrix to: + * + * | A B C | | 1 kx dx | | A+B*ky A*kx+B A*dx+B*dy+C | + * Matrix * K(kx, ky, px, py) = | D E F | | ky 1 dy | = | D+E*ky D*kx+E D*dx+E*dy+F | + * | G H I | | 0 0 1 | | G+H*ky G*kx+H G*dx+H*dy+I | + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cMatrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param kx Horizontal skew factor. + * @param ky Vertical skew factor. + * @param px Pivot on x-axis. + * @param py Pivot on y-axis. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if matrix is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixPreSkew(OH_Drawing_Matrix* cMatrix, float kx, float ky, float px, float py); + /** * @brief Sets forward matrix to translate by dx and dy. * Given: @@ -303,6 +337,37 @@ void OH_Drawing_MatrixPostRotate(OH_Drawing_Matrix*, float degree, float px, flo */ void OH_Drawing_MatrixPostScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py); +/** + * @brief Sets Matrix to Matrix constructed from skewing by (kx, ky) about pivot point + * (px, py), multiplied by Matrix. + * Given: + * + * | J K L | | 1 kx dx | + * Matrix =| M N O |, K(kx, ky, px, py) = | ky 1 dy | + * | P Q R | | 0 0 1 | + * + * where: + * + * dx = -kx * py + * dy = -ky * px + * + * sets Matrix to: + * + * | 1 kx dx| |J K L| |J+kx*M+dx*P K+kx*N+dx*Q L+kx*O+dx+R| + * K(kx, ky, px, py) * Matrix = |ky 1 dy| |M N O| = |ky*J+M+dy*P ky*K+N+dy*Q ky*L+O+dy*R| + * | 0 0 1| |P Q R| | P Q R| + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cMatrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param kx Horizontal skew factor. + * @param ky Vertical skew factor. + * @param px Pivot on x-axis. + * @param py Pivot on y-axis. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixPostSkew(OH_Drawing_Matrix* cMatrix, float kx, float ky, float px, float py); + /** * @brief Sets backward matrix to translate by (dx, dy). * Given: @@ -467,6 +532,22 @@ bool OH_Drawing_MatrixSetPolyToPoly(OH_Drawing_Matrix*, const OH_Drawing_Point2D void OH_Drawing_MatrixMapPoints(const OH_Drawing_Matrix*, const OH_Drawing_Point2D* src, OH_Drawing_Point2D* dst, int count); +/** + * @brief A circle with radius radius is constructed using the matrix mapping, and the average radius is returned. + * The result squared is equal to the major axis length times the minor axis length. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cMatrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param radius Indicates the pointer to radius of a circle. + * @param radiusDst Average mapped radius. + * @return Returns the error code. + * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. + * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if matrix or radiusDst is nullptr. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_MatrixMapRadius(const OH_Drawing_Matrix* cMatrix, float radius, float* radiusDst); + /** * @brief Sets dst to bounds of src corners mapped by matrix transformation. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 3f0f7905b..b727dd956 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -316,6 +316,10 @@ "first_introduced": "12", "name": "OH_Drawing_MatrixMapPoints" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixMapRadius" + }, { "first_introduced": "12", "name": "OH_Drawing_MatrixMapRect" @@ -333,6 +337,10 @@ "first_introduced": "12", "name": "OH_Drawing_MatrixPreScale" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixPreSkew" + }, { "first_introduced": "12", "name": "OH_Drawing_MatrixPreRotate" @@ -345,6 +353,10 @@ "first_introduced": "12", "name": "OH_Drawing_MatrixPostScale" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MatrixPostSkew" + }, { "first_introduced": "12", "name": "OH_Drawing_MatrixPostRotate" -- Gitee