diff --git a/graphic/graphic_2d/native_drawing/BUILD.gn b/graphic/graphic_2d/native_drawing/BUILD.gn index fa8656ce602ccb00e10ab6b31e2f470ad1b93fa6..b2d95f17811ca7db61937c0f7a5a0be7620ddf23 100644 --- a/graphic/graphic_2d/native_drawing/BUILD.gn +++ b/graphic/graphic_2d/native_drawing/BUILD.gn @@ -46,6 +46,8 @@ ohos_ndk_headers("native_drawing_header") { "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_sampling_options.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_shader_effect.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_shadow_layer.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_picture_recorder.h", + "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_picture.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_surface.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_blob.h", "//interface/sdk_c/graphic/graphic_2d/native_drawing/drawing_text_declaration.h", @@ -90,6 +92,8 @@ ohos_ndk_library("libnative_drawing_ndk") { "native_drawing/drawing_sampling_options.h", "native_drawing/drawing_shader_effect.h", "native_drawing/drawing_shadow_layer.h", + "native_drawing/drawing_picture_recorder.h", + "native_drawing/drawing_picture.h", "native_drawing/drawing_surface.h", "native_drawing/drawing_text_blob.h", "native_drawing/drawing_text_declaration.h", diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 05d919c2499350747aab6d849feca38db6f1df7c..69b5d03c00939cccd15e25e169db52a02464240c 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -343,6 +343,17 @@ void OH_Drawing_CanvasDrawBitmapRect(OH_Drawing_Canvas*, const OH_Drawing_Bitmap */ void OH_Drawing_CanvasDrawRect(OH_Drawing_Canvas*, const OH_Drawing_Rect*); +/** + * @brief Draws a Picture. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Picture Indicates the pointer to an OH_Drawing_Picture object. + * @since 11 + * @version 1.0 + */ +void OH_Drawing_CanvasDrawPicture(OH_Drawing_Canvas*, OH_Drawing_Picture*); + /** * @brief Draws a circle. * diff --git a/graphic/graphic_2d/native_drawing/drawing_picture.h b/graphic/graphic_2d/native_drawing/drawing_picture.h new file mode 100755 index 0000000000000000000000000000000000000000..742e8e2c80be709eb5554adaeafb71e6a396cde9 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_picture.h @@ -0,0 +1,60 @@ +/* + * 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_PICTURE_H +#define C_INCLUDE_DRAWING_PICTURE_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_picture.h + * + * @brief Declares functions related to the picture object in the drawing module. + * + * @library libnative_drawing.so + * @since 12 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Destroys an OH_Drawing_PictureDestroy object. + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param picture Indicates the pointer to an OH_Drawing_Picture object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PictureDestroy(OH_Drawing_Picture* picture); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/drawing_picture_recorder.h b/graphic/graphic_2d/native_drawing/drawing_picture_recorder.h new file mode 100755 index 0000000000000000000000000000000000000000..c8648add4e9740a1e2b1c6a5799064ae7d004385 --- /dev/null +++ b/graphic/graphic_2d/native_drawing/drawing_picture_recorder.h @@ -0,0 +1,97 @@ +/* + * 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_PICTURE_RECORDER_H +#define C_INCLUDE_DRAWING_PICTURE_RECORDER_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_shadow_layer.h + * + * @brief Declares functions related to the ShadowLayer object in the drawing module. + * + * @library libnative_drawing.so + * @since 12 + * @version 1.0 + */ + +#include "drawing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates an OH_Drawing_PictureRecorder object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_Picture_Recorder object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PictureRecorder* OH_Drawing_PictureRecorderCreate(void); + +/** + * @brief Begins the recording process for a drawing operation on a specified canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param recorder Indicates the pointer to an OH_Drawing_RecordingCanvas object. + * @param width Indicates the width to set, which is a variable. + * @param height Indicates the height to set, which is a variable. + * @return Returns the pointer to the OH_Drawing_Canvas object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Canvas* OH_Drawing_BeginRecording(OH_Drawing_PictureRecorder* recorder, int32_t width, int32_t height); + +/** + * @brief Finish the recording process of the drawing recorder and obtain the recorded drawing object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_PictureRecorder Indicates the pointer to an OH_Drawing_PictureRecorder object. + * @return Returns the pointer to the OH_Drawing_Picture object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Picture* OH_Drawing_FinishingRecording(OH_Drawing_PictureRecorder* recorder); + + +/** + * @brief Destroys an OH_Drawing_PictureRecorderDestroy object . + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_PictureRecorder Indicates the pointer to an OH_Drawing_PictureRecorder object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PictureRecorderDestroy(OH_Drawing_PictureRecorder* recorder); + + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index 1f1a94aeee303a26a6a5cca863e95660ec4c0e5b..0f439a999b2c6c8e7bfee95764abd3d1e4946a25 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -196,6 +196,22 @@ typedef struct OH_Drawing_ShaderEffect OH_Drawing_ShaderEffect; */ typedef struct OH_Drawing_ShadowLayer OH_Drawing_ShadowLayer; +/** + * @brief Defines a picture, which is used to draw shaded parts. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_Picture OH_Drawing_Picture; + +/** + * @brief Defines a picture_recorder, which is used to draw shaded parts. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Drawing_PictureRecorder OH_Drawing_PictureRecorder; + /** * @brief Defines a filter, which is used to store maskFilter, colorFilter and imageFilter. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 37535bc2b3cc673a3dacd154c9366bd9cd5ed9c0..4fab5880c43c1c11ace6cc3874e39bfa416f1ff5 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -27,6 +27,12 @@ "first_introduced": "12", "name": "OH_Drawing_BrushCopy" }, + { "name": "OH_Drawing_PictureDestroy" }, + { "name": "OH_Drawing_PictureRecorderCreate" }, + { "name": "OH_Drawing_BeginRecording" }, + { "name": "OH_Drawing_FinishingRecording" }, + { "name": "OH_Drawing_PictureRecorderDestroy" }, + { "name": "OH_Drawing_CanvasDrawPicture" }, { "name": "OH_Drawing_BrushDestroy" }, { "name": "OH_Drawing_BrushGetAlpha" }, { "name": "OH_Drawing_BrushSetAlpha" },