From c891527664bab0c9e31b8b59ecd96c37806c30bb Mon Sep 17 00:00:00 2001 From: zhanglin Date: Mon, 11 Nov 2024 14:53:26 +0800 Subject: [PATCH] add_interface_ndk2 Signed-off-by: zhanglin Change-Id: Idec46579c00effc053f92bcf7b6c9427c3eee586 --- .../native_drawing/drawing_color_filter.h | 13 +++ .../native_drawing/drawing_image_filter.h | 95 +++++++++++++++++++ .../native_drawing/drawing_mask_filter.h | 34 +++++++ .../native_drawing/drawing_matrix.h | 70 ++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 56 +++++++++++ 5 files changed, 268 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_color_filter.h b/graphic/graphic_2d/native_drawing/drawing_color_filter.h index 98907ba17..3b37b5573 100644 --- a/graphic/graphic_2d/native_drawing/drawing_color_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_color_filter.h @@ -113,6 +113,19 @@ OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateSrgbGammaToLinear(void); */ OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateLuma(void); +/** + * @brief Creates an OH_Drawing_ColorFilter with the given mutColor used to multiply source color and addColor + * used to add to source color. The Alpha channel will not be affected. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param mulColor Indicates the color, which is a 32-bit (ARGB) variable. + * @param addColor Indicates the color, which is a 32-bit (ARGB) variable. + * @return Returns the pointer to the OH_Drawing_ColorFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreateLighting(uint32_t mulColor, uint32_t addColor); + /** * @brief Destroys an OH_Drawing_ColorFilter object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_image_filter.h b/graphic/graphic_2d/native_drawing/drawing_image_filter.h index d77292aa3..c3760dc71 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_image_filter.h @@ -63,6 +63,24 @@ extern "C" { OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sigmaY, OH_Drawing_TileMode, OH_Drawing_ImageFilter*); +/** + * @brief Creates OH_Drawing_ImageFilter object that combines the "inner" and "outer", so that the result + * of the "inner" is considered as a source bitmap passed to the "outer". + * + * This API generates an error code, you can view the value of the error code by using {@link OH_Drawing_ErrorCodeGet}. + * Returns OH_DRAWING_SUCCESS when the execution is successful; + * When either cOuter or cInner is null, OH_DRAWING_ERROR_INVALID_PARAMETER is returned. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cOuter Indicates the instance to apply its effects to the output of the 'inner' filter. + * @param cInner Indicates the output as input for "outer" filters. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateComposeImageFilter( + OH_Drawing_ImageFilter* cOuter, OH_Drawing_ImageFilter* cInner); + /** * @brief Creates an OH_Drawing_ImageFilter object that applies the color filter to the input. * @@ -78,6 +96,83 @@ OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sig */ OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromColorFilter(OH_Drawing_ColorFilter*, OH_Drawing_ImageFilter*); +/** + * @brief Creates an OH_Drawing_ImageFilter object that instance with the provided x and y offset. + * + * This API generates an error code, you can view the value of the error code by using {@link OH_Drawing_ErrorCodeGet}. + * Returns OH_DRAWING_SUCCESS when the execution is successful. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param dx Indicates the offset in the X direction. + * @param dy Indicates the offset in the Y direction. + * @param cInput Indicates the input image filter used to generate offset effects, or uses the source bitmap if this is + * null. + * @param cCropRect Indicates the rectangular object that defines the area to which the layer is applied. if the + * rectangle is null, the entire image will be processed. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateOffsetImageFilter( + float dx, float dy, OH_Drawing_ImageFilter* cInput, OH_Drawing_Rect* cCropRect); + +/** + * @brief Creates an OH_Drawing_ImageFilter object that renders the contents of the input Shader. + * + * This API generates an error code, you can view the value of the error code by using {@link OH_Drawing_ErrorCodeGet}. + * Returns OH_DRAWING_SUCCESS when the execution is successful; + * Returns OH_DRAWING_ERROR_INVALID_PARAMETER when cShader is null. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cShader Indicates the shader effect to be applied to the image. + * @param cCropRect Indicates the rectangular object that defines the area to which the layer is applied. if the + * rectangle is null, the entire image will be processed. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateShaderImageFilter( + OH_Drawing_ShaderEffect* cShader, OH_Drawing_Rect* cCropRect); + +/** + * @brief Creates an OH_Drawing_ImageFilter object that applies the bitmap to the input. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cBitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromBitmap(const OH_Drawing_Bitmap* cBitmap); + +/** + * @brief Creates an OH_Drawing_ImageFilter object that applies the bitmap with rect to the input. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cBitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param cSrcRect Indicates the pointer to a src rect object. + * @param cDstRect Indicates the pointer to a dst rect object. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromBitmapWithRect( + const OH_Drawing_Bitmap* cBitmap, const OH_Drawing_Rect* cSrcRect, const OH_Drawing_Rect* cDstRect); + +/** + * @brief Creates an OH_Drawing_ImageFilter object that applies the blend to the input. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cBlendMode Indicates the pointer to an OH_Drawing_BlendMode object. + * @param cBackground Indicates the background filter. + * @param cForeground Indicates the foreground filter. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromBlend( + OH_Drawing_BlendMode* cBlendMode, OH_Drawing_ImageFilter* cBackground, OH_Drawing_ImageFilter* cForeground); + /** * @brief Destroys an OH_Drawing_ImageFilter object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_mask_filter.h b/graphic/graphic_2d/native_drawing/drawing_mask_filter.h index 86f487bfe..ec500225a 100644 --- a/graphic/graphic_2d/native_drawing/drawing_mask_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_mask_filter.h @@ -84,6 +84,40 @@ typedef enum { */ OH_Drawing_MaskFilter* OH_Drawing_MaskFilterCreateBlur(OH_Drawing_BlurType blurType, float sigma, bool respectCTM); +/** + * @brief Creates an OH_Drawing_MaskFilter with a table effect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param table Indicates a lookup table is applied to each alpha value in the mask. table.length must be = 256. + * @return Returns the pointer to the OH_Drawing_MaskFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_MaskFilter* OH_Drawing_MaskFilterCreateTable(uint8_t table[256]); + +/** + * @brief Creates an OH_Drawing_MaskFilter with a clip table effect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param min Indicates the minimum value used for comparison with the clipping table. + * @param max Indicates the maximum value used for comparison with the clipping table. + * @return Returns the pointer to the OH_Drawing_MaskFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_MaskFilter* OH_Drawing_MaskFilterCreateClipTable(uint8_t min, uint8_t max); + +/** + * @brief Creates an OH_Drawing_MaskFilter with a gamma table effect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param gamma Indicates the gamma value used for comparison with the gamma table. + * @return Returns the pointer to the OH_Drawing_MaskFilter object created. + * @since 14 + * @version 1.0 + */ +OH_Drawing_MaskFilter* OH_Drawing_MaskFilterCreateGammaTable(float gamma); + /** * @brief Destroys an OH_Drawing_MaskFilter object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index f56827d85..f96915eda 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 cMatrix 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 353ce3f53..3f6f64ce3 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -157,6 +157,10 @@ { "name": "OH_Drawing_ColorFilterCreateCompose" }, { "name": "OH_Drawing_ColorFilterCreateLinearToSrgbGamma" }, { "name": "OH_Drawing_ColorFilterCreateLuma" }, + { + "first_introduced": "14", + "name": "OH_Drawing_ColorFilterCreateLighting" + }, { "name": "OH_Drawing_ColorFilterCreateMatrix" }, { "name": "OH_Drawing_ColorFilterCreateSrgbGammaToLinear" }, { "name": "OH_Drawing_ColorFilterDestroy" }, @@ -298,6 +302,22 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateBlur" }, + { + "first_introduced": "14", + "name": "OH_Drawing_ImageFilterCreateFromBitmap" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_ImageFilterCreateFromBitmapWithRect" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_ImageFilterCreateFromBlend" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_ImageFilterCreateComposeImageFilter" + }, { "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateFromColorFilter" @@ -306,7 +326,27 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterDestroy" }, + { + "first_introduced": "14", + "name": "OH_Drawing_ImageFilterCreateOffsetImageFilter" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_ImageFilterCreateShaderImageFilter" + }, { "name": "OH_Drawing_MaskFilterCreateBlur" }, + { + "first_introduced": "14", + "name": "OH_Drawing_MaskFilterCreateTable" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_MaskFilterCreateClipTable" + }, + { + "first_introduced": "14", + "name": "OH_Drawing_MaskFilterCreateGammaTable" + }, { "name": "OH_Drawing_MaskFilterDestroy" }, { "name": "OH_Drawing_MatrixCreate" }, { "name": "OH_Drawing_MatrixCreateRotation" }, @@ -325,6 +365,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 +415,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