From 9834c97e2a9debadaec771b39a0119c05bf7f93a Mon Sep 17 00:00:00 2001 From: ustc-tianyu Date: Wed, 2 Apr 2025 18:59:44 +0800 Subject: [PATCH] =?UTF-8?q?C=5Fdraiwnginterface=20=20=20=20=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=20Signed-off-by:=20Lixiaoxiang=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../native_drawing/drawing_color_filter.h | 13 +++++++ .../native_drawing/drawing_image_filter.h | 29 +++++++++++++++ .../native_drawing/drawing_shader_effect.h | 35 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 20 +++++++++++ 4 files changed, 97 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_color_filter.h b/graphic/graphic_2d/native_drawing/drawing_color_filter.h index 051ef91bd..bfad30b6b 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 20 + * @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 3fde3b724..90d1f21f2 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_image_filter.h @@ -79,6 +79,35 @@ OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sig OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromColorFilter(OH_Drawing_ColorFilter* colorFilter, OH_Drawing_ImageFilter* imageFilter); +/** + * @brief Creates an OH_Drawing_ImageFilter object with the provided x and y offset. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param x Indicates the x offset. + * @param y Indicates the y offset. + * @param imageFilter Indicates the input filter, or uses the source bitmap if this is null. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty. + * @since 20 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateOffset(float x, float y, OH_Drawing_ImageFilter* imageFilter); + +/** + * @brief Creates an OH_Drawing_ImageFilter object that applies the shader to the input. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param shaderEffct Indicates the shader effect to be applied to the image. + * @return Returns the pointer to the OH_Drawing_ImageFilter object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty or + * a nullptr OH_Drawing_ShaderEffect is passed. + * @since 20 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromShaderEffect(OH_Drawing_ShaderEffect* shaderEffct); + /** * @brief Destroys an OH_Drawing_ImageFilter 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 b42156a5f..1f3386f92 100644 --- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h @@ -167,6 +167,25 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMat const OH_Drawing_Point2D* centerPt, float radius, const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode tileMode, const OH_Drawing_Matrix* matrix); +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates a sweep gradient given a center. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param centerPt Indicates the center of the circle for the gradient. + * @param colors Indicates the colors to be distributed between the two points. + * @param pos Indicates the relative position of each corresponding color in the colors array. + * @param size Indicates the number of colors and pos. + * @param tileMode Indicates the tile mode. + * @param matrix Indicates the pointer to an OH_Drawing_Matrix object, + which represents the local matrix of the created OH_Drawing_ShaderEffect 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_ShaderEffectCreateSweepGradientWithLocalMatrix(const OH_Drawing_Point* centerPt, + const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode tileMode, const OH_Drawing_Matrix* matrix); + /** * @brief Creates an OH_Drawing_ShaderEffect that generates a sweep gradient given a center. * @@ -226,6 +245,22 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateTwoPointConicalGradient(co float startRadius, const OH_Drawing_Point2D* endPt, float endRadius, const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode tileMode, const OH_Drawing_Matrix* matrix); +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates by two shaders.. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param dst Indicates the destination ShaderEffect pointer. + * @param src Indicates the source ShaderEffect pointer. + * @param mode Indicates the blend mode. + * @return Returns the pointer to the OH_Drawing_ShaderEffect object created. + * If nullptr is returned, the creation fails. + * The possible cause of the failure is that the available memory is empty or any of dst and src is nullptr. + * @since 20 + * @version 1.0 + */ +OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateCompose(OH_Drawing_ShaderEffect* dst, + OH_Drawing_ShaderEffect* src, OH_Drawing_BlendMode mode); + /** * @brief Destroys an OH_Drawing_ShaderEffect 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 e13687d42..44153abe0 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -177,6 +177,10 @@ { "name": "OH_Drawing_ColorFilterCreateCompose" }, { "name": "OH_Drawing_ColorFilterCreateLinearToSrgbGamma" }, { "name": "OH_Drawing_ColorFilterCreateLuma" }, + { + "first_introduced": "20", + "name": "OH_Drawing_ColorFilterCreateLighting" + }, { "name": "OH_Drawing_ColorFilterCreateMatrix" }, { "name": "OH_Drawing_ColorFilterCreateSrgbGammaToLinear" }, { "name": "OH_Drawing_ColorFilterDestroy" }, @@ -338,6 +342,14 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateFromColorFilter" }, + { + "first_introduced": "20", + "name": "OH_Drawing_ImageFilterCreateOffset" + }, + { + "first_introduced": "20", + "name": "OH_Drawing_ImageFilterCreateFromShaderEffect" + }, { "first_introduced": "12", "name": "OH_Drawing_ImageFilterDestroy" @@ -694,6 +706,10 @@ "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateRadialGradientWithLocalMatrix" }, + { + "first_introduced": "20", + "name": "OH_Drawing_ShaderEffectCreateSweepGradientWithLocalMatrix" + }, { "name": "OH_Drawing_ShaderEffectCreateSweepGradient" }, { "first_introduced": "12", @@ -703,6 +719,10 @@ "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateTwoPointConicalGradient" }, + { + "first_introduced": "20", + "name": "OH_Drawing_ShaderEffectCreateCompose" + }, { "name": "OH_Drawing_ShaderEffectDestroy" }, { "first_introduced": "12", -- Gitee