diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index 44f9f3218dcef5fc46550c6f659ff930ec0a5591..55ef6d0e8b1131c738d96bf049f46a6480676c63 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -27,6 +27,7 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_font_collection.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_mask_filter.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_matrix.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_memory_stream.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_path.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_pen.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_point.h", @@ -58,6 +59,7 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_font_collection.h", "native_drawing/drawing_mask_filter.h", "native_drawing/drawing_matrix.h", + "native_drawing/drawing_memory_stream.h", "native_drawing/drawing_path.h", "native_drawing/drawing_pen.h", "native_drawing/drawing_point.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index cc37815899750dae0d247397f59ebc3db6e23256..374b0061038ac32b64f394678e6c4bda2fa593f5 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -129,6 +129,19 @@ void OH_Drawing_CanvasDetachBrush(OH_Drawing_Canvas*); */ void OH_Drawing_CanvasSave(OH_Drawing_Canvas*); +/** + * @brief Saves matrix and clip, and allocates a bitmap for subsequent drawing. + * Calling restore discards changes to matrix and clip, and draws the bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_CanvasSaveLayer(OH_Drawing_Canvas*, const OH_Drawing_Rect*, const OH_Drawing_Brush*); + /** * @brief Restores the canvas status (canvas matrix) saved on the top of the stack. * diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 5c02a704d0b24f8fc6aaa4051878280e0643edea..6949e5f32af93fa1f7a577471d75084846342b56 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -64,6 +64,28 @@ OH_Drawing_Font* OH_Drawing_FontCreate(void); */ void OH_Drawing_FontSetTypeface(OH_Drawing_Font*, OH_Drawing_Typeface*); +/** + * @brief Gets an OH_Drawing_Typeface object from the OH_Drawing_Typeface object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @return OH_Drawing_Typeface Indicates the pointer to an OH_Drawing_Typeface object. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_FontGetTypeface(OH_Drawing_Font*); + +/** + * @brief Set Font and glyph metrics should ignore hinting and rounding. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param bool Should ignore hinting and rounding. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_FontSetLinearMetrics(OH_Drawing_Font*, bool); + /** * @brief Sets text size for an OH_Drawing_Font object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index 8ae3da4c2e141737926d18b59c7ca4e3c851e741..1aa849bcd2a019aec8a742a61d9747be379f04d8 100644 --- a/graphic/graphic_2d/native_drawing/drawing_matrix.h +++ b/graphic/graphic_2d/native_drawing/drawing_matrix.h @@ -53,6 +53,49 @@ extern "C" { */ OH_Drawing_Matrix* OH_Drawing_MatrixCreate(void); +/** + * @brief Creates an OH_Drawing_Matrix object with rotation. Sets matrix to + * rotate by degrees 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 deg angle of axes relative to upright axes + * @param x pivot on x-axis. + * @param y pivot on y-axis. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Matrix* OH_Drawing_MatrixCreateRotation(float deg, float x, float y); + +/** + * @brief Creates an OH_Drawing_Matrix object with scale. Sets matrix to 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 created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Matrix* OH_Drawing_MatrixCreateScale(float sx, float sy, float px, float py); + +/** + * @brief Creates an OH_Drawing_Matrix object with translation. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param dx horizontal translation. + * @param dy vertical translation. + * @return Returns the pointer to the OH_Drawing_Matrix object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Matrix* OH_Drawing_MatrixCreateTranslation(float dx, float dy); + /** * @brief Sets the params for a matrix. * @@ -73,6 +116,103 @@ OH_Drawing_Matrix* OH_Drawing_MatrixCreate(void); 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 Sets matrix to matrix multiplied by matrix other. + * Given: + * | A B C | | J K L | + * Matrix = | D E F |, other = | M N O | + * | G H I | | P Q R | + * sets Matrix to: + * + * | A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | + * Matrix * other = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | + * | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR | + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param other Indicates the pointer to an OH_Drawing_Matrix object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_MatrixPreConcat(OH_Drawing_Matrix*, OH_Drawing_Matrix* other); + +/** + * @brief Sets matrix to rotate by degrees about a pivot point at (px, py). The pivot point is unchanged + * when mapped with matrix. Positive degrees rotates clockwise. + * + * @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_MatrixRotate(OH_Drawing_Matrix*, float degree, float px, float py); + +/** + * @brief Sets 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_MatrixTranslate(OH_Drawing_Matrix*, float dx, float dy); + +/** + * @brief Sets matrix to 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 Indicates the horizontal scale factor. + * @param sy Indicates the vertical scale factor. + * @param px Indicates the pivot on x-axis. + * @param py Indicates the pivot on y-axis. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_MatrixScale(OH_Drawing_Matrix*, float sx, float sy, float px, float py); + +/** + * @brief Sets inverse to reciprocal matrix, returning true if matrix can be inverted. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param inverse Indicates the pointer to an OH_Drawing_Matrix object. + * @return Returns true if matrix can be inverted, or flase. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_MatrixInvert(OH_Drawing_Matrix*, OH_Drawing_Matrix* inverse); + +/** + * @brief Returns true if the first matrix equals the second matrix. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param other Indicates the pointer to an OH_Drawing_Matrix object. + * @return Returns true if the two matrices are equal, or flase. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_MatrixIsEqual(OH_Drawing_Matrix*, OH_Drawing_Matrix* other); + +/** + * @brief Returns true if matrix is identity. + * Identity matrix is : | 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. + * @return Returns true if matrix is identity, or flase. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_MatrixIsIdentity(OH_Drawing_Matrix*); + /** * @brief Destroys an OH_Drawing_Matrix object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_memory_stream.h b/graphic/graphic_2d/native_drawing/drawing_memory_stream.h new file mode 100644 index 0000000000000000000000000000000000000000..4abafe9fe36464cb34aaf7ff54dfeecedc2fa6c3 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_memory_stream.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2023 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_MEMORY_STREAM_H +#define C_INCLUDE_DRAWING_MEMORY_STREAM_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_memory_stream.h + * + * @brief Declares functions related to the memoryStream object in the drawing module. + * + * @since 12 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates a OH_Drawing_MemoryStream object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_MemoryStream object created. + * @param data file path. + * @param length Data length. + * @param copyData Copy data or not. + * @since 12 + * @version 1.0 + */ +OH_Drawing_MemoryStream* OH_Drawing_MemoryStreamCreate(const void* data, size_t length, bool copyData); + +/** + * @brief Destroys an OH_Drawing_MemoryStream object and reclaims the memory occupied by the object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_MemoryStream Indicates the pointer to an OH_Drawing_MemoryStream object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_MemoryStreamDestroy(OH_Drawing_MemoryStream*); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/drawing_path.h b/graphic/graphic_2d/native_drawing/drawing_path.h index 5f5e34a1a12d6f17be39477e7000656e0a7ba2c1..104ecbb9f4ecf1fde0498181c0e75574f0d04fda 100644 --- a/graphic/graphic_2d/native_drawing/drawing_path.h +++ b/graphic/graphic_2d/native_drawing/drawing_path.h @@ -43,6 +43,36 @@ extern "C" { #endif +/** + * @brief Direction for adding closed contours. + * + * @since 11 + * @version 1.0 + */ +typedef enum { + /** clockwise direction for adding closed contours */ + PATH_DIRECTION_CW, + /** counter-clockwise direction for adding closed contours */ + PATH_DIRECTION_CCW, +} OH_Drawing_PathDirection; + +/** + * @brief FillType of path + * + * @since 11 + * @version 1.0 + */ +typedef enum { + /** Specifies that "inside" is computed by a non-zero sum of signed edge crossings */ + PATH_FILL_TYPE_WINDING, + /** Specifies that "inside" is computed by an odd number of edge crossings */ + PATH_FILL_TYPE_EVEN_ODD, + /** Same as Winding, but draws outside of the path, rather than inside */ + PATH_FILL_TYPE_INVERSE_WINDING, + /** Same as EvenOdd, but draws outside of the path, rather than inside */ + PATH_FILL_TYPE_INVERSE_EVEN_ODD, +} OH_Drawing_PathFillType; + /** * @brief Creates an OH_Drawing_Path object. * @@ -53,6 +83,17 @@ extern "C" { */ OH_Drawing_Path* OH_Drawing_PathCreate(void); +/** + * @brief Creates an OH_Drawing_Path copy object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Rect object. + * @return Returns the pointer to the OH_Drawing_Path object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Path* OH_Drawing_PathCopy(OH_Drawing_Path*); + /** * @brief Destroys an OH_Drawing_Path object and reclaims the memory occupied by the object. * @@ -139,6 +180,99 @@ 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 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 left Indicates the left coordinate of the upper left corner of the rectangle. + * @param top Indicates the top coordinate of the upper top corner of the rectangle. + * @param right Indicates the right coordinate of the lower right corner of the rectangle. + * @param bottom Indicates the bottom coordinate of the lower bottom corner of the rectangle. + * @param OH_Drawing_PathDirection Indicates the path direction. + * @since 12 + * @version 1.0 + */ +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 round 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_RoundRect Indicates the pointer to an OH_Drawing_RoundRect object. + * @param OH_Drawing_PathDirection Indicates the path direction. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PathAddRoundRect(OH_Drawing_Path*, const OH_Drawing_RoundRect* roundRect, 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 + * is aligned with the positive x-axis, and positive sweeps extends arc clockwise.If sweepAngle <= -360, or + * sweepAngle >= 360; and startAngle modulo 90 is nearly zero, append oval instead of arc. Otherwise, sweepAngle + * values are treated modulo 360, and arc may or may not draw depending on numeric rounding. + * + * @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 startAngle Indicates the starting angle of arc in degrees. + * @param sweepAngle Indicates the sweep, in degrees. Positive is clockwise. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PathAddArc(OH_Drawing_Path*, const OH_Drawing_Rect*, float startAngle, float sweepAngle); + +/** + * @brief Appends src path to path, transformed by matrix. 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. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PathAddPath(OH_Drawing_Path*, const OH_Drawing_Path* src, const OH_Drawing_Matrix*); + +/** + * @brief Return the status that point (x, y) is contained by path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param x Indicates the x-axis value of containment test. + * @param y Indicates the y-axis value of containment test. + * @return Returns true if the point (x, y) is contained by path. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_PathContains(OH_Drawing_Path*, float x, float y); + +/** + * @brief Transforms verb array, point array, and weight by matrix. transform may change verbs + * and increase their number. path is replaced by transformed data. + * + * @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. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PathTransform(OH_Drawing_Path*, const OH_Drawing_Matrix*); + +/** + * @brief Sets FillType, the rule used to fill path. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param OH_Drawing_PathFillType Indicates the add path's fill type. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_SetFillStyle(OH_Drawing_Path*, OH_Drawing_PathFillType); + /** * @brief Closes a path. A line segment from the start point to the last point of the path is added. * diff --git a/graphic/graphic_2d/native_drawing/drawing_text_blob.h b/graphic/graphic_2d/native_drawing/drawing_text_blob.h index 73325b032013affd46f05212499dcf3f6d30f9c0..5993b89eb220b932b8d13a8a070d9ead4d594122 100644 --- a/graphic/graphic_2d/native_drawing/drawing_text_blob.h +++ b/graphic/graphic_2d/native_drawing/drawing_text_blob.h @@ -43,6 +43,22 @@ extern "C" { #endif +/** + * @brief Enumerates text encoding. + * @since 12 + * @version 1.0 + */ +typedef enum { + /** uses bytes to represent UTF-8 or ASCII */ + TEXT_ENCODING_UTF8, + /** uses two byte words to represent most of Unicode */ + TEXT_ENCODING_UTF16, + /** uses four byte words to represent all of Unicode */ + TEXT_ENCODING_UTF32, + /** uses two byte words to represent glyph indices */ + TEXT_ENCODING_GLYPH_ID, +} OH_Drawing_TextEncoding; + /** * @brief Creates an OH_Drawing_TextBlobBuilder object. * @@ -53,6 +69,62 @@ extern "C" { */ OH_Drawing_TextBlobBuilder* OH_Drawing_TextBlobBuilderCreate(void); +/** + * @brief Creates an OH_Drawing_TextBlob object from text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param text Indicates the the pointer to text. + * @param byteLength Indicates the text length. + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param OH_Drawing_TextEncoding Indicates the pointer to an OH_Drawing_TextEncoding object. + * @return Returns the pointer to the OH_Drawing_TextBlob object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_TextBlob* OH_Drawing_TextBlobCreateFromText(const void* text, size_t byteLength, + const OH_Drawing_Font*, OH_Drawing_TextEncoding); + +/** + * @brief Creates an OH_Drawing_TextBlob object from pos text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param text Indicates the the pointer to text. + * @param byteLength Indicates the text length. + * @param OH_Drawing_Point Indicates the points. + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param OH_Drawing_TextEncoding Indicates the pointer to an OH_Drawing_TextEncoding object. + * @return Returns the pointer to the OH_Drawing_TextBlob object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_TextBlob* OH_Drawing_TextBlobCreateFromPosText(const void* text, size_t byteLength, + OH_Drawing_Point* points, const OH_Drawing_Font*, OH_Drawing_TextEncoding); + +/** + * @brief Creates an OH_Drawing_TextBlob object from pos text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param str Indicates the the pointer to text. + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param OH_Drawing_TextEncoding Indicates the pointer to an OH_Drawing_TextEncoding object. + * @return Returns the pointer to the OH_Drawing_TextBlob object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_TextBlob* OH_Drawing_TextBlobCreateFromString(const char* str, + const OH_Drawing_Font*, OH_Drawing_TextEncoding); + +/** + * @brief Gets the bounds of textblob, assigned to the pointer to an OH_Drawing_Rect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_TextBlob Indicates the pointer to an OH_Drawing_TextBlob object. + * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_TextBlobGetBounds(OH_Drawing_TextBlob*, OH_Drawing_Rect*); + /** * @brief Defines a run, supplies storage for glyphs and positions. * diff --git a/graphic/graphic_2d/native_drawing/drawing_typeface.h b/graphic/graphic_2d/native_drawing/drawing_typeface.h index a484d70f2d560d9865122a46c2fd1d68a32be856..9498b5a1cee64dc0741f7d30b0543fa4f5673abe 100644 --- a/graphic/graphic_2d/native_drawing/drawing_typeface.h +++ b/graphic/graphic_2d/native_drawing/drawing_typeface.h @@ -53,6 +53,32 @@ extern "C" { */ OH_Drawing_Typeface* OH_Drawing_TypefaceCreateDefault(void); +/** + * @brief Creates a OH_Drawing_Typeface object by file. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path file path. + * @param index file index. + * @return Returns the pointer to the OH_Drawing_Typeface object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromFile(const char* path, int index); + +/** + * @brief Creates a OH_Drawing_Typeface object by given a stream. If the stream is not a valid + * font file, returns nullptr. Ownership of the stream is transferred, so the caller must not reference + * it or free it again. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_MemoryStream Indicates the pointer to an OH_Drawing_MemoryStream object. + * @param index memory stream index. + * @return Returns the pointer to the OH_Drawing_Typeface object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Typeface* OH_Drawing_TypefaceCreateFromStream(OH_Drawing_MemoryStream*, int32_t index); + /** * @brief Destroys an OH_Drawing_Typeface 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 cdf7f35cc7738dc86e91aa114147e4e10c70f3ef..d79276b45d3e0ff1ec2d68f27e09ba76c62bdc0c 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -38,6 +38,7 @@ */ #include +#include #ifdef __cplusplus extern "C" { @@ -156,6 +157,14 @@ typedef struct OH_Drawing_ColorFilter OH_Drawing_ColorFilter; */ typedef struct OH_Drawing_Font OH_Drawing_Font; +/** + * @brief Defines a memoryStream, which is used to describe the memory stream. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_MemoryStream OH_Drawing_MemoryStream; + /** * @brief Defines a typeface, which is used to describe the typeface. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 314e98b4190bd230729f7e365372eca4559d92d7..66b5389295421df3131e04c913bbe2925d2d268d 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -23,6 +23,7 @@ { "name": "OH_Drawing_CanvasAttachBrush" }, { "name": "OH_Drawing_CanvasDetachBrush" }, { "name": "OH_Drawing_CanvasSave" }, + { "name": "OH_Drawing_CanvasSaveLayer" }, { "name": "OH_Drawing_CanvasRestore" }, { "name": "OH_Drawing_CanvasGetSaveCount" }, { "name": "OH_Drawing_CanvasRestoreToCount" }, @@ -59,18 +60,38 @@ { "name": "OH_Drawing_FontSetTextSize" }, { "name": "OH_Drawing_FontSetTextSkewX" }, { "name": "OH_Drawing_FontSetTypeface" }, + { "name": "OH_Drawing_FontGetTypeface" }, + { "name": "OH_Drawing_FontSetLinearMetrics" }, { "name": "OH_Drawing_MaskFilterCreateBlur" }, { "name": "OH_Drawing_MaskFilterDestroy" }, { "name": "OH_Drawing_MatrixCreate" }, + { "name": "OH_Drawing_MatrixCreateRotation" }, + { "name": "OH_Drawing_MatrixCreateScale" }, + { "name": "OH_Drawing_MatrixCreateTranslation" }, { "name": "OH_Drawing_MatrixSetMatrix" }, + { "name": "OH_Drawing_MatrixPreConcat" }, + { "name": "OH_Drawing_MatrixRotate" }, + { "name": "OH_Drawing_MatrixTranslate" }, + { "name": "OH_Drawing_MatrixScale" }, + { "name": "OH_Drawing_MatrixInvert" }, + { "name": "OH_Drawing_MatrixIsEqual" }, + { "name": "OH_Drawing_MatrixIsIdentity" }, { "name": "OH_Drawing_MatrixDestroy" }, { "name": "OH_Drawing_PathCreate" }, + { "name": "OH_Drawing_PathCopy" }, { "name": "OH_Drawing_PathDestroy" }, { "name": "OH_Drawing_PathMoveTo" }, { "name": "OH_Drawing_PathLineTo" }, { "name": "OH_Drawing_PathArcTo" }, { "name": "OH_Drawing_PathQuadTo" }, { "name": "OH_Drawing_PathCubicTo" }, + { "name": "OH_Drawing_PathAddRect" }, + { "name": "OH_Drawing_PathAddRoundRect" }, + { "name": "OH_Drawing_PathAddArc" }, + { "name": "OH_Drawing_PathAddPath" }, + { "name": "OH_Drawing_PathContains" }, + { "name": "OH_Drawing_PathTransform" }, + { "name": "OH_Drawing_SetFillStyle" }, { "name": "OH_Drawing_PathClose" }, { "name": "OH_Drawing_PathReset" }, { "name": "OH_Drawing_PenCreate" }, @@ -121,12 +142,20 @@ { "name": "OH_Drawing_ShaderEffectCreateRadialGradient" }, { "name": "OH_Drawing_ShaderEffectCreateSweepGradient" }, { "name": "OH_Drawing_ShaderEffectDestroy" }, + { "name": "OH_Drawing_TextBlobCreateFromText" }, + { "name": "OH_Drawing_TextBlobCreateFromPosText" }, + { "name": "OH_Drawing_TextBlobCreateFromString" }, + { "name": "OH_Drawing_TextBlobGetBounds" }, { "name": "OH_Drawing_TextBlobBuilderAllocRunPos" }, { "name": "OH_Drawing_TextBlobBuilderCreate" }, { "name": "OH_Drawing_TextBlobBuilderDestroy" }, { "name": "OH_Drawing_TextBlobBuilderMake" }, { "name": "OH_Drawing_TextBlobDestroy" }, + { "name": "OH_Drawing_MemoryStreamCreate" }, + { "name": "OH_Drawing_MemoryStreamDestroy" }, { "name": "OH_Drawing_TypefaceCreateDefault" }, + { "name": "OH_Drawing_TypefaceCreateFromFile" }, + { "name": "OH_Drawing_TypefaceCreateFromStream" }, { "name": "OH_Drawing_TypefaceDestroy" }, { "name": "OH_Drawing_CreateTypographyHandler" }, { "name": "OH_Drawing_DestroyTypographyHandler" },