From 5dad1352a645ea4cfbced49191652561393a505d Mon Sep 17 00:00:00 2001 From: dreamyhhh Date: Fri, 27 Jun 2025 17:58:14 +0800 Subject: [PATCH] add new ndk Signed-off-by: dreamyhhh --- .../native_drawing/drawing_canvas.h | 21 +++++++++++++++++++ .../native_drawing/drawing_image_filter.h | 18 ++++++++++++++++ .../native_drawing/drawing_sampling_options.h | 11 ++++++++++ .../native_drawing/drawing_shader_effect.h | 18 ++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 16 ++++++++++++++ 5 files changed, 84 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 8f515031b25..02f3f5b8d93 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -271,6 +271,27 @@ OH_Drawing_ErrorCode OH_Drawing_CanvasDrawPixelMapNine(OH_Drawing_Canvas* canvas void OH_Drawing_CanvasDrawPixelMapRect(OH_Drawing_Canvas* canvas, OH_Drawing_PixelMap* pixelMap, const OH_Drawing_Rect* src, const OH_Drawing_Rect* dst, const OH_Drawing_SamplingOptions* samplingOptions); +/** + * @brief Draw the specified area of the Media::PixelMap to the specified area of the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param pixelMap Indicates the pointer to an OH_Drawing_PixelMap object. + * @param src Indicates the area of source pixelmap. + * @param dst Indicates the area of destination canvas. + * @param samplingOptions Indicates the sampling mode. + * @param constraint Indicates constraint type. + * @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 canvas, pixelMap + * and dst is nullptr. + * @since 20 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_CanvasDrawPixelMapRectConstraint(OH_Drawing_Canvas* canvas, + OH_Drawing_PixelMap* pixelMap, const OH_Drawing_Rect* src, const OH_Drawing_Rect* dst, + const OH_Drawing_SamplingOptions* samplingOptions, OH_Drawing_SrcRectConstraint constraint); + /** * @brief Fills clipped canvas area with brush. * diff --git a/graphic/graphic_2d/native_drawing/drawing_image_filter.h b/graphic/graphic_2d/native_drawing/drawing_image_filter.h index 44c566b90f0..51b46b41eaf 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 tileMode, OH_Drawing_ImageFilter* imageFilter); +/** + * @brief Creates an OH_Drawing_ImageFilter object that blurs its input by the separate x and y sigmas. + * Supports an optional crop rectangle to restrict the blur effect to a specific region of the input. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param sigmaX Indicates the Gaussian sigma value for blurring along the x axis. + * @param sigmaY Indicates the Gaussian sigma value for blurring along the y axis. + * @param tileMode Indicates the tile mode applied at edges. + * @param input Indicates the input filter that is blurred, uses source bitmap if this is null. + * @param rect Indicates optional rectangle that crops the input and output. + * If rect is null, the blur effect applies to the entire input image. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 20 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlurWithCrop(float sigmaX, float sigmaY, + OH_Drawing_TileMode tileMode, OH_Drawing_ImageFilter* input, const OH_Drawing_Rect* rect); + /** * @brief Creates an OH_Drawing_ImageFilter object that applies the color filter to the input. * diff --git a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h index 12a90a08797..793bc52d8c2 100644 --- a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h +++ b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h @@ -87,6 +87,17 @@ typedef enum { OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode filterMode, OH_Drawing_MipmapMode mipmapMode); +/** + * @brief Creates an OH_Drawing_SamplingOptions copy object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param samplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object. + * @return Returns the pointer to the OH_Drawing_SamplingOptions object created. + * @since 20 + * @version 1.0 + */ +OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCopy(OH_Drawing_SamplingOptions* samplingOptions); + /** * @brief Destroys an OH_Drawing_SamplingOptions object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h index df43af96cfe..b3d37ffd3a3 100644 --- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h @@ -221,6 +221,24 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Ima OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY, const OH_Drawing_SamplingOptions* samplingOptions, const OH_Drawing_Matrix* matrix); +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates a pixel map shader. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param pixelMap Indicates the pointer to an OH_Drawing_PixelMap object. + * @param tileX Indicates the horizontal tile mode. + * @param tileY Indicates the vertical tile mode. + * @param samplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object. It cannot be null. + * @param matrix Indicates the pointer to an OH_Drawing_Matrix object. + * If matrix is nullptr, defaults to the identity matrix. + * @return Returns the pointer to the OH_Drawing_ShaderEffect object created. + * @since 20 + * @version 1.0 + */ +OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreatePixelMapShader(OH_Drawing_PixelMap* pixelMap, + OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY, const OH_Drawing_SamplingOptions* samplingOptions, + const OH_Drawing_Matrix* matrix); + /** * @brief Creates an OH_Drawing_ShaderEffect that generates a conical gradient given two circles. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 2ea2b4a7e29..67e70630228 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -96,6 +96,10 @@ "first_introduced": "12", "name": "OH_Drawing_CanvasDrawPixelMapRect" }, + { + "first_introduced": "20", + "name": "OH_Drawing_CanvasDrawPixelMapRectConstraint" + }, { "first_introduced": "12", "name": "OH_Drawing_CanvasDrawPoints" @@ -378,6 +382,10 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateBlur" }, + { + "first_introduced": "20", + "name": "OH_Drawing_ImageFilterCreateBlurWithCrop" + }, { "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateFromColorFilter" @@ -811,6 +819,10 @@ "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateImageShader" }, + { + "first_introduced": "20", + "name": "OH_Drawing_ShaderEffectCreatePixelMapShader" + }, { "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateTwoPointConicalGradient" @@ -921,6 +933,10 @@ "name": "OH_Drawing_ImageGetImageInfo" }, { "name": "OH_Drawing_SamplingOptionsCreate" }, + { + "first_introduced": "20", + "name": "OH_Drawing_SamplingOptionsCopy" + }, { "name": "OH_Drawing_SamplingOptionsDestroy" }, { "first_introduced": "12", -- Gitee