diff --git a/en/native_sdk/graphic/.gitignore b/en/native_sdk/graphic/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/en/native_sdk/graphic/external_window.h b/en/native_sdk/graphic/external_window.h new file mode 100644 index 0000000000000000000000000000000000000000..9f0d475f64290fc9b8026935eac5900df8b2259f --- /dev/null +++ b/en/native_sdk/graphic/external_window.h @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2021-2022 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 NDK_INCLUDE_EXTERNAL_NATIVE_WINDOW_H_ +#define NDK_INCLUDE_EXTERNAL_NATIVE_WINDOW_H_ + +/** + * @addtogroup NativeWindow + * @{ + * + * @brief Provides the native window capability for connection to the EGL. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @since 8 + * @version 1.0 + */ + +/** + * @file external_window.h + * + * @brief Defines the functions for obtaining and using a native window. + * + * @since 8 + * @version 1.0 + */ + +#include "window.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Creates a NativeWindow instance. A new NativeWindow instance is created each time this function is called. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param pSurface Indicates the pointer to a ProduceSurface. The type is a pointer to sptr. + * @return Returns the pointer to the NativeWindow instance created. + * @since 8 + * @version 1.0 + */ +struct NativeWindow* OH_NativeWindow_CreateNativeWindowFromSurface(void* pSurface); + +/** + * @brief Decreases the reference count of a NativeWindow instance by 1, and when the reference count reaches 0, destroys the instance. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to a NativeWindow instance. + * @since 8 + * @version 1.0 + */ +void OH_NativeWindow_DestroyNativeWindow(struct NativeWindow* window); + +/** + * @brief Creates a NativeWindowBuffer instance. A new NativeWindowBuffer instance is created each time this function is called. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param pSurfaceBuffer Indicates the pointer to a produce buffer. The type is sptr. + * @return Returns the pointer to the NativeWindowBuffer instance created. + * @since 8 + * @version 1.0 + */ +struct NativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer); + +/** + * @brief Decreases the reference count of a NativeWindowBuffer instance by 1 and, when the reference count reaches 0, destroys the instance. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param buffer Indicates the pointer to a NativeWindowBuffer instance. + * @since 8 + * @version 1.0 + */ +void OH_NativeWindow_DestroyNativeWindowBuffer(struct NativeWindowBuffer* buffer); + +/** + * @brief Requests a NativeWindowBuffer through a NativeWindow instance for content production. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to a NativeWindow instance. + * @param buffer Indicates the double pointer to a NativeWindowBuffer instance. + * @param fenceFd Indicates the pointer to a file descriptor handle. + * @return Returns an error code defined in GSError. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_NativeWindowRequestBuffer(struct NativeWindow *window, + struct NativeWindowBuffer **buffer, int *fenceFd); + +/** + * @brief Flushes the NativeWindowBuffer filled with the content to the buffer queue through a NativeWindow instance for content consumption. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to a NativeWindow instance. + * @param buffer Indicates the pointer to a NativeWindowBuffer instance. + * @param fenceFd Indicates a file descriptor handle, which is used for timing synchronization. + * @param region Indicates a dirty region where content is updated. + * @return Returns an error code defined in GSError. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_NativeWindowFlushBuffer(struct NativeWindow *window, struct NativeWindowBuffer *buffer, + int fenceFd, Region region); + +/** + * @brief Returns the NativeWindowBuffer to the buffer queue through a NativeWindow instance, without filling in any content. The NativeWindowBuffer can be used for another request. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to a NativeWindow instance. + * @param buffer Indicates the pointer to a NativeWindowBuffer instance. + * @return Returns an error code defined in GSError. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_NativeWindowCancelBuffer(struct NativeWindow *window, struct NativeWindowBuffer *buffer); + +/** + * @brief Sets or obtains the attributes of a native window, including the width, height, and content format. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param window Indicates the pointer to a NativeWindow instance. + * @param code Indicates the operation code. + * @return Returns an error code defined in GSError. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_NativeWindowHandleOpt(struct NativeWindow *window, int code, ...); + +/** + * @brief Obtains the pointer to a BufferHandle of a NativeWindowBuffer instance. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param buffer Indicates the pointer to a NativeWindowBuffer instance. + * @return Returns the pointer to the BufferHandle instance obtained. + * @since 8 + * @version 1.0 + */ +BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(struct NativeWindowBuffer *buffer); + +/** + * @brief Adds the reference count of a native object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param obj Indicates the pointer to a NativeWindow or NativeWindowBuffer instance. + * @return Returns an error code defined in GSError. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_NativeObjectReference(void *obj); + +/** + * @brief Decreases the reference count of a native object and, when the reference count reaches 0, destroys this object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param obj Indicates the pointer to a NativeWindow or NativeWindowBuffer instance. + * @return Returns an error code defined in GSError. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_NativeObjectUnreference(void *obj); + +/** + * @brief Obtains the magic ID of a native object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow + * @param obj Indicates the pointer to a NativeWindow or NativeWindowBuffer instance. + * @return Returns the magic ID, which is unique for each native object. + * @since 8 + * @version 1.0 + */ +int32_t OH_NativeWindow_GetNativeObjectMagic(void *obj); + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif diff --git a/zh-cn/native_sdk/graphic/external_window.h b/zh-cn/native_sdk/graphic/external_window.h index d61204ac2e20ec1c61d38e6e232fb6262ab438ba..e5b722555917503e9c4a93c176fe5b7f31acf9e8 100644 --- a/zh-cn/native_sdk/graphic/external_window.h +++ b/zh-cn/native_sdk/graphic/external_window.h @@ -46,7 +46,7 @@ extern "C" { * @brief 创建NativeWindow实例,每次调用都会产生一个新的NativeWindow实例 * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow - * @param pSurface 参数是一个指向生产者ProduceSurface的指针,类型为Surface + * @param pSurface 参数是一个指向生产者ProduceSurface的指针,类型为sptr * @return 返回一个指针,指向NativeWindow的结构体实例 * @since 8 * @version 1.0 @@ -64,10 +64,10 @@ struct NativeWindow* OH_NativeWindow_CreateNativeWindowFromSurface(void* pSurfac void OH_NativeWindow_DestroyNativeWindow(struct NativeWindow* window); /** - * @brief 创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindow实例 + * @brief 创建NativeWindowBuffer实例,每次调用都会产生一个新的NativeWindowBuffer实例 * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow - * @param pSurfaceBuffer 参数是一个指向生产者buffer的指针,类型为SurfaceBuffer + * @param pSurfaceBuffer 参数是一个指向生产者buffer的指针,类型为sptr * @return 返回一个指针,指向NativeWindowBuffer的结构体实例 * @since 8 * @version 1.0 @@ -89,8 +89,8 @@ void OH_NativeWindow_DestroyNativeWindowBuffer(struct NativeWindowBuffer* buffer * * @syscap SystemCapability.Graphic.Graphic2D.NativeWindow * @param window 参数是一个NativeWindow的结构体实例的指针 - * @param buffer 参数是一个NativeWindowBuffer的结构体实例的二级指针,作为出参传入 - * @param fenceFd 参数是一个文件描述符句柄,作为出参传入 + * @param buffer 参数是一个NativeWindowBuffer的结构体实例的二级指针 + * @param fenceFd 参数是一个文件描述符句柄 * @return GSError 返回值为错误码 * @since 8 * @version 1.0