diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index f4ba43a3231d40be0e78cba1dd72e539284520fe..fa8656ce602ccb00e10ab6b31e2f470ad1b93fa6 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -23,6 +23,7 @@ ohos_ndk_headers("native_drawing_header") { "//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_error_code.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", @@ -66,6 +67,7 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_color.h", "native_drawing/drawing_color_filter.h", "native_drawing/drawing_color_space.h", + "native_drawing/drawing_error_code.h", "native_drawing/drawing_filter.h", "native_drawing/drawing_font.h", "native_drawing/drawing_font_collection.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index a98e15828ee9a684c615ec5515d183127472b4d5..9535f48c5a0aa3f14bc11a81b3a9a8f6193edefe 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -570,7 +570,7 @@ typedef enum { */ SHADOW_FLAGS_GEOMETRIC_ONLY, /** - * Use all shadow falgs. + * Use all shadow flags. */ SHADOW_FLAGS_ALL, } OH_Drawing_CanvasShadowFlags; diff --git a/graphic/graphic_2d/native_drawing/drawing_error_code.h b/graphic/graphic_2d/native_drawing/drawing_error_code.h new file mode 100644 index 0000000000000000000000000000000000000000..779a60ca71d7498307604a899ca8e43f53b3df91 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_error_code.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_ERROR_CODE_H +#define C_INCLUDE_DRAWING_ERROR_CODE_H + +/** + * @addtogroup Drawing + * @{ + * + * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * + * @since 8 + * @version 1.0 + */ + +/** + * @file drawing_error_code.h + * + * @brief Declares functions related to the error code in the drawing module. + * + * @library libnative_drawing.so + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 12 + * @version 1.0 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates error codes of drawing. + * @since 12 + */ +typedef enum { + /** + * @error Operation completed successfully. + */ + OH_DRAWING_SUCCESS = 0, + /** + * @error Permission verification failed. + */ + OH_DRAWING_ERROR_NO_PERMISSION = 201, + /** + * @error Invalid input parameter. For example, the pointer in the parameter is a nullptr. + */ + OH_DRAWING_ERROR_INVALID_PARAMETER = 401, + /** + * @error The parameter is not in the valid range. + */ + OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE = 26200001, +} OH_Drawing_ErrorCode; + +/** + * @brief Obtains the error code of the drawing module. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the error code. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ErrorCode OH_Drawing_ErrorCodeGet(); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 0fe56c1d5f23a2f4eaa43e7d222b5669450d38f4..28fec472377c8b6f99daa131f89cf144b253811b 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -404,7 +404,7 @@ OH_Drawing_FontEdging OH_Drawing_FontGetEdging(const OH_Drawing_Font*); void OH_Drawing_FontDestroy(OH_Drawing_Font*); /** - * @brief Defines a run, supplies storage for the metrics of an SkFont. + * @brief Defines a run, supplies storage for the metrics of an OH_Drawing_Font. * * @since 12 * @version 1.0 diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index e26f2fb4937f2f7554e9f7c48de3b05da9006b8b..103788eba0cdac9e76dfc9f96f00f2074b3547ab 100644 --- a/graphic/graphic_2d/native_drawing/drawing_matrix.h +++ b/graphic/graphic_2d/native_drawing/drawing_matrix.h @@ -412,7 +412,8 @@ void OH_Drawing_MatrixScale(OH_Drawing_Matrix*, float sx, float sy, float px, fl * @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. + * @return Returns true if the matrix is not nullptr and can be inverted; + * returns false if the matrix is nullptr or cannot be inverted. * @since 12 * @version 1.0 */ @@ -467,7 +468,7 @@ bool OH_Drawing_MatrixMapRect(const OH_Drawing_Matrix*, const OH_Drawing_Rect* s * @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. + * @return Returns true if the two matrices are equal; returns false if not equal. * @since 12 * @version 1.0 */ @@ -481,7 +482,7 @@ bool OH_Drawing_MatrixIsEqual(OH_Drawing_Matrix*, OH_Drawing_Matrix* other); * * @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. + * @return Returns true if matrix is identity; returns false if not identity. * @since 12 * @version 1.0 */ diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index 572625aa7432e6c7e48635ff4b2a5334ebb4dafa..d671444a3a42c3b2e4b6bea5083cf6c4af16d84d 100644 --- a/graphic/graphic_2d/native_drawing/drawing_region.h +++ b/graphic/graphic_2d/native_drawing/drawing_region.h @@ -113,7 +113,7 @@ bool OH_Drawing_RegionContains(OH_Drawing_Region* region, int32_t x, int32_t y); bool OH_Drawing_RegionOp(OH_Drawing_Region* region, const OH_Drawing_Region* dst, OH_Drawing_RegionOpMode op); /** - * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object. + * @brief Sets the region to the specified rect. * * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object. diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index def9cec8cc3437144df84fbefbbdd15d2f5f31c6..2e2483c275f266c50a09a3255c18bde7ec96f687 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -132,6 +132,10 @@ { "name": "OH_Drawing_ColorFilterCreateMatrix" }, { "name": "OH_Drawing_ColorFilterCreateSrgbGammaToLinear" }, { "name": "OH_Drawing_ColorFilterDestroy" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ErrorCodeGet" + }, { "name": "OH_Drawing_FilterCreate" }, { "name": "OH_Drawing_FilterSetColorFilter" }, {