From a3edf4864bb38f9fe7878f0b78ea51f18b18471c Mon Sep 17 00:00:00 2001 From: dreamyhhh Date: Tue, 3 Jun 2025 10:18:44 +0800 Subject: [PATCH 1/3] add drawing ndk interfaces Signed-off-by: dreamyhhh --- .../native_drawing/drawing_canvas.h | 19 ++++++++++++++++++- .../native_drawing/drawing_image_filter.h | 19 ++++++++++++++++++- .../native_drawing/drawing_sampling_options.h | 14 +++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 10824c04c8f..b0be244d5a8 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -271,6 +271,23 @@ 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); +// todo modify +/** + * @brief Draw the specified area of the Media::PixelMap to the specified area of the canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_PixelMap Indicates the pointer to an OH_Drawing_PixelMap object. + * @param src the area of source pixelmap. + * @param dst the area of destination canvas. + * @param OH_Drawing_SamplingOptions the sampling mode. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_CanvasDrawPixelMapRectConstraint(OH_Drawing_Canvas*, OH_Drawing_PixelMap*, + const OH_Drawing_Rect* src, const OH_Drawing_Rect* dst, const OH_Drawing_SamplingOptions*, + OH_Drawing_SrcRectConstraint); + /** * @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 a67f2353193..abf80521df7 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_image_filter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -63,6 +63,23 @@ extern "C" { OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sigmaY, OH_Drawing_TileMode tileMode, OH_Drawing_ImageFilter* imageFilter); +// todo modify +/** + * @brief Creates an OH_Drawing_ImageFilter object that blurs its input by the separate x and y sigmas. + * + * @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 OH_Drawing_TileMode Indicates the tile mode applied at edges. + * @param OH_Drawing_ImageFilter Indicates the input filter that is blurred, uses source bitmap if this is null. + * @param OH_Drawing_Rect Indicates the input filter that is blurred, uses source bitmap if this is null. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlurWithCrop(float sigmaX, float sigmaY, OH_Drawing_TileMode, + OH_Drawing_ImageFilter*, const OH_Drawing_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..6d88e75c466 100644 --- a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h +++ b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -87,6 +87,18 @@ typedef enum { OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMode filterMode, OH_Drawing_MipmapMode mipmapMode); +// todo modify +/** + * @brief Creates an OH_Drawing_SamplingOptions copy object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_SamplingOptions sIndicates the pointer to an OH_Drawing_SamplingOptions object. + * @return Returns the pointer to the OH_Drawing_SamplingOptions object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCreate(OH_Drawing_SamplingOptions*); + /** * @brief Destroys an OH_Drawing_SamplingOptions object and reclaims the memory occupied by the object. * -- Gitee From e857833f7290f0ce1b6a3b88ee4c04989f72c065 Mon Sep 17 00:00:00 2001 From: dreamyhhh Date: Tue, 3 Jun 2025 11:02:56 +0800 Subject: [PATCH 2/3] add drawing ndk interfaces Signed-off-by: dreamyhhh --- .../native_drawing/drawing_sampling_options.h | 2 +- .../native_drawing/libnative_drawing.ndk.json | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h index 6d88e75c466..a8f83cdec27 100644 --- a/graphic/graphic_2d/native_drawing/drawing_sampling_options.h +++ b/graphic/graphic_2d/native_drawing/drawing_sampling_options.h @@ -97,7 +97,7 @@ OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCreate(OH_Drawing_FilterMo * @since 12 * @version 1.0 */ -OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCreate(OH_Drawing_SamplingOptions*); +OH_Drawing_SamplingOptions* OH_Drawing_SamplingOptionsCopy(OH_Drawing_SamplingOptions*); /** * @brief Destroys an OH_Drawing_SamplingOptions 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 cd1b53c1f7b..8ca1dd7ffef 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -76,6 +76,10 @@ "first_introduced": "12", "name": "OH_Drawing_CanvasDrawPixelMapRect" }, + { + "first_introduced": "20", + "name": "OH_Drawing_CanvasDrawPixelMapRectConstraint" + }, { "first_introduced": "12", "name": "OH_Drawing_CanvasDrawPoints" @@ -358,6 +362,10 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateBlur" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageFilterCreateBlurWithCrop" + }, { "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateFromColorFilter" @@ -869,6 +877,10 @@ "name": "OH_Drawing_ImageGetImageInfo" }, { "name": "OH_Drawing_SamplingOptionsCreate" }, + { + "first_introduced": "20", + "name": "OH_Drawing_SamplingOptionsCopy" + }, { "name": "OH_Drawing_SamplingOptionsDestroy" }, { "first_introduced": "12", -- Gitee From 8d1574cf5b78ef870108fd3e6b791b27b8a8171f Mon Sep 17 00:00:00 2001 From: dreamyhhh Date: Tue, 3 Jun 2025 11:23:37 +0800 Subject: [PATCH 3/3] add drawing ndk interfaces Signed-off-by: dreamyhhh --- graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 8ca1dd7ffef..bf9b8c17c2e 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -363,7 +363,7 @@ "name": "OH_Drawing_ImageFilterCreateBlur" }, { - "first_introduced": "12", + "first_introduced": "20", "name": "OH_Drawing_ImageFilterCreateBlurWithCrop" }, { -- Gitee