diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn
index 60e24af8d5234c31a2686e65ddefe17bc0c129ed..542a4865597391104836ba8a98db1cea0d4c9fc8 100644
--- a/graphic/graphic_2d/native_drawing/BUILD.gn
+++ b/graphic/graphic_2d/native_drawing/BUILD.gn
@@ -22,6 +22,7 @@ ohos_ndk_headers("native_drawing_header") {
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_canvas.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_color.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_color_filter.h",
+ "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_color_space.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_filter.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font_collection.h",
@@ -34,6 +35,7 @@ ohos_ndk_headers("native_drawing_header") {
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_point.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_rect.h",
+ "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_region.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_register_font.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_round_rect.h",
"//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_sampling_options.h",
@@ -57,6 +59,7 @@ ohos_ndk_library("libnative_drawing_ndk") {
"native_drawing/drawing_canvas.h",
"native_drawing/drawing_color.h",
"native_drawing/drawing_color_filter.h",
+ "native_drawing/drawing_color_space.h",
"native_drawing/drawing_filter.h",
"native_drawing/drawing_font.h",
"native_drawing/drawing_font_collection.h",
@@ -68,6 +71,7 @@ ohos_ndk_library("libnative_drawing_ndk") {
"native_drawing/drawing_pen.h",
"native_drawing/drawing_point.h",
"native_drawing/drawing_rect.h",
+ "native_drawing/drawing_region.h",
"native_drawing/drawing_register_font.h",
"native_drawing/drawing_round_rect.h",
"native_drawing/drawing_image.h",
diff --git a/graphic/graphic_2d/native_drawing/drawing_bitmap.h b/graphic/graphic_2d/native_drawing/drawing_bitmap.h
index 2540c24fb7a9c9d012ea20e75785e636adfa0072..3f7a4035d7b1114e9776d2cdf411a85de26d72b8 100644
--- a/graphic/graphic_2d/native_drawing/drawing_bitmap.h
+++ b/graphic/graphic_2d/native_drawing/drawing_bitmap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
@@ -150,6 +150,27 @@ void* OH_Drawing_BitmapGetPixels(OH_Drawing_Bitmap*);
*/
void OH_Drawing_BitmapGetImageInfo(OH_Drawing_Bitmap*, OH_Drawing_Image_Info*);
+/**
+ * @brief Copies a rect of pixels from bitmap to dstPixels. Copy starts at (srcX, srcY),
+ * and does not exceed bitmap (width(), height()).
+ * dstInfo specifies width, height, colorType, alphaType of
+ * destination. dstRowBytes specifics the gap from one destination row to the next.
+ * Returns true if pixels are copied. Returns false if:
+ * - dstInfo has no address
+ * - dstRowBytes is less than dstInfo.minRowBytes()
+ * - PixelRef is nullptr
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object.
+ * @param dstInfo Indicates the pointer to an OH_Drawing_Image_Info object.
+ * @param dstPixels Destination pixel storage.
+ * @param dstRowBytes Destination row length.
+ * @param srcX Column index whose absolute value is less than width().
+ * @param srcY Row index whose absolute value is less than height().
+ * @return Returns true if pixels are copied to dstPixels.
+*/
+bool OH_Drawing_BitmapReadPixels(OH_Drawing_Bitmap*, const OH_Drawing_Image_Info* dstInfo,
+ void* dstPixels, size_t dstRowBytes, int32_t srcX, int32_t srcY);
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_brush.h b/graphic/graphic_2d/native_drawing/drawing_brush.h
index dca333f2de58b6036da66f0ff346a9ebaf34202f..822d6bdbdd964ba14ab52c794033e793379015e9 100644
--- a/graphic/graphic_2d/native_drawing/drawing_brush.h
+++ b/graphic/graphic_2d/native_drawing/drawing_brush.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
@@ -154,6 +154,17 @@ void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush*, OH_Drawing_ShaderEffect*
*/
void OH_Drawing_BrushSetFilter(OH_Drawing_Brush*, OH_Drawing_Filter*);
+/**
+ * @brief Gets the filter from a brush.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object.
+ * @param OH_Drawing_Filter Indicates the pointer to an OH_Drawing_Filter object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_BrushGetFilter(OH_Drawing_Brush*, OH_Drawing_Filter*);
+
/**
* @brief Sets a blender that implements the specified blendmode enum for a brush.
*
@@ -165,6 +176,16 @@ void OH_Drawing_BrushSetFilter(OH_Drawing_Brush*, OH_Drawing_Filter*);
*/
void OH_Drawing_BrushSetBlendMode(OH_Drawing_Brush*, OH_Drawing_BlendMode);
+/**
+ * @brief Resets brush data.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_BrushReset(OH_Drawing_Brush*);
+
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h
index c65f1a8130485d159e57cc6419cdb826cc0b0b91..84c5346a89b7aac67c79bd634b8bd0d029883f9f 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-2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
@@ -43,6 +43,19 @@
extern "C" {
#endif
+/**
+ * @brief Enumeration defines the constraint type.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /** Strict constraint. The source rectangle region must be fully contained within the image. */
+ STRICT_SRC_RECT_CONSTRAINT,
+ /** Fast constraint. The source rectangle region can be partially outside the image. */
+ FAST_SRC_RECT_CONSTRAINT,
+} OH_Drawing_SrcRectConstraint;
+
/**
* @brief Creates an OH_Drawing_Canvas object.
*
@@ -199,6 +212,62 @@ void OH_Drawing_CanvasDrawLine(OH_Drawing_Canvas*, float x1, float y1, float x2,
*/
void OH_Drawing_CanvasDrawPath(OH_Drawing_Canvas*, const OH_Drawing_Path*);
+/**
+ * @brief Draws a Background.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasDrawBackground(OH_Drawing_Canvas*, const OH_Drawing_Brush*);
+
+/**
+ * @brief Draws a region.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasDrawRegion(OH_Drawing_Canvas*, const OH_Drawing_Region*);
+
+/**
+ * @brief draw points enum method.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /**
+ * draw each point separately.
+ */
+ POINT_MODE_POINTS,
+ /**
+ * draw each pair of points as a line segment.
+ */
+ POINT_MODE_LINES,
+ /**
+ * draw the array of points as a open polygon.
+ */
+ POINT_MODE_POLYGON,
+} OH_Drawing_PointMode;
+
+/**
+ * @brief Draws point array.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param mode Draw points enum.
+ * @param count The point count.
+ * @param OH_Drawing_Point2D Point struct array.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasDrawPoints(OH_Drawing_Canvas*, OH_Drawing_PointMode mode, uint32_t count, const OH_Drawing_Point2D*);
+
/**
* @brief Draws a bitmap.
*
@@ -380,6 +449,18 @@ void OH_Drawing_CanvasTranslate(OH_Drawing_Canvas*, float dx, float dy);
*/
void OH_Drawing_CanvasScale(OH_Drawing_Canvas*, float sx, float sy);
+/**
+ * @brief Shear by sx on the x-axis and sy on the y-axis.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param sx Indicates the amount to shear on x-axis.
+ * @param sy Indicates the amount to shear on y-axis.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasShear(OH_Drawing_Canvas*, float sx, float sy);
+
/**
* @brief Get the width of a canvas.
*
@@ -501,6 +582,33 @@ void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color);
*/
void OH_Drawing_CanvasSetMatrix(OH_Drawing_Canvas*, OH_Drawing_Matrix*);
+/**
+ * @brief Reset matrix of canvas.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasResetMatrix(OH_Drawing_Canvas*);
+
+/**
+ * @brief Draws the specified source rectangle of the image onto the canvas,
+ * scaled and translated to the destination rectangle.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object.
+ * @param src The area of source image.
+ * @param dst The area of destination canvas.
+ * @param OH_Drawing_SamplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object.
+ * @param OH_Drawing_SrcRectConstraint Constraint type.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasDrawImageRectWithSrc(OH_Drawing_Canvas*, OH_Drawing_Image*,
+ OH_Drawing_Rect* src, OH_Drawing_Rect* dst, OH_Drawing_SamplingOptions*, OH_Drawing_SrcRectConstraint);
+
/**
* @brief Draws the specified source rectangle of the image onto the canvas,
* scaled and translated to the destination rectangle.
@@ -516,6 +624,50 @@ void OH_Drawing_CanvasSetMatrix(OH_Drawing_Canvas*, OH_Drawing_Matrix*);
void OH_Drawing_CanvasDrawImageRect(OH_Drawing_Canvas*, OH_Drawing_Image*,
OH_Drawing_Rect* dst, OH_Drawing_SamplingOptions*);
+/**
+ * @brief Draw a set of vertices.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum{
+ /**
+ * The vertices are a triangle list.
+ */
+ VERTEX_MODE_TRIANGLES,
+ /**
+ * The vertices are a triangle strip.
+ */
+ VERTEX_MODE_TRIANGLESSTRIP,
+ /**
+ * The vertices are a triangle fan.
+ */
+ VERTEX_MODE_TRIANGLEFAN,
+ /**
+ * The vertices are a default.
+ */
+ VERTEX_MODE_LAST,
+} OH_Drawing_VertexMode;
+
+/**
+ * @brief Draw vertices.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object.
+ * @param vertexMmode Draw a set of vertices.
+ * @param vertexCount Vertex count.
+ * @param positions Positions data pointer.
+ * @param texs Texture coordinate data pointer.
+ * @param colors Color data pointer.
+ * @param indexCount Index count.
+ * @param indices Index data pointer.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasDrawVertices(OH_Drawing_Canvas*, OH_Drawing_VertexMode vertexMmode,
+ int32_t vertexCount, const OH_Drawing_Point2D* positions, const OH_Drawing_Point2D* texs, uint32_t* colors,
+ int32_t indexCount, uint16_t* indices, OH_Drawing_BlendMode mode);
+
/**
* @brief Read pixels data from canvas.
*
diff --git a/graphic/graphic_2d/native_drawing/drawing_color_space.h b/graphic/graphic_2d/native_drawing/drawing_color_space.h
new file mode 100755
index 0000000000000000000000000000000000000000..fb746329712d35238103deb8fe882637643c791c
--- /dev/null
+++ b/graphic/graphic_2d/native_drawing/drawing_color_space.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef C_INCLUDE_DRAWING_COLOR_SPACE_H
+#define C_INCLUDE_DRAWING_COLOR_SPACE_H
+
+/**
+ * @addtogroup Drawing
+ * @{
+ *
+ * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ *
+ * @since 8
+ * @version 1.0
+ */
+
+/**
+ * @file drawing_color_space.h
+ *
+ * @brief Declares functions related to the colorSpace object in the drawing module.
+ *
+ * @since 12
+ * @version 1.0
+ */
+
+#include "drawing_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Creates an OH_Drawing_ColorSpace object that represents the sRGB color space.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @return Returns the pointer to the OH_Drawing_ColorSpace object created.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_ColorSpace* OH_Drawing_ColorSpaceCreateSRGB();
+
+/**
+ * @brief Creates an OH_Drawing_ColorSpace object with the sRGB primaries, but a linear (1.0) gamma.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @return Returns the pointer to the OH_Drawing_ColorSpace object created.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_ColorSpace* OH_Drawing_ColorSpaceCreateSRGBLinear();
+
+/**
+ * @brief Destroy an OH_Drawing_ColorSpace object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_ColorSpace Indicates the pointer to an OH_Drawing_ColorSpace object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_ColorSpaceDestroy(OH_Drawing_ColorSpace*);
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */
+#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_filter.h b/graphic/graphic_2d/native_drawing/drawing_filter.h
index 3a031b95fb94ed9cd4187eaf03d71c115193960b..556c19d85ca81f103cb50f3ba1cd85e37cd80941 100644
--- a/graphic/graphic_2d/native_drawing/drawing_filter.h
+++ b/graphic/graphic_2d/native_drawing/drawing_filter.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2023-2024 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
@@ -75,6 +75,17 @@ void OH_Drawing_FilterSetMaskFilter(OH_Drawing_Filter*, OH_Drawing_MaskFilter*);
*/
void OH_Drawing_FilterSetColorFilter(OH_Drawing_Filter*, OH_Drawing_ColorFilter*);
+/**
+ * @brief Gets an OH_Drawing_ColorFilter object from an OH_Drawing_Filter object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Filter Indicates the pointer to an OH_Drawing_Filter object.
+ * @param OH_Drawing_ColorFilter Indicates the pointer to an OH_Drawing_ColorFilter object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_FilterGetColorFilter(OH_Drawing_Filter*, OH_Drawing_ColorFilter*);
+
/**
* @brief Destroys an OH_Drawing_Filter object and reclaims the memory occupied by the object.
*
diff --git a/graphic/graphic_2d/native_drawing/drawing_image.h b/graphic/graphic_2d/native_drawing/drawing_image.h
index ed2f1f4914cc0deb31957b99d3f4697ab851c061..07ae9b3015e0e567b79def465f418f3fdd99a93f 100644
--- a/graphic/graphic_2d/native_drawing/drawing_image.h
+++ b/graphic/graphic_2d/native_drawing/drawing_image.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h
index 1a1bc0255d3aa91b50b53880699fe9613e1dc029..aded64897b4f646e0ceb16b9d8bde78d59797b97 100644
--- a/graphic/graphic_2d/native_drawing/drawing_matrix.h
+++ b/graphic/graphic_2d/native_drawing/drawing_matrix.h
@@ -83,6 +83,36 @@ OH_Drawing_Matrix* OH_Drawing_MatrixCreateRotation(float deg, float x, float y);
*/
OH_Drawing_Matrix* OH_Drawing_MatrixCreateScale(float sx, float sy, float px, float py);
+/**
+ * @brief Sets matrix to forward scale by sx and sy, about a pivot point at (px, py).
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param sx horizontal scale factor.
+ * @param sy vertical scale factor.
+ * @param px pivot on x-axis.
+ * @param py pivot on y-axis.
+ * @return Returns the pointer to the OH_Drawing_Matrix object scale.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_Matrix* OH_Drawing_MatrixPreScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py);
+
+/**
+ * @brief Sets matrix to backward scale by sx and sy, about a pivot point at (px, py).
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param sx horizontal scale factor.
+ * @param sy vertical scale factor.
+ * @param px pivot on x-axis.
+ * @param py pivot on y-axis.
+ * @return Returns the pointer to the OH_Drawing_Matrix object scale.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_Matrix* OH_Drawing_MatrixPostScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py);
+
/**
* @brief Creates an OH_Drawing_Matrix object with translation.
*
@@ -117,6 +147,130 @@ void OH_Drawing_MatrixSetMatrix(OH_Drawing_Matrix*, float scaleX, float skewX, f
float skewY, float scaleY, float transY, float persp0, float persp1, float persp2);
/**
+ * @brief scales to fit enum method.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /**
+ * scales in x and y to fill destination Rect.
+ */
+ SCALE_TO_FIT_FILL,
+ /**
+ * scales and aligns to left and top.
+ */
+ SCALE_TO_FIT_START,
+ /**
+ * scales and aligns to center.
+ */
+ SCALE_TO_FIT_CENTER,
+ /**
+ * scales and aligns to right and bottom.
+ */
+ SCALE_TO_FIT_END,
+} OH_Drawing_ScaleToFit;
+
+/**
+ * @brief Sets Matrix to scale and translate src Rect to dst Rect. stf selects whether
+ *mapping completely fills dst or preserves the aspect ratio, and how to align
+ *src within dst. Returns false if src is empty, and sets Matrix to identity.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param src Indicates the pointer to an OH_Drawing_Rect object Rect to map from.
+ * @param dst Indicates the pointer to an OH_Drawing_Rect object Rect to map to.
+ * @param stf Scales to fit enum method.
+ * @return true if dst is empty, and sets Matrix to:
+ * | 0 0 0 |
+ * | 0 0 0 |
+ * | 0 0 1 |
+ *
+ * @since 12
+ * @version 1.0
+ */
+bool OH_Drawing_MatrixSetRectToRect(OH_Drawing_Matrix*, const OH_Drawing_Rect* src,
+ const OH_Drawing_Rect* dst, OH_Drawing_ScaleToFit stf);
+
+/**
+ * @brief Sets Matrix to Matrix multiplied by Matrix constructed from rotating by degrees
+ *about pivot point (px, py), Positive degrees rotates clockwise
+ * Given:
+ *
+ * | A B C | | c -s dx |
+ * Matrix = | D E F |, R(degrees, px, py) = | s c dy |
+ * | G H I | | 0 0 1 |
+ *
+ * where
+ *
+ * c = cos(degrees)
+ * s = sin(degrees)
+ * dx = s * py + (1 - c) * px
+ * dy = -s * px + (1 - c) * py
+ *
+ * sets Matrix to:
+ *
+ * | A B C | | c -s dx | | Ac+Bs -As+Bc A*dx+B*dy+C |
+ * Matrix * R(degrees, px, py) = | D E F | | s c dy | = | Dc+Es -Ds+Ec D*dx+E*dy+F |
+ * | G H I | | 0 0 1 | | Gc+Hs -Gs+Hc G*dx+H*dy+I |
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param degree Indicates the angle of axes relative to upright axes.
+ * @param px Indicates the pivot on x-axis.
+ * @param py Indicates the pivot on y-axis.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixPreRotate(OH_Drawing_Matrix*, float degree, float px, float py);
+
+/**
+ * @brief Sets Matrix to Matrix constructed from rotating by degrees about pivot point
+ *(px, py), multiplied by Matrix, Positive degrees rotates clockwise
+ * Given:
+ *
+ * | J K L | | c -s dx |
+ * Matrix = | M N O |, R(degrees, px, py) = | s c dy |
+ * | P Q R | | 0 0 1 |
+ *
+ * where
+ *
+ * c = cos(degrees)
+ * s = sin(degrees)
+ * dx = s * py + (1 - c) * px
+ * dy = -s * px + (1 - c) * py
+ *
+ * sets Matrix to:
+ *
+ * |c -s dx| |J K L| |cJ-sM+dx*P cK-sN+dx*Q cL-sO+dx+R|
+ * R(degrees, px, py) * Matrix = |s c dy| |M N O| = |sJ+cM+dy*P sK+cN+dy*Q sL+cO+dy*R|
+ * |0 0 1| |P Q R| | P Q R|
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param degree Indicates the angle of axes relative to upright axes.
+ * @param px Indicates the pivot on x-axis.
+ * @param py Indicates the pivot on y-axis.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixPostRotate(OH_Drawing_Matrix*, float degree, float px, float py);
+
+/**
+ * @brief Sets Matrix to identity; which has no effect on mapped Point. Sets Matrix to:
+ * | 1 0 0 |
+ * | 0 1 0 |
+ * | 0 0 1 |
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing.
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixReset(OH_Drawing_Matrix*);
+
+/**
+ * @brief Sets matrix to matrix multiplied by matrix other.
* @brief Sets matrix total to matrix a multiplied by matrix b.
* Given:
* | A B C | | J K L |
@@ -173,6 +327,30 @@ void OH_Drawing_MatrixRotate(OH_Drawing_Matrix*, float degree, float px, float p
*/
void OH_Drawing_MatrixTranslate(OH_Drawing_Matrix*, float dx, float dy);
+/**
+ * @brief Sets forward matrix to translate by (dx, dy).
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param dx Indicates the horizontal translation.
+ * @param dy Indicates the vertical translation.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixPreTranslate(OH_Drawing_Matrix*, float dx, float dy);
+
+/**
+ * @brief Sets backward matrix to translate by (dx, dy).
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param dx Indicates the horizontal translation.
+ * @param dy Indicates the vertical translation.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixPostTranslate(OH_Drawing_Matrix*, float dx, float dy);
+
/**
* @brief Sets matrix to scale by sx and sy, about a pivot point at (px, py).
*
diff --git a/graphic/graphic_2d/native_drawing/drawing_path.h b/graphic/graphic_2d/native_drawing/drawing_path.h
index 968f65c17060c9c76579411f62587ec5d5e7c3f5..348efc68ede69d4af2b606614103a9fe54f6c20b 100644
--- a/graphic/graphic_2d/native_drawing/drawing_path.h
+++ b/graphic/graphic_2d/native_drawing/drawing_path.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
@@ -57,7 +57,20 @@ typedef enum {
} OH_Drawing_PathDirection;
/**
- * @brief FillType of path
+ * @brief Whether to apply perspective clip.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /** Don't pre-clip the geometry before applying the (perspective) matrix */
+ PATH_APPLY_PERSPECTIVEClIP_NO,
+ /** Do pre-clip the geometry before applying the (perspective) matrix */
+ PATH_APPLY_PERSPECTIVEClIP_YES,
+} OH_Drawing_PathApplyPerspectiveClip;
+
+/**
+ * @brief FillType of path.
*
* @since 12
* @version 1.0
@@ -73,6 +86,19 @@ typedef enum {
PATH_FILL_TYPE_INVERSE_EVEN_ODD,
} OH_Drawing_PathFillType;
+/**
+ * @brief AddMode of path.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /** Appended to destination unaltered */
+ PATH_ADD_MODE_APPEND,
+ /** Add line if prior contour is not closed */
+ PATH_ADD_MODE_EXTEND,
+} OH_Drawing_PathAddMode;
+
/**
* @brief Creates an OH_Drawing_Path object.
*
@@ -163,6 +189,21 @@ void OH_Drawing_PathArcTo(OH_Drawing_Path*, float x1, float y1, float x2, float
*/
void OH_Drawing_PathQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY);
+/**
+ * @brief Draws a conic from the last point of a path to the target point.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param ctrlX Indicates the x coordinate of the control point.
+ * @param ctrlY Indicates the y coordinate of the control point.
+ * @param endX Indicates the x coordinate of the target point.
+ * @param endY Indicates the y coordinate of the target point.
+ * @param weight Indicates the weight of added conic.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathConicTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY, float weight);
+
/**
* @brief Draws a cubic Bezier curve from the last point of a path to the target point.
*
@@ -180,6 +221,76 @@ void OH_Drawing_PathQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float end
void OH_Drawing_PathCubicTo(
OH_Drawing_Path*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY);
+/**
+ * @brief Sets the relative starting point of a path.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param x Indicates the x coordinate of the relative starting point.
+ * @param y Indicates the y coordinate of the relative starting point.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathRMoveTo(OH_Drawing_Path*, float x, float y);
+
+/**
+ * @brief Draws a line segment from the last point of a path to the relative target point.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param x Indicates the x coordinate of the relative target point.
+ * @param y Indicates the y coordinate of the relative target point.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathRLineTo(OH_Drawing_Path*, float x, float y);
+
+/**
+ * @brief Draws a quadratic Bezier curve from the last point of a path to the relative target point.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param ctrlX Indicates the x coordinate of the relative control point.
+ * @param ctrlY Indicates the y coordinate of the relative control point.
+ * @param endX Indicates the x coordinate of the relative target point.
+ * @param endY Indicates the y coordinate of the relative target point.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathRQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY);
+
+/**
+ * @brief Draws a conic from the last point of a path to the relative target point.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param ctrlX Indicates the x coordinate of the relative control point.
+ * @param ctrlY Indicates the y coordinate of the relative control point.
+ * @param endX Indicates the x coordinate of the relative target point.
+ * @param endY Indicates the y coordinate of the relative target point.
+ * @param weight Indicates the weight of added conic.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathRConicTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY, float weight);
+
+/**
+ * @brief Draws a cubic Bezier curve from the last point of a path to the relative target point.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param ctrlX1 Indicates the x coordinate of the first relative control point.
+ * @param ctrlY1 Indicates the y coordinate of the first relative control point.
+ * @param ctrlX2 Indicates the x coordinate of the second relative control point.
+ * @param ctrlY2 Indicates the y coordinate of the second relative control point.
+ * @param endX Indicates the x coordinate of the relative target point.
+ * @param endY Indicates the y coordinate of the relative target point.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathRCubicTo(
+ OH_Drawing_Path*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY);
+
/**
* @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction.
*
@@ -195,6 +306,19 @@ void OH_Drawing_PathCubicTo(
*/
void OH_Drawing_PathAddRect(OH_Drawing_Path*, float left, float top, float right, float bottom, OH_Drawing_PathDirection);
+/**
+ * @brief Adds a new contour to the path, defined by the rect, and wound in the specified direction.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param OH_Drawing_PathDirection Indicates the path direction.
+ * @param start Indicates initial corner of Rect to add.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathAddRectWithInitialCorner(OH_Drawing_Path*, OH_Drawing_Rect*, OH_Drawing_PathDirection, unsigned start);
+
/**
* @brief Adds a new contour to the path, defined by the round rect, and wound in the specified direction.
*
@@ -207,6 +331,19 @@ void OH_Drawing_PathAddRect(OH_Drawing_Path*, float left, float top, float right
*/
void OH_Drawing_PathAddRoundRect(OH_Drawing_Path*, const OH_Drawing_RoundRect* roundRect, OH_Drawing_PathDirection);
+/**
+ * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param start Index of initial point of ellipse.
+ * @param OH_Drawing_PathDirection Indicates the path direction.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path*, const OH_Drawing_Rect*, unsigned start, OH_Drawing_PathDirection);
+
/**
* @brief Appends arc to path, as the start of new contour.Arc added is part of ellipse bounded by oval,
* from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees
@@ -237,6 +374,48 @@ void OH_Drawing_PathAddArc(OH_Drawing_Path*, const OH_Drawing_Rect*, float start
*/
void OH_Drawing_PathAddPath(OH_Drawing_Path*, const OH_Drawing_Path* src, const OH_Drawing_Matrix*);
+/**
+ * @brief Appends src path to path, transformed by matrix and mode. Transformed curves may have different verbs,
+ * point, and conic weights.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param src Indicates the pointer to an OH_Drawing_Path object.
+ * @param OH_Drawing_Matrix Indicates the length of the OH_Drawing_Matrix object.
+ * @param OH_Drawing_PathAddMode Indicates the add path's add mode.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathAddPathWithMatrixAndMode(OH_Drawing_Path*, const OH_Drawing_Path* src, const OH_Drawing_Matrix*, OH_Drawing_PathAddMode);
+
+/**
+ * @brief Appends src path to path, transformed by mode. Transformed curves may have different verbs,
+ * point, and conic weights.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param src Indicates the pointer to an OH_Drawing_Path object.
+ * @param OH_Drawing_PathAddMode Indicates the add path's add mode.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path*, const OH_Drawing_Path* src, OH_Drawing_PathAddMode);
+
+/**
+ * @brief Appends src path to path, transformed by offset and mode. Transformed curves may have different verbs,
+ * point, and conic weights.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param src Indicates the pointer to an OH_Drawing_Path object.
+ * @param dx Indicates offset added to src path x-axis coordinates.
+ * @param dy Indicates offset added to src path y-axis coordinates.
+ * @param OH_Drawing_PathAddMode Indicates the add path's add mode.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathAddPathWithOffsetAndMode(OH_Drawing_Path*, const OH_Drawing_Path* src, float dx, float dy, OH_Drawing_PathAddMode);
+
/**
* @brief Return the status that point (x, y) is contained by path.
*
@@ -262,6 +441,23 @@ bool OH_Drawing_PathContains(OH_Drawing_Path*, float x, float y);
*/
void OH_Drawing_PathTransform(OH_Drawing_Path*, const OH_Drawing_Matrix*);
+/**
+ * @brief Transforms verb array, Point array, and weight by matrix.
+ * transform may change verbs and increase their number.
+ * Transformed Path replaces dst; if dst is nullptr, original data
+ * is replaced.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param src Indicates the pointer to an OH_Drawing_Path object.
+ * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object.
+ * @param dst Indicates the pointer to an OH_Drawing_Path object.
+ * @param OH_Drawing_PathApplyPerspectiveClip Indicates whether to apply perspective clip.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathTransformWithPerspectiveClip(OH_Drawing_Path* src, const OH_Drawing_Matrix*,
+ OH_Drawing_Path* dst, OH_Drawing_PathApplyPerspectiveClip);
+
/**
* @brief Sets FillType, the rule used to fill path.
*
@@ -273,6 +469,18 @@ void OH_Drawing_PathTransform(OH_Drawing_Path*, const OH_Drawing_Matrix*);
*/
void OH_Drawing_PathSetFillType(OH_Drawing_Path*, OH_Drawing_PathFillType);
+/**
+ * @brief Gets the length of the current path object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param forceClosed Indicates whether free to modify/delete the path after this call.
+ * @return Returns the length of the current path object.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_PathGetLength(OH_Drawing_Path*, bool forceClosed);
+
/**
* @brief Closes a path. A line segment from the start point to the last point of the path is added.
*
@@ -283,6 +491,19 @@ void OH_Drawing_PathSetFillType(OH_Drawing_Path*, OH_Drawing_PathFillType);
*/
void OH_Drawing_PathClose(OH_Drawing_Path*);
+/**
+ * @brief Offset path replaces dst.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object.
+ * @param dst Indicates the pointer to an OH_Drawing_Path object.
+ * @param dx Indicates offset added to dst path x-axis coordinates.
+ * @param dy Indicates offset added to dst path y-axis coordinates.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathOffset(OH_Drawing_Path*, OH_Drawing_Path* dst, float dx, float dy);
+
/**
* @brief Resets path data.
*
diff --git a/graphic/graphic_2d/native_drawing/drawing_pen.h b/graphic/graphic_2d/native_drawing/drawing_pen.h
index 3780c838ce90d78f126e73d32fe7518797c0d09e..9fc7a89d4a997dd7a87228043a0c9f09bbdecfb0 100644
--- a/graphic/graphic_2d/native_drawing/drawing_pen.h
+++ b/graphic/graphic_2d/native_drawing/drawing_pen.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
@@ -302,6 +302,17 @@ void OH_Drawing_PenSetPathEffect(OH_Drawing_Pen*, OH_Drawing_PathEffect*);
*/
void OH_Drawing_PenSetFilter(OH_Drawing_Pen*, OH_Drawing_Filter*);
+/**
+ * @brief Gets the filter from a pen.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object.
+ * @param OH_Drawing_Filter Indicates the pointer to an OH_Drawing_Filter object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PenGetFilter(OH_Drawing_Pen*, OH_Drawing_Filter*);
+
/**
* @brief Sets a blender that implements the specified blendmode enum for a pen.
*
@@ -313,6 +324,16 @@ void OH_Drawing_PenSetFilter(OH_Drawing_Pen*, OH_Drawing_Filter*);
*/
void OH_Drawing_PenSetBlendMode(OH_Drawing_Pen*, OH_Drawing_BlendMode);
+/**
+ * @brief Resets pen data.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PenReset(OH_Drawing_Pen*);
+
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h
index 3f1a1bc0e03a5b1afaf333df5e19b871b3d3fa5d..d40a9142c0be313da0195fdaf794a7740a162e27 100644
--- a/graphic/graphic_2d/native_drawing/drawing_rect.h
+++ b/graphic/graphic_2d/native_drawing/drawing_rect.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2023-2024 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
@@ -67,6 +67,137 @@ OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float
*/
void OH_Drawing_RectDestroy(OH_Drawing_Rect*);
+/**
+ * @brief If RectI intersects other, sets RectI to intersection.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param cRect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param other Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Returns true true if have area in common.
+ * @since 12
+ * @version 1.0
+ */
+bool OH_Drawing_RectIntersect(OH_Drawing_Rect* cRect, OH_Drawing_Rect* other);
+
+/**
+ * @brief Get Height of OH_Drawing_Rect object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_RectGetHeight(OH_Drawing_Rect*);
+
+/* @brief Obtains the width of a rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Returns the width.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_RectGetWidth(OH_Drawing_Rect*);
+
+/**
+ * @brief Set the left position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param left Indicates the left position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left);
+
+/**
+ * @brief Set the top position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param top Indicates the top position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top);
+
+/**
+ * @brief Set the right position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param right Indicates the right position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right);
+
+/**
+ * @brief Set the bottom position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param bottom Indicates the bottom position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom);
+
+/**
+ * @brief Get the left position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Return the left position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_RectGetLeft(OH_Drawing_Rect*);
+
+/**
+ * @brief Get the top position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Return the top position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_RectGetTop(OH_Drawing_Rect*);
+
+/**
+ * @brief Get the right position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Return the right position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_RectGetRight(OH_Drawing_Rect*);
+
+/**
+ * @brief Get the bottom position of the rect.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Return the bottom position of the rect.
+ * @since 12
+ * @version 1.0
+ */
+float OH_Drawing_RectGetBottom(OH_Drawing_Rect*);
+
+/**
+ * @brief Copy the original rectangular object to the destination rectangular object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param sRect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param dRect Indicates the pointer to an OH_Drawing_Rect object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RectCopy(OH_Drawing_Rect* sRect, OH_Drawing_Rect* dRect);
+
#ifdef __cplusplus
}
#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h
new file mode 100644
index 0000000000000000000000000000000000000000..1ff3b6fc8b419e07aaa91f07503498e780c4d3c4
--- /dev/null
+++ b/graphic/graphic_2d/native_drawing/drawing_region.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2024 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef C_INCLUDE_DRAWING_REGION_H
+#define C_INCLUDE_DRAWING_REGION_H
+
+/**
+ * @addtogroup Drawing
+ * @{
+ *
+ * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ *
+ * @since 8
+ * @version 1.0
+ */
+
+/**
+ * @file drawing_region.h
+ *
+ * @brief Declares functions related to the region object in the drawing module.
+ *
+ * @since 12
+ * @version 1.0
+ */
+
+#include "drawing_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Creates an OH_Drawing_Region object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @return Returns the pointer to the OH_Drawing_Region object created.
+ * @since 12
+ * @version 1.0
+ */
+OH_Drawing_Region* OH_Drawing_RegionCreate(void);
+
+/**
+ * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object.
+ * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Return true if constructed Region is not empty.
+ * @since 12
+ * @version 1.0
+ */
+bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, OH_Drawing_Rect* rect);
+
+/**
+ * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RegionDestroy(OH_Drawing_Region*);
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */
+#endif
diff --git a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h
index 6eac17aaa560ee6431cdf6d25af275cd55239be9..c537e38a8b76cc5f52d2f7de9c7e27957bd5e391 100644
--- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h
+++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2023-2024 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
@@ -119,6 +119,23 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateRadialGradient(const OH_Dr
OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Drawing_Point* centerPt,
const uint32_t* colors, const float* pos, uint32_t size, OH_Drawing_TileMode);
+/**
+ * @brief Creates an OH_Drawing_ShaderEffect that generates a image shader.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object.
+ * @param tileX Indicates the tileX.
+ * @param tileY Indicates the tileY.
+ * @param OH_Drawing_SamplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object.
+ * @param OH_Drawing_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 12
+ * @version 1.0
+ */
+OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Image*,
+ OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY, OH_Drawing_SamplingOptions*, OH_Drawing_Matrix*);
+
/**
* @brief Destroys an OH_Drawing_ShaderEffect object and reclaims the memory occupied by the object.
*
diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h
index 23e50f38dc3175744df726236a0011a5715abcec..4a386fdd8748b4f206b9399af2d27ad65262a027 100644
--- a/graphic/graphic_2d/native_drawing/drawing_types.h
+++ b/graphic/graphic_2d/native_drawing/drawing_types.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
+ * Copyright (c) 2021-2024 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
@@ -61,6 +61,14 @@ typedef struct OH_Drawing_Canvas OH_Drawing_Canvas;
*/
typedef struct OH_Drawing_Pen OH_Drawing_Pen;
+/**
+ * @brief Defines a region,which is used to represent an enclosed area on the canvas layer.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Drawing_Region OH_Drawing_Region;
+
/**
* @brief Defines as a brush, which is used to describe the style and color to fill in a shape.
*
@@ -93,6 +101,14 @@ typedef struct OH_Drawing_Bitmap OH_Drawing_Bitmap;
*/
typedef struct OH_Drawing_Point OH_Drawing_Point;
+/**
+ * @brief Defines a ColorSpace, which is used to determine how Quartz interprets color information.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Drawing_ColorSpace OH_Drawing_ColorSpace;
+
/**
* @brief Defines a point of 2d.
*
@@ -237,6 +253,14 @@ typedef struct OH_Drawing_SamplingOptions OH_Drawing_SamplingOptions;
*/
typedef struct OH_Drawing_TextBlobBuilder OH_Drawing_TextBlobBuilder;
+/**
+ * @brief Defines a Pixmap, which is used to build the Pixmap.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Drawing_Pixmap OH_Drawing_Pixmap;
+
/**
* @brief Enumerates storage formats of bitmap pixels.
*
diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
index e076cd829af17a63caeda7107214f27e9fc6d99b..74bea691b34f30dac19076a87eeb06dd1055d338 100644
--- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
+++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
@@ -10,6 +10,10 @@
"name": "OH_Drawing_BitmapGetImageInfo"
},
{ "name": "OH_Drawing_BitmapGetPixels" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_BitmapReadPixels"
+ },
{ "name": "OH_Drawing_BrushCreate" },
{ "name": "OH_Drawing_BrushDestroy" },
{ "name": "OH_Drawing_BrushGetAlpha" },
@@ -20,7 +24,15 @@
{ "name": "OH_Drawing_BrushGetColor" },
{ "name": "OH_Drawing_BrushSetColor" },
{ "name": "OH_Drawing_BrushSetFilter" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_BrushGetFilter"
+ },
{ "name": "OH_Drawing_BrushSetShaderEffect" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_BrushReset"
+ },
{ "name": "OH_Drawing_CanvasCreate" },
{ "name": "OH_Drawing_CanvasDestroy" },
{ "name": "OH_Drawing_CanvasBind" },
@@ -40,16 +52,44 @@
{ "name": "OH_Drawing_CanvasDrawLine" },
{ "name": "OH_Drawing_CanvasDrawOval" },
{ "name": "OH_Drawing_CanvasDrawPath" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasDrawPoints"
+ },
{ "name": "OH_Drawing_CanvasDrawRect" },
{ "name": "OH_Drawing_CanvasDrawRoundRect" },
{ "name": "OH_Drawing_CanvasDrawTextBlob" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasDrawRegion"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasDrawBackground"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasDrawVertices"
+ },
{ "name": "OH_Drawing_CanvasClipRect" },
{ "name": "OH_Drawing_CanvasClipPath" },
{ "name": "OH_Drawing_CanvasRotate" },
{ "name": "OH_Drawing_CanvasTranslate" },
{ "name": "OH_Drawing_CanvasScale" },
{ "name": "OH_Drawing_CanvasClear" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasShear"
+ },
{ "name": "OH_Drawing_CanvasSetMatrix" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasResetMatrix"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasDrawImageRectWithSrc"
+ },
{ "name": "OH_Drawing_CanvasDrawImageRect" },
{ "name": "OH_Drawing_CanvasReadPixels" },
{ "name": "OH_Drawing_CanvasReadPixelsToBitmap" },
@@ -70,6 +110,10 @@
{ "name": "OH_Drawing_ColorFilterDestroy" },
{ "name": "OH_Drawing_FilterCreate" },
{ "name": "OH_Drawing_FilterSetColorFilter" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_FilterGetColorFilter"
+ },
{ "name": "OH_Drawing_FilterSetMaskFilter" },
{ "name": "OH_Drawing_FilterDestroy" },
{ "name": "OH_Drawing_FontCreate" },
@@ -87,8 +131,41 @@
{ "name": "OH_Drawing_MatrixCreate" },
{ "name": "OH_Drawing_MatrixCreateRotation" },
{ "name": "OH_Drawing_MatrixCreateScale" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPreScale"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPostScale"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPreTranslate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPostTranslate"
+ },
{ "name": "OH_Drawing_MatrixCreateTranslation" },
{ "name": "OH_Drawing_MatrixSetMatrix" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixSetRectToRect"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPreRotate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPostRotate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixReset"
+ },
+ { "name": "OH_Drawing_MatrixPreConcat" },
{ "name": "OH_Drawing_MatrixConcat" },
{ "name": "OH_Drawing_MatrixGetValue" },
{ "name": "OH_Drawing_MatrixRotate" },
@@ -110,14 +187,70 @@
{ "name": "OH_Drawing_PathArcTo" },
{ "name": "OH_Drawing_PathQuadTo" },
{ "name": "OH_Drawing_PathCubicTo" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathRMoveTo"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathRLineTo"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathRQuadTo"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathRConicTo"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathRCubicTo"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathConicTo"
+ },
{ "name": "OH_Drawing_PathAddRect" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathAddRectWithInitialCorner"
+ },
{ "name": "OH_Drawing_PathAddRoundRect" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathAddOvalWithInitialPoint"
+ },
{ "name": "OH_Drawing_PathAddArc" },
{ "name": "OH_Drawing_PathAddPath" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathAddPathWithMatrixAndMode"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathAddPathWithMode"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathAddPathWithOffsetAndMode"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathGetLength"
+ },
{ "name": "OH_Drawing_PathContains" },
{ "name": "OH_Drawing_PathTransform" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathTransformWithPerspectiveClip"
+ },
{ "name": "OH_Drawing_PathSetFillType" },
{ "name": "OH_Drawing_PathClose" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathOffset"
+ },
{ "name": "OH_Drawing_PathReset" },
{ "name": "OH_Drawing_PenCreate" },
{ "name": "OH_Drawing_PenDestroy" },
@@ -137,14 +270,34 @@
{ "name": "OH_Drawing_PenGetJoin" },
{ "name": "OH_Drawing_PenSetJoin" },
{ "name": "OH_Drawing_PenSetFilter" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PenGetFilter"
+ },
{ "name": "OH_Drawing_PenSetShaderEffect" },
{
"first_introduced": "12",
"name": "OH_Drawing_PenSetPathEffect"
},
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PenReset"
+ },
{ "name": "OH_Drawing_PointCreate" },
{ "name": "OH_Drawing_PointDestroy" },
{ "name": "OH_Drawing_ColorSetArgb" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_ColorSpaceCreateSRGB"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_ColorSpaceCreateSRGBLinear"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_ColorSpaceDestroy"
+ },
{ "name": "OH_Drawing_CreateFontCollection" },
{ "name": "OH_Drawing_DestroyFontCollection" },
{ "name": "OH_Drawing_CreateTypographyStyle" },
@@ -171,6 +324,10 @@
{ "name": "OH_Drawing_ShaderEffectCreateLinearGradient" },
{ "name": "OH_Drawing_ShaderEffectCreateRadialGradient" },
{ "name": "OH_Drawing_ShaderEffectCreateSweepGradient" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_ShaderEffectCreateImageShader"
+ },
{ "name": "OH_Drawing_ShaderEffectDestroy" },
{ "name": "OH_Drawing_TextBlobCreateFromText" },
{ "name": "OH_Drawing_TextBlobCreateFromPosText" },
@@ -566,6 +723,18 @@
"first_introduced": "12",
"name": "OH_Drawing_DestroyTextShadows"
},
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RegionCreate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RegionDestroy"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RegionSetRect"
+ },
{
"first_introduced": "12",
"name": "OH_Drawing_SetTypographyTextFontFamily"
@@ -574,5 +743,4 @@
"first_introduced": "12",
"name": "OH_Drawing_SetTypographyTextFontHeight"
}
-
]
\ No newline at end of file