From 10a6d8dc2ac1f163e140a5bd1b0e8c961b0f9bbc Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Thu, 29 Feb 2024 17:15:14 +0800 Subject: [PATCH] drawing interface commit 0228 Signed-off-by: lw19901203 --- graphic/graphic_2d/native_drawing/BUILD.gn | 6 + .../native_drawing/drawing_bitmap.h | 86 ++++++- .../graphic_2d/native_drawing/drawing_brush.h | 24 +- .../native_drawing/drawing_canvas.h | 153 ++++++++++- .../native_drawing/drawing_color_space.h | 80 ++++++ .../graphic_2d/native_drawing/drawing_image.h | 27 +- .../native_drawing/drawing_matrix.h | 177 +++++++++++++ .../graphic_2d/native_drawing/drawing_path.h | 224 +++++++++++++++- .../graphic_2d/native_drawing/drawing_pen.h | 24 +- .../native_drawing/drawing_pixmap.h | 83 ++++++ .../graphic_2d/native_drawing/drawing_rect.h | 133 +++++++++- .../native_drawing/drawing_region.h | 82 ++++++ .../native_drawing/drawing_shader_effect.h | 16 ++ .../native_drawing/drawing_typeface.h | 107 ++++++++ .../graphic_2d/native_drawing/drawing_types.h | 78 +++++- .../native_drawing/libnative_drawing.ndk.json | 243 +++++++++++++++++- 16 files changed, 1532 insertions(+), 11 deletions(-) create mode 100755 graphic/graphic_2d/native_drawing/drawing_color_space.h create mode 100644 graphic/graphic_2d/native_drawing/drawing_pixmap.h create mode 100644 graphic/graphic_2d/native_drawing/drawing_region.h diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 60e24af8d..bd6c65e8b 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", @@ -32,8 +33,10 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path_effect.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pixmap.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 +60,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", @@ -66,8 +70,10 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_path.h", "native_drawing/drawing_path_effect.h", "native_drawing/drawing_pen.h", + "native_drawing/drawing_pixmap.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 2540c24fb..932e6af1a 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,90 @@ void* OH_Drawing_BitmapGetPixels(OH_Drawing_Bitmap*); */ void OH_Drawing_BitmapGetImageInfo(OH_Drawing_Bitmap*, OH_Drawing_Image_Info*); +/** + * @brief Sets OH_Drawing_Image_Info to ImageInfo following the rules in setInfo(), and creates PixelRef + * containing pixels and rowBytes. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @param pixels Address or pixel storage; may be nullptr. + * @param rowBytes Size of pixel row or larger. + * @param releaseProc Function called when pixels can be deleted; may be nullptr. + * @param context Caller state passed to releaseProc; may be nullptr. + * @return Returns true if OH_Drawing_Image_Info is set to ImageInfo. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_BitmapInstallPixels(OH_Drawing_Bitmap*, const OH_Drawing_Image_Info*, void* pixels, size_t rowBytes, + void (*releaseProc)(void* addr, void* context), void*); + +/** + * @brief Copies Bitmap pixel address, row bytes, and ImageInfo to pixmap, if address + * is available, and returns true. If pixel address is not available, return + * false and leave pixmap unchanged. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param OH_Drawing_Pixmap Indicates the pointer to an OH_Drawing_Pixmap object. + * @return Returns true if Image has direct access to pixels. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_BitmapPeekPixels(OH_Drawing_Bitmap*, OH_Drawing_Pixmap*); + +/** + * @brief Sets OH_Drawing_Image_Info to ImageInfo following the rules in setInfo() and allocates pixel + * memory. + * Returns false and calls reset() if ImageInfo could not be set, or memory could + * not be allocated. + * On most platforms, allocating pixel memory may succeed even though there is + * not sufficient memory to hold pixels; allocation does not take place + * until the pixels are written to. The actual behavior depends on the platform + * implementation of malloc(). + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @return Returns true if pixel storage is allocated. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_BitmapTryAllocPixels(OH_Drawing_Bitmap*, const 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 OH_Drawing_Image_Info 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); + +/** + * @brief Returns storage required by pixel array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Return memory required by pixel buffer. + * @since 12 + * @version 1.0 + */ +size_t OH_Drawing_BitmapComputeByteSize(OH_Drawing_Bitmap*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_brush.h b/graphic/graphic_2d/native_drawing/drawing_brush.h index dca333f2d..9614febd7 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 @@ -110,6 +110,18 @@ uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush*); */ void OH_Drawing_BrushSetColor(OH_Drawing_Brush*, uint32_t color); +/** + * @brief Sets the color for a brush. The color will be used by the brush to fill in a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @param OH_Drawing_Color4f Indicates the pointer to an OH_Drawing_Color4f object. + * @param OH_Drawing_ColorSpace Indicates Indicates the pointer to an OH_Drawing_ColorSpace object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_BrushSetColor4f(OH_Drawing_Brush*, OH_Drawing_Color4f*, OH_Drawing_ColorSpace*); + /** * @brief Obtains the alpha of a brush. The alpha is used by the brush to fill in a shape. * @@ -165,6 +177,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 c65f1a813..834da2030 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,61 @@ 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 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 +448,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 +581,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 +623,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 000000000..c4627ec88 --- /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 12 + * @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_image.h b/graphic/graphic_2d/native_drawing/drawing_image.h index ed2f1f491..028006268 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 @@ -108,6 +108,31 @@ int32_t OH_Drawing_ImageGetHeight(OH_Drawing_Image*); */ void OH_Drawing_ImageGetImageInfo(OH_Drawing_Image*, OH_Drawing_Image_Info*); +/** + * @brief Gets opaque property of image. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. + * @return Returns true if image is opaque. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_ImageIsOpaque(const OH_Drawing_Image*); + +/** + * @brief Create an OH_Drawing_Image object from Pixmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param pixels The pointer to memory address or pixel storage. + * @param rasterReleaseProc Function called when pixels can be released; or nullptr. + * @param releaseContext State passed to rasterReleaseProc; or nullptr. + * @return Returns true if successed. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Image* OH_Drawing_ImageCreateFromRaster(void* pixels, + void (*rasterReleaseProc)(const void* pixels, void* releaseContext), void* releaseContext); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index 1a1bc0255..364b21ad4 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,129 @@ 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). + * 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. + * 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 +326,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 968f65c17..170b4fcee 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 */ + NO_PERSPECTIVEClIP, + /** Do pre-clip the geometry before applying the (perspective) matrix */ + YES_PERSPECTIVEClIP, +} 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 */ + APPEND_PATH_ADD_MODE, + /** Add line if prior contour is not closed */ + EXTEND_PATH_ADD_MODE, +} 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,18 @@ 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 OH_Drawing_PathDirection Indicates the path direction. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PathAddOval(OH_Drawing_Path*, const OH_Drawing_Rect*, 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 +373,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 +440,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 OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param OH_Drawing_Path 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*, const OH_Drawing_Matrix*, + OH_Drawing_Path*, OH_Drawing_PathApplyPerspectiveClip); + /** * @brief Sets FillType, the rule used to fill path. * @@ -273,6 +468,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 +490,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 3780c838c..588e62a74 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 @@ -110,6 +110,18 @@ uint32_t OH_Drawing_PenGetColor(const OH_Drawing_Pen*); */ void OH_Drawing_PenSetColor(OH_Drawing_Pen*, uint32_t color); +/** + * @brief Sets the color for a Pen. The color is used by the pen to outline a shape. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param OH_Drawing_Color4f Indicates the pointer to an OH_Drawing_Color4f object. + * @param OH_Drawing_ColorSpace Indicates Indicates the pointer to an OH_Drawing_ColorSpace object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PenSetColor4f(OH_Drawing_Pen*, OH_Drawing_Color4f*, OH_Drawing_ColorSpace*); + /** * @brief Obtains the alpha of a pen. The alpha is used by the pen to outline a shape. * @@ -313,6 +325,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_pixmap.h b/graphic/graphic_2d/native_drawing/drawing_pixmap.h new file mode 100644 index 000000000..20da72560 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_pixmap.h @@ -0,0 +1,83 @@ +/* + * 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_PIXMAP_H +#define C_INCLUDE_DRAWING_PIXMAP_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 12 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_Pixmap object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Pixmap object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Pixmap* OH_Drawing_PixmapCreate(void); + +/** + * @brief Destroys an OH_Drawing_Pixmap object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pixmap Indicates the pointer to an OH_Drawing_Pixmap object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PixmapDestroy(OH_Drawing_Pixmap*); + +/** + * @brief Obtains the width of a pixmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pixmap Indicates the pointer to an OH_Drawing_Pixmap object. + * @return Returns the width. + * @since 12 + * @version 1.0 + */ +uint32_t OH_Drawing_PixmapGetWidth(OH_Drawing_Pixmap*); + +/** + * @brief Obtains the height of a pixmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pixmap Indicates the pointer to an OH_Drawing_Pixmap object. + * @return Returns the height. + * @since 12 + * @version 1.0 + */ +uint32_t OH_Drawing_PixmapGetHeight(OH_Drawing_Pixmap*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/drawing_rect.h b/graphic/graphic_2d/native_drawing/drawing_rect.h index 3f1a1bc0e..84bb26d2c 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 OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @param OH_Drawing_Rect 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* cRect); + +/* @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* 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 OH_Drawing_Rect sRect Indicates the pointer to an OH_Drawing_Rect object. + * @param OH_Drawing_Rect 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 000000000..39ea51201 --- /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 12 + * @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 6eac17aaa..e021ddedb 100644 --- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h @@ -119,6 +119,22 @@ 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 sweep gradient given a center. + * + * @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. + * @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_typeface.h b/graphic/graphic_2d/native_drawing/drawing_typeface.h index 9498b5a1c..2acde8ba0 100644 --- a/graphic/graphic_2d/native_drawing/drawing_typeface.h +++ b/graphic/graphic_2d/native_drawing/drawing_typeface.h @@ -89,6 +89,113 @@ OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromStream(OH_Drawing_MemoryStream */ void OH_Drawing_TypefaceDestroy(OH_Drawing_Typeface*); +/** + * @brief Creates an OH_Drawing_FontMgr object, user should manage the pointer's lifecycle, + * release pointer by {@link OH_Drawing_FontMgrDestroy}. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_FontMgr object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontMgr* OH_Drawing_FontMgrCreate(void); + +/** + * @brief Destroys an OH_Drawing_FontMgr object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontMgrDestroy(OH_Drawing_FontMgr*); + +/** + * @brief Get the pointer to an OH_Drawing_FontStyleSet object for the given font style set family name, + * user should manage the pointer's lifecycle, release pointer by {@link OH_Drawing_FontStyleSetDestroy}. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param familyName The family name of a font style set to be matched. + * @return Returns the pointer to the OH_Drawing_FontStyleSet matched, + * Return the default font style set if family name is null, Return null if family name is not found. + * @since 12 + * @version 1.0 + */ +OH_Drawing_FontStyleSet* OH_Drawing_FontMgrMatchFamily(const OH_Drawing_FontMgr*, const char* familyName); + +/** + * @brief Get the pointer to an OH_Drawing_Typeface object based on the given font style and family name, + * user should manage the pointer's lifecycle, release the pointer by {@link OH_Drawing_TypefaceDestroy}. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param familyName The family name of a font style set to be matched. + * @param fontStyle Indicates the pointer to an OH_Drawing_TextFontStyle object. + * @return Returns the pointer to the OH_Drawing_Typeface object which is closest matching to 'style', + * Return the typeface in the default font style set if family name is null, + * Return null if family name is not found. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyle(const OH_Drawing_FontMgr*, const char* familyName, + const OH_Drawing_TextFontStyle* fontStyle); + +/** + * @brief Get the pointer to an OH_Drawing_Typeface object for the given character, + * user should manage the pointer's lifecycle, release the pointer by {@link OH_Drawing_TypefaceDestroy}. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontMgr Indicates the pointer to an OH_Drawing_FontMgr object. + * @param familyName The family name of a font style set to be matched. + * @param fontStyle Indicates the pointer to an OH_Drawing_FontStyle object to be matched. + * @param bcp47 An array of languages which indicate the language of 'character'. + * @param bcp47Count The array size of bcp47. + * @param character A UTF8 value to be matched. + * @return Returns the pointer to the OH_Drawing_Typeface object matched, + * Return the typeface in the default fallback set if familyName is null, + * Return null if the typeface is not found for the given character. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontMgrMatchFamilyStyleCharacter(const OH_Drawing_FontMgr*, const char familyName[], + const OH_Drawing_TextFontStyle* fontStyle, + const char* bcp47[], int bcp47Count, int32_t character); + +/** + * @brief Destroys an OH_Drawing_FontStyleSet object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_FontStyleSet Indicates the pointer to an OH_DRAWING_FontStyleSet object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontStyleSetDestroy(OH_Drawing_FontStyleSet*); + +/** + * @brief Creates an OH_Drawing_TextFontStyle object, user should manage the pointer lifecycle and + * release pointer by {@Link OH_Drawing_TextFontStyleDestroy}. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param Weight Weight of font. + * @param Width Width of font. + * @param OH_Drawing_FontStyleSlant Slant of font. + * @return Returns the pointer to the OH_Drawing_TextFontStyle object created, user need recycle pointer by + * {@link OH_Drawing_TextFontStyleDestroy}. + * @since 12 + * @version 1.0 + */ +OH_Drawing_TextFontStyle* OH_Drawing_TextFontStyleCreate(uint32_t weight, uint32_t width, OH_Drawing_FontStyleSlant); + +/** + * @brief Destroys an OH_Drawing_TextFontStyle object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextFontStyle Indicates the pointer to an OH_Drawing_TextFontStyle object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextFontStyleDestroy(OH_Drawing_TextFontStyle*); #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index 23e50f38d..fee2d5572 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,38 @@ typedef struct OH_Drawing_SamplingOptions OH_Drawing_SamplingOptions; */ typedef struct OH_Drawing_TextBlobBuilder OH_Drawing_TextBlobBuilder; +/** + * @brief Defines a OH_Drawing_FontMgr, which is used to manage font family. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontMgr OH_Drawing_FontMgr; + +/** + * @brief Defines a OH_Drawing_TextFontStyle, which is used to build the OH_Drawing_FontMgr. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_TextFontStyle OH_Drawing_TextFontStyle; + +/** + * @brief Defines a OH_Drawing_FontStyleSet, which is used to match font family. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_FontStyleSet OH_Drawing_FontStyleSet; + +/** + * @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. * @@ -400,6 +448,34 @@ typedef enum { TEXT_ENCODING_GLYPH_ID, } OH_Drawing_TextEncoding; +/** + * @brief Enumerates slant of fontStyle. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** upright slant. */ + FONTSTYLE_UPRIGHT_SLANT, + /** italic slant. */ + FONTSTYLE_ITALIC_SLANT, + /** oblique slant. */ + FONTSTYLE_OBLIQUE_SLANT, +} OH_Drawing_FontStyleSlant; + +/** + * @brief Defines a RGBA color composed of 4 floats. Color and alpha components should be in the range of zero to one. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + float red; + float green; + float blue; + float alpha; +} OH_Drawing_Color4f; + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index e076cd829..66b0c816d 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1,4 +1,8 @@ [ + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapComputeByteSize" + }, { "name": "OH_Drawing_BitmapCreate" }, { "name": "OH_Drawing_BitmapDestroy" }, { "name": "OH_Drawing_BitmapBuild" }, @@ -10,6 +14,26 @@ "name": "OH_Drawing_BitmapGetImageInfo" }, { "name": "OH_Drawing_BitmapGetPixels" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapGetImageInfo" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapInstallPixels" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapPeekPixels" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapReadPixels" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapTryAllocPixels" + }, { "name": "OH_Drawing_BrushCreate" }, { "name": "OH_Drawing_BrushDestroy" }, { "name": "OH_Drawing_BrushGetAlpha" }, @@ -19,8 +43,16 @@ { "name": "OH_Drawing_BrushSetAntiAlias" }, { "name": "OH_Drawing_BrushGetColor" }, { "name": "OH_Drawing_BrushSetColor" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BrushSetColor4f" + }, { "name": "OH_Drawing_BrushSetFilter" }, { "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 +72,43 @@ { "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" }, @@ -82,13 +141,70 @@ { "name": "OH_Drawing_FontSetTypeface" }, { "name": "OH_Drawing_FontGetMetrics" }, { "name": "OH_Drawing_FontGetTypeface" }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontMgrCreate" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontMgrDestroy" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontMgrMatchFamily" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontMgrMatchFamilyStyle" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontMgrMatchFamilyStyleCharacter" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontStyleSetDestroy" + }, { "name": "OH_Drawing_MaskFilterCreateBlur" }, { "name": "OH_Drawing_MaskFilterDestroy" }, { "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 +226,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_PathAddOval" + }, { "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" }, @@ -128,6 +300,10 @@ { "name": "OH_Drawing_PenSetAntiAlias" }, { "name": "OH_Drawing_PenGetColor" }, { "name": "OH_Drawing_PenSetColor" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PenSetColor4f" + }, { "name": "OH_Drawing_PenGetWidth" }, { "name": "OH_Drawing_PenSetWidth" }, { "name": "OH_Drawing_PenGetMiterLimit" }, @@ -142,9 +318,41 @@ "first_introduced": "12", "name": "OH_Drawing_PenSetPathEffect" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PenReset" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PixmapCreate" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PixmapDestroy" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PixmapGetWidth" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PixmapGetHeight" + }, { "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 +379,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" }, @@ -181,6 +393,14 @@ { "name": "OH_Drawing_TextBlobBuilderDestroy" }, { "name": "OH_Drawing_TextBlobBuilderMake" }, { "name": "OH_Drawing_TextBlobDestroy" }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextFontStyleCreate" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_TextFontStyleDestroy" + }, { "name": "OH_Drawing_MemoryStreamCreate" }, { "name": "OH_Drawing_MemoryStreamDestroy" }, { "name": "OH_Drawing_TypefaceCreateDefault" }, @@ -208,6 +428,10 @@ { "name": "OH_Drawing_ImageBuildFromBitmap" }, { "name": "OH_Drawing_ImageGetWidth" }, { "name": "OH_Drawing_ImageGetHeight" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageIsOpaque" + }, { "first_introduced": "12", "name": "OH_Drawing_TextStyleGetShadowWithIndex" @@ -248,6 +472,10 @@ "first_introduced": "12", "name": "OH_Drawing_ImageGetImageInfo" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageCreateFromRaster" + }, { "name": "OH_Drawing_SamplingOptionsCreate" }, { "name": "OH_Drawing_SamplingOptionsDestroy" }, { @@ -566,6 +794,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 +814,4 @@ "first_introduced": "12", "name": "OH_Drawing_SetTypographyTextFontHeight" } - ] \ No newline at end of file -- Gitee