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..2707635f91eb4c961c69f6434937f93086f1d297 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,23 @@ 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 and height.
+ *
+ * @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.
+ * @since 12
+ * @version 1.0
+ */
+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..74d09b503b392abaa3fbe9400427e3c9d51d1b96 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 all brush contents to their initial values.
+ *
+ * @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..521c93ec67a1c08f5ea97b344bd52bc35e5b8930 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,23 @@
extern "C" {
#endif
+/**
+ * @brief Enumeration defines the constraint type.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /**
+ * Using sampling only inside bounds in a slower manner.
+ */
+ STRICT_SRC_RECT_CONSTRAINT,
+ /**
+ * Using sampling outside bounds in a faster manner.
+ */
+ FAST_SRC_RECT_CONSTRAINT,
+} OH_Drawing_SrcRectConstraint;
+
/**
* @brief Creates an OH_Drawing_Canvas object.
*
@@ -199,6 +216,64 @@ 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 Fills clipped canvas area with brush.
+ *
+ * @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 region using clip, matrix and paint.
+ *
+ * @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 Enumerates of scale to fit flags, selects if an array of points are drawn as discrete points, as lines,
+ * or as an open polygon.
+ *
+ * @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 as separate point, line segment or open polygon according to given point mode.
+ *
+ * @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 +455,18 @@ void OH_Drawing_CanvasTranslate(OH_Drawing_Canvas*, float dx, float dy);
*/
void OH_Drawing_CanvasScale(OH_Drawing_Canvas*, float sx, float sy);
+/**
+ * @brief Skew 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 skew on x-axis.
+ * @param sy Indicates the amount to skew on y-axis.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_CanvasSkew(OH_Drawing_Canvas*, float sx, float sy);
+
/**
* @brief Get the width of a canvas.
*
@@ -501,6 +588,34 @@ void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color);
*/
void OH_Drawing_CanvasSetMatrix(OH_Drawing_Canvas*, OH_Drawing_Matrix*);
+/**
+ * @brief Reset matrix to the idenmtity matrix, any prior matrix state is overwritten.
+ *
+ * @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*, const OH_Drawing_Image*,
+ const OH_Drawing_Rect* src, const OH_Drawing_Rect* dst, const 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 +631,46 @@ 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 Enumerates of vertices flags.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /**
+ * The vertices are a triangle list.
+ */
+ VERTEX_MODE_TRIANGLES,
+ /**
+ * The vertices are a triangle strip.
+ */
+ VERTEX_MODE_TRIANGLES_STRIP,
+ /**
+ * The vertices are a triangle fan.
+ */
+ VERTEX_MODE_TRIANGLE_FAN,
+} OH_Drawing_VertexMode;
+
+/**
+ * @brief Draw a triangular mesh with vertex descriptions.
+ *
+ * @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,
+ const uint32_t* colors, int32_t indexCount, const 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..46efa2b0f36c4e1d335be796474f408f56260508
--- /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(void);
+
+/**
+ * @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(void);
+
+/**
+ * @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_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h
index 1a1bc0255d3aa91b50b53880699fe9613e1dc029..a2ae15adb71f0f23aa0520788fac83f85cbae2a8 100644
--- a/graphic/graphic_2d/native_drawing/drawing_matrix.h
+++ b/graphic/graphic_2d/native_drawing/drawing_matrix.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
@@ -116,6 +116,225 @@ OH_Drawing_Matrix* OH_Drawing_MatrixCreateTranslation(float dx, float dy);
void OH_Drawing_MatrixSetMatrix(OH_Drawing_Matrix*, float scaleX, float skewX, float transX,
float skewY, float scaleY, float transY, float persp0, float persp1, float persp2);
+/**
+ * @brief Enumerates of scale to fit flags, how matrix is constructed to map one rect to another.
+ *
+ * @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.
+ *
+ * @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 Returns 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 forward scale by sx and sy, about a pivot point at (px, py).
+ * Given:
+ *
+ * | A B C | | sx 0 dx |
+ * Matrix =| D E F |, S(sx, sy, px, py) = | 0 sy dy |
+ * | G H I | | 0 0 1 |
+ *
+ * where:
+ *
+ * dx = px - sx * px
+ * dy = py - sy * py
+ *
+ * sets Matrix to:
+ *
+ * | A B C | | sx 0 dx | | A*sx B*sy A*dx+B*dy+C |
+ * Matrix * S(sx, sy, px, py) = | D E F | | 0 sy dy | = | D*sx E*sy D*dx+E*dy+F |
+ * | G H I | | 0 0 1 | | G*sx H*sy G*dx+H*dy+I |
+ *
+ * @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.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixPreScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py);
+
+/**
+ * @brief Sets forward matrix to translate by dx and dy.
+ * Given:
+ * | A B C | | 1 0 dx |
+ * Matrix = | D E F |, T(dx, dy) = | 0 1 dy |
+ * | G H I | | 0 0 1 |
+ * sets Matrix to:
+ * | A B C | | 1 0 dx | | A B A*dx+B*dy+C |
+ * Matrix * T(dx, dy) = | D E F | | 0 1 dy | = | D E D*dx+E*dy+F |
+ * | G H I | | 0 0 1 | | G H G*dx+H*dy+I |
+ *
+ * @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 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 backward scale by sx and sy, about a pivot point at (px, py).
+ * Given:
+ * | J K L | | sx 0 dx |
+ * Matrix = | M N O |, S(sx, sy, px, py) = | 0 sy dy |
+ * | P Q R | | 0 0 1 |
+ * where:
+ * dx = px - sx * px
+ * dy = py - sy * py
+ * sets Matrix to:
+ * | sx 0 dx | | J K L | | sx*J+dx*P sx*K+dx*Q sx*L+dx+R |
+ * S(sx, sy, px, py) * Matrix = | 0 sy dy | | M N O | = | sy*M+dy*P sy*N+dy*Q sy*O+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 sx Horizontal scale factor.
+ * @param sy Vertical scale factor.
+ * @param px Pivot on x-axis.
+ * @param py Pivot on y-axis.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_MatrixPostScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py);
+
+/**
+ * @brief Sets backward matrix to translate by (dx, dy).
+ * Given:
+ *
+ * | J K L | | 1 0 dx |
+ * Matrix = | M N O |, T(dx, dy) = | 0 1 dy |
+ * | P Q R | | 0 0 1 |
+ *
+ * sets Matrix to:
+ *
+ * | 1 0 dx | | J K L | | J+dx*P K+dx*Q L+dx*R |
+ * T(dx, dy) * Matrix = | 0 1 dy | | M N O | = | M+dy*P N+dy*Q O+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 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 Reset 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 total to matrix a multiplied by matrix b.
* Given:
diff --git a/graphic/graphic_2d/native_drawing/drawing_path.h b/graphic/graphic_2d/native_drawing/drawing_path.h
index 968f65c17060c9c76579411f62587ec5d5e7c3f5..687bdf780d8f6b4088538e684b42ecc40090dfe1 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,7 @@ typedef enum {
} OH_Drawing_PathDirection;
/**
- * @brief FillType of path
+ * @brief FillType of path.
*
* @since 12
* @version 1.0
@@ -73,6 +73,19 @@ typedef enum {
PATH_FILL_TYPE_INVERSE_EVEN_ODD,
} OH_Drawing_PathFillType;
+/**
+ * @brief Add mode 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 +176,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 +208,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.
*
@@ -193,7 +291,22 @@ void OH_Drawing_PathCubicTo(
* @since 12
* @version 1.0
*/
-void OH_Drawing_PathAddRect(OH_Drawing_Path*, float left, float top, float right, float bottom, OH_Drawing_PathDirection);
+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*, const OH_Drawing_Rect*,
+ OH_Drawing_PathDirection, uint32_t start);
/**
* @brief Adds a new contour to the path, defined by the round rect, and wound in the specified direction.
@@ -207,6 +320,20 @@ 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*,
+ uint32_t 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 +364,50 @@ 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 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* 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 path Indicates the pointer to an OH_Drawing_Path object.
+ * @param src Indicates the pointer to an OH_Drawing_Path object, which is Appends src path to path.
+ * @param OH_Drawing_PathAddMode Indicates the add path's add mode.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_PathAddPathWithMode(OH_Drawing_Path* 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 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* 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 +433,21 @@ 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.
+ *
+ * @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 applyPerspectiveClip 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, bool applyPerspectiveClip);
+
/**
* @brief Sets FillType, the rule used to fill path.
*
@@ -273,6 +459,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 +481,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 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* 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..b3809f381c521baed5e0799c59d8ff48310631a8 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 all pen contents to their initial values.
+ *
+ * @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..49a7a75303eef9c4a5a44b0a5fe093260a72b97e 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
@@ -57,6 +57,137 @@ extern "C" {
*/
OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom);
+/**
+ * @brief If rect intersects other, sets rect to intersection.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param rect Indicates the pointer to an OH_Drawing_Rect object.
+ * @param other Indicates the pointer to an OH_Drawing_Rect object.
+ * @return Returns true if have area in common.
+ * @since 12
+ * @version 1.0
+ */
+bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other);
+
+/**
+ * @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 Get the height position of the rect.
+ *
+ * @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 Get the width position of the 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 Copy the original rectangular object to the destination rectangular object.
+ *
+ * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
+ * @param src Indicates the pointer to an OH_Drawing_Rect object.
+ * @param dst Indicates the pointer to an OH_Drawing_Rect object.
+ * @since 12
+ * @version 1.0
+ */
+void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst);
+
/**
* @brief Destroys an OH_Drawing_Rect object and reclaims the memory occupied by the object.
*
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..b145f999e085bd16ea5919ab203ea43e17c8de15
--- /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, const 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..3bd2368d2639045f2cf4c2f346fa6edba69ee865 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, const OH_Drawing_SamplingOptions*, const 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..1d544bec9a032f7488443baa697a118a4ddc5fd0 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 Define color space to determine color information.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Drawing_ColorSpace OH_Drawing_ColorSpace;
+
/**
* @brief Defines a point of 2d.
*
diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json
index e076cd829af17a63caeda7107214f27e9fc6d99b..60c76d48b2782e33f2660831df629474e3298e0a 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,17 +52,45 @@
{ "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_CanvasDrawImageRect" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasDrawImageRectWithSrc"
+ },
{ "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_CanvasSkew"
+ },
{ "name": "OH_Drawing_CanvasSetMatrix" },
- { "name": "OH_Drawing_CanvasDrawImageRect" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_CanvasResetMatrix"
+ },
{ "name": "OH_Drawing_CanvasReadPixels" },
{ "name": "OH_Drawing_CanvasReadPixelsToBitmap" },
{ "name": "OH_Drawing_CanvasGetWidth" },
@@ -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" },
@@ -89,6 +133,38 @@
{ "name": "OH_Drawing_MatrixCreateScale" },
{ "name": "OH_Drawing_MatrixCreateTranslation" },
{ "name": "OH_Drawing_MatrixSetMatrix" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixSetRectToRect"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixReset"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPreScale"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPreRotate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPreTranslate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPostScale"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPostRotate"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_MatrixPostTranslate"
+ },
{ "name": "OH_Drawing_MatrixConcat" },
{ "name": "OH_Drawing_MatrixGetValue" },
{ "name": "OH_Drawing_MatrixRotate" },
@@ -109,15 +185,71 @@
{ "name": "OH_Drawing_PathLineTo" },
{ "name": "OH_Drawing_PathArcTo" },
{ "name": "OH_Drawing_PathQuadTo" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_PathConicTo"
+ },
{ "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"
+ },
{ "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 +269,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" },
@@ -155,6 +307,54 @@
{ "name": "OH_Drawing_CreateTextStyle" },
{ "name": "OH_Drawing_DestroyTextStyle" },
{ "name": "OH_Drawing_RectCreate" },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectIntersect"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectSetLeft"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectSetTop"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectSetRight"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectSetBottom"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectGetLeft"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectGetTop"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectGetRight"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectGetBottom"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectGetHeight"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectGetWidth"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_Drawing_RectCopy"
+ },
{ "name": "OH_Drawing_RectDestroy" },
{ "name": "OH_Drawing_RoundRectCreate" },
{ "name": "OH_Drawing_RoundRectDestroy" },
@@ -171,6 +371,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 +770,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 +790,4 @@
"first_introduced": "12",
"name": "OH_Drawing_SetTypographyTextFontHeight"
}
-
]
\ No newline at end of file