/*
* 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.
*/
/**
* @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.
*
* @kit ArkGraphics2D
* @library libnative_window.so
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @since 8
* @version 1.0
*/
#ifndef NDK_INCLUDE_EXTERNAL_NATIVE_WINDOW_H_
#define NDK_INCLUDE_EXTERNAL_NATIVE_WINDOW_H_
#include
#include "buffer_handle.h"
#include "../native_buffer/buffer_common.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OH_NativeBuffer OH_NativeBuffer;
/**
* @brief Defines the ipc parcel.
*
* @since 12
* @version 1.0
*/
typedef struct OHIPCParcel OHIPCParcel;
/**
* @brief native window.
* @since 8
*/
struct NativeWindow;
/**
* @brief native window buffer.
* @since 8
*/
struct NativeWindowBuffer;
/**
* @brief define the new type name OHNativeWindow for struct NativeWindow.
* @since 8
*/
typedef struct NativeWindow OHNativeWindow;
/**
* @brief define the new type name OHNativeWindowBuffer for struct NativeWindowBuffer.
* @since 8
*/
typedef struct NativeWindowBuffer OHNativeWindowBuffer;
/**
* @brief indicates a dirty region where content is updated.
* @since 8
*/
typedef struct Region {
/** if rects is nullptr, fill the Buffer dirty size by default */
struct Rect {
int32_t x;
int32_t y;
uint32_t w;
uint32_t h;
} *rects;
/** if rectNumber is 0, fill the Buffer dirty size by default */
int32_t rectNumber;
}Region;
/**
* @brief Indicates the operation code in the function OH_NativeWindow_NativeWindowHandleOpt.
* @since 8
*/
typedef enum NativeWindowOperation {
/**
* set native window buffer geometry,
* variable parameter in function is
* [in] int32_t width, [in] int32_t height
*/
SET_BUFFER_GEOMETRY,
/**
* get native window buffer geometry,
* variable parameter in function is
* [out] int32_t *height, [out] int32_t *width
*/
GET_BUFFER_GEOMETRY,
/**
* get native window buffer format,
* variable parameter in function is
* [out] int32_t *format, the enumeration value refers to {@link OH_NativeBuffer_Format}.
*/
GET_FORMAT,
/**
* set native window buffer format,
* variable parameter in function is
* [in] int32_t format, the enumeration value refers to {@link OH_NativeBuffer_Format}.
*/
SET_FORMAT,
/**
* get native window buffer usage,
* variable parameter in function is
* [out] uint64_t *usage, the enumeration value refers to {@link OH_NativeBuffer_Usage}.
*/
GET_USAGE,
/**
* set native window buffer usage,
* variable parameter in function is
* [in] uint64_t usage, the enumeration value refers to {@link OH_NativeBuffer_Usage}.
*/
SET_USAGE,
/**
* set native window buffer stride,
* variable parameter in function is
* [in] int32_t stride.
* @deprecated since 16
*/
SET_STRIDE,
/**
* get native window buffer stride,
* variable parameter in function is
* [out] int32_t *stride.
* @deprecated since 16
* @useinstead Use {@link OH_NativeWindow_GetBufferHandleFromNative} to get a {@link BufferHandleand} from a buffer
* and then retrieve the stride from the {@link BufferHandle}.
*/
GET_STRIDE,
/**
* set native window buffer swap interval,
* variable parameter in function is
* [in] int32_t interval.
*/
SET_SWAP_INTERVAL,
/**
* get native window buffer swap interval,
* variable parameter in function is
* [out] int32_t *interval.
*/
GET_SWAP_INTERVAL,
/**
* set the timeout in milliseconds when the native window requests a buffer,
* the default value is 3000 milliseconds when not set,
* variable parameter in function is
* [in] int32_t timeout, in milliseconds.
*/
SET_TIMEOUT,
/**
* get the timeout in milliseconds when the native window requests a buffer,
* the default value is 3000 milliseconds when not set,
* variable parameter in function is
* [out] int32_t *timeout, in milliseconds.
*/
GET_TIMEOUT,
/**
* set native window buffer colorGamut,
* variable parameter in function is
* [in] int32_t colorGamut, the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}.
*/
SET_COLOR_GAMUT,
/**
* get native window buffer colorGamut,
* variable parameter in function is
* [out] int32_t *colorGamut, the enumeration value refers to {@link OH_NativeBuffer_ColorGamut}.
*/
GET_COLOR_GAMUT,
/**
* set native window buffer transform,
* variable parameter in function is
* [in] int32_t transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}.
*/
SET_TRANSFORM,
/**
* get native window buffer transform,
* variable parameter in function is
* [out] int32_t *transform, the enumeration value refers to {@link OH_NativeBuffer_TransformType}.
*/
GET_TRANSFORM,
/**
* set native window buffer uiTimestamp,
* variable parameter in function is
* [in] uint64_t uiTimestamp.
*/
SET_UI_TIMESTAMP,
/**
* get native window bufferqueue size,
* variable parameter in function is
* [out] int32_t *size.
* @since 12
*/
GET_BUFFERQUEUE_SIZE,
/**
* set surface source type,
* variable parameter in function is
* [in] int32_t sourceType, the enumeration value refers to {@link OHSurfaceSource}.
* @since 12
*/
SET_SOURCE_TYPE,
/**
* get surface source type,
* variable parameter in function is
* [out] int32_t *sourceType, the enumeration value refers to {@link OHSurfaceSource}.
* @since 12
*/
GET_SOURCE_TYPE,
/**
* set app framework type,
* variable parameter in function is
* [in] char* frameworkType. maximum length is 64 bytes, otherwise the setting fails.
* @since 12
*/
SET_APP_FRAMEWORK_TYPE,
/**
* get app framework type,
* variable parameter in function is
* [out] char** frameworkType.
* @since 12
*/
GET_APP_FRAMEWORK_TYPE,
/**
* set hdr white point brightness,
* variable parameter in function is
* [in] float brightness. the value range is 0.0f to 1.0f.
* @since 12
*/
SET_HDR_WHITE_POINT_BRIGHTNESS,
/**
* set sdr white point brightness,
* variable parameter in function is
* [in] float brightness. the value range is 0.0f to 1.0f.
* @since 12
*/
SET_SDR_WHITE_POINT_BRIGHTNESS,
/**
* Set native window buffer desiredPresentTimestamp, indicates the desired time to present the buffer.\n
* Which should be generated by std::chrono::steady_clock in nanoseconds.\n
* It is only effective when RenderService is the consumer.\n
* The buffer will wait until desiredPresentTimestamp is reached before being consumed and displayed.\n
* If multiple buffers reach desiredPresentTimestamp, the earlier buffer will be dropped.\n
* This Operation should be called before calling OH_NativeWindow_NativeWindowFlushBuffer.\n
* If desiredPresentTimestamp is greater than 1 second of the consumer-provided timestamp,
* the desiredPresentTimestamp will be ignored.\n
* Variable parameter in function is
* [in] int64_t desiredPresentTimestamp.
* @since 13
*/
SET_DESIRED_PRESENT_TIMESTAMP = 24,
} NativeWindowOperation;
/**
* @brief Indicates Scaling Mode.
* @since 9
* @deprecated(since = "10")
* @useinstead OHScalingModeV2
*/
typedef enum {
/**
* the window content is not updated until a buffer of
* the window size is received
*/
OH_SCALING_MODE_FREEZE = 0,
/**
* the buffer is scaled in two dimensions to match the window size
*/
OH_SCALING_MODE_SCALE_TO_WINDOW,
/**
* the buffer is uniformly scaled so that the smaller size of
* the buffer matches the window size
*/
OH_SCALING_MODE_SCALE_CROP,
/**
* the window is clipped to the size of the buffer's clipping rectangle
* pixels outside the clipping rectangle are considered fully transparent.
*/
OH_SCALING_MODE_NO_SCALE_CROP,
} OHScalingMode;
/**
* @brief Indicates Scaling Mode.
* @since 12
*/
typedef enum {
/**
* the window content is not updated until a buffer of
* the window size is received
*/
OH_SCALING_MODE_FREEZE_V2 = 0,
/**
* the buffer is scaled in two dimensions to match the window size
*/
OH_SCALING_MODE_SCALE_TO_WINDOW_V2,
/**
* the buffer is uniformly scaled so that the smaller size of
* the buffer matches the window size
*/
OH_SCALING_MODE_SCALE_CROP_V2,
/**
* the window is clipped to the size of the buffer's clipping rectangle
* pixels outside the clipping rectangle are considered fully transparent.
*/
OH_SCALING_MODE_NO_SCALE_CROP_V2,
/**
* Adapt to the buffer and scale proportionally to the buffer size. Prioritize displaying all buffer content.
* If the size is not the same as the window size, fill the unfilled area of the window with a background color.
*/
OH_SCALING_MODE_SCALE_FIT_V2,
} OHScalingModeV2;
/**
* @brief Enumerates the HDR metadata keys.
* @since 9
* @deprecated(since = "10")
*/
typedef enum {
OH_METAKEY_RED_PRIMARY_X = 0,
OH_METAKEY_RED_PRIMARY_Y = 1,
OH_METAKEY_GREEN_PRIMARY_X = 2,
OH_METAKEY_GREEN_PRIMARY_Y = 3,
OH_METAKEY_BLUE_PRIMARY_X = 4,
OH_METAKEY_BLUE_PRIMARY_Y = 5,
OH_METAKEY_WHITE_PRIMARY_X = 6,
OH_METAKEY_WHITE_PRIMARY_Y = 7,
OH_METAKEY_MAX_LUMINANCE = 8,
OH_METAKEY_MIN_LUMINANCE = 9,
OH_METAKEY_MAX_CONTENT_LIGHT_LEVEL = 10,
OH_METAKEY_MAX_FRAME_AVERAGE_LIGHT_LEVEL = 11,
OH_METAKEY_HDR10_PLUS = 12,
OH_METAKEY_HDR_VIVID = 13,
} OHHDRMetadataKey;
/**
* @brief Defines the HDR metadata.
* @since 9
* @deprecated(since = "10")
*/
typedef struct {
OHHDRMetadataKey key;
float value;
} OHHDRMetaData;
/**
* @brief Defines the ExtData Handle
* @since 9
* @deprecated(since = "10")
*/
typedef struct OHExtDataHandle {
/**< Handle fd, -1 if not supported */
int32_t fd;
/**< the number of reserved integer value */
uint32_t reserveInts;
/**< the reserved data */
int32_t reserve[0];
} OHExtDataHandle;
/**
* @brief Indicates the source type of surface.
* @since 12
*/
typedef enum {
/*
* the default source type of surface.
*/
OH_SURFACE_SOURCE_DEFAULT = 0,
/*
* the surface is created by ui.
*/
OH_SURFACE_SOURCE_UI,
/*
* the surface is created by game.
*/
OH_SURFACE_SOURCE_GAME,
/*
* the surface is created by camera.
*/
OH_SURFACE_SOURCE_CAMERA,
/*
* the surface is created by video.
*/
OH_SURFACE_SOURCE_VIDEO,
} OHSurfaceSource;
/**
* @brief Creates a OHNativeWindow instance. A new OHNativeWindow 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 OHNativeWindow instance created.
* @since 8
* @version 1.0
* @deprecated since 12
*/
OHNativeWindow* OH_NativeWindow_CreateNativeWindow(void* pSurface);
/**
* @brief Decreases the reference count of a OHNativeWindow instance by 1,
* and when the reference count reaches 0, destroys the instance.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @since 8
* @version 1.0
*/
void OH_NativeWindow_DestroyNativeWindow(OHNativeWindow* window);
/**
* @brief Creates a OHNativeWindowBuffer instance. A new OHNativeWindowBuffer 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 OHNativeWindowBuffer instance created.
* @since 8
* @version 1.0
* @deprecated since 12
* @useinstead OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer
*/
OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromSurfaceBuffer(void* pSurfaceBuffer);
/**
* @brief Creates a OHNativeWindowBuffer instance.\n
* A new OHNativeWindowBuffer instance is created each time this function is called.\n
* This interface needs to be used in conjunction with OH_NativeWindow_DestroyNativeWindowBuffer,
* otherwise memory leaks will occur.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param nativeBuffer Indicates the pointer to a native buffer. The type is OH_NativeBuffer*.
* @return Returns the pointer to the OHNativeWindowBuffer instance created.
* @since 11
* @version 1.0
*/
OHNativeWindowBuffer* OH_NativeWindow_CreateNativeWindowBufferFromNativeBuffer(OH_NativeBuffer* nativeBuffer);
/**
* @brief Decreases the reference count of a OHNativeWindowBuffer instance by 1 and,
* when the reference count reaches 0, destroys the instance.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
* @since 8
* @version 1.0
*/
void OH_NativeWindow_DestroyNativeWindowBuffer(OHNativeWindowBuffer* buffer);
/**
* @brief Requests a OHNativeWindowBuffer through a OHNativeWindow instance for content production.\n
* Before calling this interface, you need to set the width and height of
* OHNativeWindow through SET_BUFFER_GEOMETRY.\n
* This interface needs to be used in conjunction with OH_NativeWindow_NativeWindowFlushBuffer,
* otherwise buffer will be exhausted.\n
* When the fenceFd is used up, you need to close it.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param buffer Indicates the double pointer to a OHNativeWindowBuffer instance.
* @param fenceFd Indicates the pointer to a file descriptor handle.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 8
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowRequestBuffer(OHNativeWindow *window,
OHNativeWindowBuffer **buffer, int *fenceFd);
/**
* @brief Flushes the OHNativeWindowBuffer filled with the content to the buffer queue
* through a OHNativeWindow instance for content consumption.\n
* The fenceFd will be close by system.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param buffer Indicates the pointer to a OHNativeWindowBuffer 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, 0 is success, otherwise, failed.
* @since 8
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowFlushBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer,
int fenceFd, Region region);
/**
* @brief Get the last flushed OHNativeWindowBuffer from a OHNativeWindow instance.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param buffer Indicates the pointer to a OHNativeWindowBuffer pointer.
* @param fenceFd Indicates the pointer to a file descriptor handle.
* @param matrix Indicates the retrieved 4*4 transform matrix.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 11
* @version 1.0
* @deprecated since 12
* @useinstead OH_NativeWindow_GetLastFlushedBufferV2
*/
int32_t OH_NativeWindow_GetLastFlushedBuffer(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
int *fenceFd, float matrix[16]);
/**
* @brief Returns the OHNativeWindowBuffer to the buffer queue through a OHNativeWindow instance,
* without filling in any content. The OHNativeWindowBuffer can be used for another request.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 8
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowAbortBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
/**
* @brief Sets or obtains the attributes of a native window, including the width, height, and content format.\n
* This interface is a non-thread-safe type interface.\n
*
* API Note
*
* Performance Note
*
By default, the window buffer in the current operating system is accessed via the CPU. If an application
* does not need to access the window buffer data using the CPU, it can proactively disable CPU access to
* enhance energy efficiency and reduce power consumption.
*
* For details about how to optimize power consumption for data read/write operations in data buffers,
* see [How do I proactively disable CPU access to window buffers to reduce power consumption?]{@link https://developer.huawei.com/consumer/en/doc/harmonyos-faqs/faqs-arkgraphics-2d-14}.
*
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param code Indicates the operation code, pointer to NativeWindowOperation.
* @param ... variable parameter, must correspond to code one-to-one.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 8
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowHandleOpt(OHNativeWindow *window, int code, ...);
/**
* @brief Obtains the pointer to a BufferHandle of a OHNativeWindowBuffer instance.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
* @return Returns the pointer to the BufferHandle instance obtained.
* @since 8
* @version 1.0
*/
BufferHandle *OH_NativeWindow_GetBufferHandleFromNative(OHNativeWindowBuffer *buffer);
/**
* @brief Adds the reference count of a native object.\n
* This interface needs to be used in conjunction with OH_NativeWindow_NativeObjectUnreference,
* otherwise memory leaks will occur.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param obj Indicates the pointer to a OHNativeWindow or OHNativeWindowBuffer instance.
* @return Returns an error code, 0 is success, otherwise, failed.
* @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.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param obj Indicates the pointer to a OHNativeWindow or OHNativeWindowBuffer instance.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 8
* @version 1.0
*/
int32_t OH_NativeWindow_NativeObjectUnreference(void *obj);
/**
* @brief Obtains the magic ID of a native object.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param obj Indicates the pointer to a OHNativeWindow or OHNativeWindowBuffer 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);
/**
* @brief Sets scalingMode of a native window.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param sequence Indicates the sequence to a produce buffer.
* @param scalingMode Indicates the enum value to OHScalingMode
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 9
* @version 1.0
* @deprecated(since = "10")
* @useinstead OH_NativeWindow_NativeWindowSetScalingModeV2
*/
int32_t OH_NativeWindow_NativeWindowSetScalingMode(OHNativeWindow *window, uint32_t sequence,
OHScalingMode scalingMode);
/**
* @brief Sets metaData of a native window.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param sequence Indicates the sequence to a produce buffer.
* @param size Indicates the size of a OHHDRMetaData vector.
* @param metaDate Indicates the pointer to a OHHDRMetaData vector.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 9
* @version 1.0
* @deprecated(since = "10")
*/
int32_t OH_NativeWindow_NativeWindowSetMetaData(OHNativeWindow *window, uint32_t sequence, int32_t size,
const OHHDRMetaData *metaData);
/**
* @brief Sets metaDataSet of a native window.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param sequence Indicates the sequence to a produce buffer.
* @param key Indicates the enum value to OHHDRMetadataKey
* @param size Indicates the size of a uint8_t vector.
* @param metaDate Indicates the pointer to a uint8_t vector.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 9
* @version 1.0
* @deprecated(since = "10")
*/
int32_t OH_NativeWindow_NativeWindowSetMetaDataSet(OHNativeWindow *window, uint32_t sequence, OHHDRMetadataKey key,
int32_t size, const uint8_t *metaData);
/**
* @brief Sets tunnel handle of a native window.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param handle Indicates the pointer to a OHExtDataHandle.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 9
* @version 1.0
* @deprecated(since = "10")
*/
int32_t OH_NativeWindow_NativeWindowSetTunnelHandle(OHNativeWindow *window, const OHExtDataHandle *handle);
/**
* @brief Attach a buffer to an OHNativeWindow instance.\n
* This interface needs to be used in conjunction with OH_NativeWindow_NativeWindowDetachBuffer,
* otherwise buffer management will be chaotic.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to an OHNativeWindow instance.
* @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
/**
* @brief Detach a buffer from an OHNativeWindow instance.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to an OHNativeWindow instance.
* @param buffer Indicates the pointer to a OHNativeWindowBuffer instance.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
/**
* @brief Get surfaceId from native window.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to an OHNativeWindow instance.
* @param surfaceId Indicates the pointer to a surfaceId.
* @return Returns an error code, 0 is success, otherwise, failed.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId);
/**
* @brief Creates an OHNativeWindow instance.\n
* This interface needs to be used in conjunction with OH_NativeWindow_DestroyNativeWindow,
* otherwise memory leaks will occur.\n
* If there is a concurrent destroy OHNativeWindow, you need to add once and decrement once to the
* OHNativeWindow reference count through OH_NativeWindow_NativeObjectReference and
* OH_NativeWindow_NativeObjectUnreference.\n
* If the surface obtained through surfaceId is created in this process, the surface cannot be obtained
* across processes.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param surfaceId Indicates the surfaceId to a surface.
* @param window indicates the pointer to an OHNativeWindow instance.
* @return Returns an error code, 0 is Success, otherwise, failed.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window);
/**
* @brief Sets scalingMode of a native window.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window indicates the pointer to an OHNativeWindow instance.
* @param scalingMode Indicates the enum value to OHScalingModeV2
* @return Returns an error code, 0 is Success, otherwise, failed.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_NativeWindowSetScalingModeV2(OHNativeWindow *window, OHScalingModeV2 scalingMode);
/**
* @brief Set native window buffer hold.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to an OHNativeWindow instance.
* @since 12
* @version 1.0
*/
void OH_NativeWindow_SetBufferHold(OHNativeWindow *window);
/**
* @brief Write an OHNativeWindow to an OHIPCParcel.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to an OHNativeWindow instance.
* @param parcel Indicates the pointer to an OHIPCParcel instance.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or window is NULL.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_WriteToParcel(OHNativeWindow *window, OHIPCParcel *parcel);
/**
* @brief Read an OHNativeWindow from an OHIPCParcel.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param parcel Indicates the pointer to an OHIPCParcel instance.
* @param window Indicates the pointer to an OHNativeWindow instance.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - parcel is NULL or parcel does not contain the window.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_ReadFromParcel(OHIPCParcel *parcel, OHNativeWindow **window);
/**
* @brief Get the last flushed OHNativeWindowBuffer from an OHNativeWindow instance.\n
* When the fenceFd is used up, you need to close it.\n
* This interface needs to be used in conjunction with OH_NativeWindow_NativeObjectUnreference,
* otherwise memory leaks will occur.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to an OHNativeWindow instance.
* @param buffer Indicates the pointer to an OHNativeWindowBuffer pointer.
* @param fenceFd Indicates the pointer to a file descriptor handle.
* @param matrix Indicates the retrieved 4*4 transform matrix.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL or buffer is NULL or fenceFd is NULL.
* {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - buffer state is wrong.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_GetLastFlushedBufferV2(OHNativeWindow *window, OHNativeWindowBuffer **buffer,
int *fenceFd, float matrix[16]);
/**
* @brief Set the color space of the native window.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param colorSpace Indicates the color space of native window, see OH_NativeBuffer_ColorSpace.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.
* {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_SetColorSpace(OHNativeWindow *window, OH_NativeBuffer_ColorSpace colorSpace);
/**
* @brief Get the color space of the native window.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param colorSpace Indicates the color space of native window, see OH_NativeBuffer_ColorSpace.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.
* {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_GetColorSpace(OHNativeWindow *window, OH_NativeBuffer_ColorSpace *colorSpace);
/**
* @brief Set the metadata type of the native window.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param metadataKey Indicates the metadata type of native window, see OH_NativeBuffer_MetadataKey.
* @param size Indicates the size of a uint8_t vector.
* @param metadata Indicates the pointer to a uint8_t vector.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window or metadata is NULL.
* {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state.
* {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_SetMetadataValue(OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey,
int32_t size, uint8_t *metadata);
/**
* @brief Set the metadata type of the native window.\n
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @param metadataKey Indicates the metadata type of native window, see OH_NativeBuffer_MetadataKey.
* @param size Indicates the size of a uint8_t vector.
* @param metadata Indicates the pointer to a uint8_t vector.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window, metadata, or size is NULL.
* {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state.
* {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key.
* @since 12
* @version 1.0
*/
int32_t OH_NativeWindow_GetMetadataValue(OHNativeWindow *window, OH_NativeBuffer_MetadataKey metadataKey,
int32_t *size, uint8_t **metadata);
/**
* @brief Clean all OHNativeWindowBuffer caches of this OHNativeWindow
* This interface is a non-thread-safe type interface.\n
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeWindow
* @param window Indicates the pointer to a OHNativeWindow instance.
* @return {@link NATIVE_ERROR_OK} 0 - Success.
* {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - window is NULL.
* {@link NATIVE_ERROR_CONSUMER_DISCONNECTED} 41211000 - the consumer is disconnected.
* {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed.
* @since 19
* @version 1.0
*/
int32_t OH_NativeWindow_CleanCache(OHNativeWindow *window);
#ifdef __cplusplus
}
#endif
/** @} */
#endif