17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef NDK_INCLUDE_NATIVE_BUFFER_H_ 177777dab0Sopenharmony_ci#define NDK_INCLUDE_NATIVE_BUFFER_H_ 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup OH_NativeBuffer 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief Provides the native buffer capability. 247777dab0Sopenharmony_ci * 257777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 267777dab0Sopenharmony_ci * @since 9 277777dab0Sopenharmony_ci * @version 1.0 287777dab0Sopenharmony_ci */ 297777dab0Sopenharmony_ci 307777dab0Sopenharmony_ci/** 317777dab0Sopenharmony_ci * @file native_buffer.h 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @brief Defines the functions for obtaining and using a native buffer. 347777dab0Sopenharmony_ci * 357777dab0Sopenharmony_ci * @kit ArkGraphics2D 367777dab0Sopenharmony_ci * @library libnative_buffer.so 377777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 387777dab0Sopenharmony_ci * @since 9 397777dab0Sopenharmony_ci * @version 1.0 407777dab0Sopenharmony_ci */ 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#include <stdint.h> 437777dab0Sopenharmony_ci#include <native_window/external_window.h> 447777dab0Sopenharmony_ci#include <native_buffer/buffer_common.h> 457777dab0Sopenharmony_ci 467777dab0Sopenharmony_ci#ifdef __cplusplus 477777dab0Sopenharmony_ciextern "C" { 487777dab0Sopenharmony_ci#endif 497777dab0Sopenharmony_ci 507777dab0Sopenharmony_cistruct OH_NativeBuffer; 517777dab0Sopenharmony_citypedef struct OH_NativeBuffer OH_NativeBuffer; 527777dab0Sopenharmony_ci 537777dab0Sopenharmony_ci/** 547777dab0Sopenharmony_ci * @brief Indicates the usage of a native buffer. 557777dab0Sopenharmony_ci * 567777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 577777dab0Sopenharmony_ci * @since 10 587777dab0Sopenharmony_ci * @version 1.0 597777dab0Sopenharmony_ci */ 607777dab0Sopenharmony_citypedef enum OH_NativeBuffer_Usage { 617777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_CPU_READ = (1ULL << 0), /// < CPU read buffer */ 627777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_CPU_WRITE = (1ULL << 1), /// < CPU write memory */ 637777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_MEM_DMA = (1ULL << 3), /// < Direct memory access (DMA) buffer */ 647777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_HW_RENDER = (1ULL << 8), /// < For GPU write case */ 657777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_HW_TEXTURE = (1ULL << 9), /// < For GPU read case */ 667777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_CPU_READ_OFTEN = (1ULL << 16), /// < Often be mapped for direct CPU reads */ 677777dab0Sopenharmony_ci NATIVEBUFFER_USAGE_ALIGNMENT_512 = (1ULL << 18), /// < 512 bytes alignment */ 687777dab0Sopenharmony_ci} OH_NativeBuffer_Usage; 697777dab0Sopenharmony_ci 707777dab0Sopenharmony_ci/** 717777dab0Sopenharmony_ci * @brief Indicates the format of a native buffer. 727777dab0Sopenharmony_ci * 737777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 747777dab0Sopenharmony_ci * @since 10 757777dab0Sopenharmony_ci * @version 1.0 767777dab0Sopenharmony_ci */ 777777dab0Sopenharmony_citypedef enum OH_NativeBuffer_Format { 787777dab0Sopenharmony_ci /** 797777dab0Sopenharmony_ci * CLUT8 format 807777dab0Sopenharmony_ci * @since 12 817777dab0Sopenharmony_ci */ 827777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_CLUT8 = 0, 837777dab0Sopenharmony_ci /** 847777dab0Sopenharmony_ci * CLUT1 format 857777dab0Sopenharmony_ci * @since 12 867777dab0Sopenharmony_ci */ 877777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_CLUT1, 887777dab0Sopenharmony_ci /** 897777dab0Sopenharmony_ci * CLUT4 format 907777dab0Sopenharmony_ci * @since 12 917777dab0Sopenharmony_ci */ 927777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_CLUT4, 937777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGB_565 = 3, /// < RGB565 format */ 947777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBA_5658, /// < RGBA5658 format */ 957777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBX_4444, /// < RGBX4444 format */ 967777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBA_4444, /// < RGBA4444 format */ 977777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGB_444, /// < RGB444 format */ 987777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBX_5551, /// < RGBX5551 format */ 997777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBA_5551, /// < RGBA5551 format */ 1007777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGB_555, /// < RGB555 format */ 1017777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBX_8888, /// < RGBX8888 format */ 1027777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBA_8888, /// < RGBA8888 format */ 1037777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGB_888, /// < RGB888 format */ 1047777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGR_565, /// < BGR565 format */ 1057777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGRX_4444, /// < BGRX4444 format */ 1067777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGRA_4444, /// < BGRA4444 format */ 1077777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGRX_5551, /// < BGRX5551 format */ 1087777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGRA_5551, /// < BGRA5551 format */ 1097777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGRX_8888, /// < BGRX8888 format */ 1107777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BGRA_8888, /// < BGRA8888 format */ 1117777dab0Sopenharmony_ci /** 1127777dab0Sopenharmony_ci * YUV422 interleaved format 1137777dab0Sopenharmony_ci * @since 12 1147777dab0Sopenharmony_ci */ 1157777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YUV_422_I, 1167777dab0Sopenharmony_ci /** 1177777dab0Sopenharmony_ci * YCBCR422 semi-plannar format 1187777dab0Sopenharmony_ci * @since 12 1197777dab0Sopenharmony_ci */ 1207777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCBCR_422_SP, 1217777dab0Sopenharmony_ci /** 1227777dab0Sopenharmony_ci * YCRCB422 semi-plannar format 1237777dab0Sopenharmony_ci * @since 12 1247777dab0Sopenharmony_ci */ 1257777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCRCB_422_SP, 1267777dab0Sopenharmony_ci /** 1277777dab0Sopenharmony_ci * YCBCR420 semi-plannar format 1287777dab0Sopenharmony_ci * @since 12 1297777dab0Sopenharmony_ci */ 1307777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCBCR_420_SP, 1317777dab0Sopenharmony_ci /** 1327777dab0Sopenharmony_ci * YCRCB420 semi-plannar format 1337777dab0Sopenharmony_ci * @since 12 1347777dab0Sopenharmony_ci */ 1357777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCRCB_420_SP, 1367777dab0Sopenharmony_ci /** 1377777dab0Sopenharmony_ci * YCBCR422 plannar format 1387777dab0Sopenharmony_ci * @since 12 1397777dab0Sopenharmony_ci */ 1407777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCBCR_422_P, 1417777dab0Sopenharmony_ci /** 1427777dab0Sopenharmony_ci * YCRCB422 plannar format 1437777dab0Sopenharmony_ci * @since 12 1447777dab0Sopenharmony_ci */ 1457777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCRCB_422_P, 1467777dab0Sopenharmony_ci /** 1477777dab0Sopenharmony_ci * YCBCR420 plannar format 1487777dab0Sopenharmony_ci * @since 12 1497777dab0Sopenharmony_ci */ 1507777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCBCR_420_P, 1517777dab0Sopenharmony_ci /** 1527777dab0Sopenharmony_ci * YCRCB420 plannar format 1537777dab0Sopenharmony_ci * @since 12 1547777dab0Sopenharmony_ci */ 1557777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCRCB_420_P, 1567777dab0Sopenharmony_ci /** 1577777dab0Sopenharmony_ci * YUYV422 packed format 1587777dab0Sopenharmony_ci * @since 12 1597777dab0Sopenharmony_ci */ 1607777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YUYV_422_PKG, 1617777dab0Sopenharmony_ci /** 1627777dab0Sopenharmony_ci * UYVY422 packed format 1637777dab0Sopenharmony_ci * @since 12 1647777dab0Sopenharmony_ci */ 1657777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_UYVY_422_PKG, 1667777dab0Sopenharmony_ci /** 1677777dab0Sopenharmony_ci * YVYU422 packed format 1687777dab0Sopenharmony_ci * @since 12 1697777dab0Sopenharmony_ci */ 1707777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YVYU_422_PKG, 1717777dab0Sopenharmony_ci /** 1727777dab0Sopenharmony_ci * VYUY422 packed format 1737777dab0Sopenharmony_ci * @since 12 1747777dab0Sopenharmony_ci */ 1757777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_VYUY_422_PKG, 1767777dab0Sopenharmony_ci /** 1777777dab0Sopenharmony_ci * RGBA_1010102 packed format 1787777dab0Sopenharmony_ci * @since 12 1797777dab0Sopenharmony_ci */ 1807777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RGBA_1010102, 1817777dab0Sopenharmony_ci /** 1827777dab0Sopenharmony_ci * YCBCR420 semi-planar 10bit packed format 1837777dab0Sopenharmony_ci * @since 12 1847777dab0Sopenharmony_ci */ 1857777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCBCR_P010, 1867777dab0Sopenharmony_ci /** 1877777dab0Sopenharmony_ci * YCRCB420 semi-planar 10bit packed format 1887777dab0Sopenharmony_ci * @since 12 1897777dab0Sopenharmony_ci */ 1907777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_YCRCB_P010, 1917777dab0Sopenharmony_ci /** 1927777dab0Sopenharmony_ci * Raw 10bit packed format 1937777dab0Sopenharmony_ci * @since 12 1947777dab0Sopenharmony_ci */ 1957777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_RAW10, 1967777dab0Sopenharmony_ci /** 1977777dab0Sopenharmony_ci * vender mask format 1987777dab0Sopenharmony_ci * @since 12 1997777dab0Sopenharmony_ci */ 2007777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_VENDER_MASK = 0X7FFF0000, 2017777dab0Sopenharmony_ci NATIVEBUFFER_PIXEL_FMT_BUTT = 0X7FFFFFFF /// < Invalid pixel format */ 2027777dab0Sopenharmony_ci} OH_NativeBuffer_Format; 2037777dab0Sopenharmony_ci 2047777dab0Sopenharmony_ci/** 2057777dab0Sopenharmony_ci * @brief Indicates the transform type of a native buffer. 2067777dab0Sopenharmony_ci * 2077777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 2087777dab0Sopenharmony_ci * @since 12 2097777dab0Sopenharmony_ci * @version 1.0 2107777dab0Sopenharmony_ci */ 2117777dab0Sopenharmony_citypedef enum OH_NativeBuffer_TransformType { 2127777dab0Sopenharmony_ci NATIVEBUFFER_ROTATE_NONE = 0, /**< No rotation */ 2137777dab0Sopenharmony_ci NATIVEBUFFER_ROTATE_90, /**< Rotation by 90 degrees */ 2147777dab0Sopenharmony_ci NATIVEBUFFER_ROTATE_180, /**< Rotation by 180 degrees */ 2157777dab0Sopenharmony_ci NATIVEBUFFER_ROTATE_270, /**< Rotation by 270 degrees */ 2167777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_H, /**< Flip horizontally */ 2177777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_V, /**< Flip vertically */ 2187777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_H_ROT90, /**< Flip horizontally and rotate 90 degrees */ 2197777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_V_ROT90, /**< Flip vertically and rotate 90 degrees */ 2207777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_H_ROT180, /**< Flip horizontally and rotate 180 degrees */ 2217777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_V_ROT180, /**< Flip vertically and rotate 180 degrees */ 2227777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_H_ROT270, /**< Flip horizontally and rotate 270 degrees */ 2237777dab0Sopenharmony_ci NATIVEBUFFER_FLIP_V_ROT270, /**< Flip vertically and rotate 270 degrees */ 2247777dab0Sopenharmony_ci} OH_NativeBuffer_TransformType; 2257777dab0Sopenharmony_ci 2267777dab0Sopenharmony_ci/** 2277777dab0Sopenharmony_ci * @brief Indicates the color gamut of a native buffer. 2287777dab0Sopenharmony_ci * 2297777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 2307777dab0Sopenharmony_ci * @since 12 2317777dab0Sopenharmony_ci * @version 1.0 2327777dab0Sopenharmony_ci */ 2337777dab0Sopenharmony_citypedef enum OH_NativeBuffer_ColorGamut { 2347777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_NATIVE = 0, /**< Native or default */ 2357777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT601 = 1, /**< Standard BT601 */ 2367777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_STANDARD_BT709 = 2, /**< Standard BT709 */ 2377777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_DCI_P3 = 3, /**< DCI P3 */ 2387777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_SRGB = 4, /**< SRGB */ 2397777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_ADOBE_RGB = 5, /**< Adobe RGB */ 2407777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_DISPLAY_P3 = 6, /**< Display P3 */ 2417777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_BT2020 = 7, /**< BT2020 */ 2427777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_BT2100_PQ = 8, /**< BT2100 PQ */ 2437777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_BT2100_HLG = 9, /**< BT2100 HLG */ 2447777dab0Sopenharmony_ci NATIVEBUFFER_COLOR_GAMUT_DISPLAY_BT2020 = 10, /**< Display BT2020 */ 2457777dab0Sopenharmony_ci} OH_NativeBuffer_ColorGamut; 2467777dab0Sopenharmony_ci 2477777dab0Sopenharmony_ci/** 2487777dab0Sopenharmony_ci * @brief <b>OH_NativeBuffer</b> config. \n 2497777dab0Sopenharmony_ci * Used to allocating new <b>OH_NativeBuffer</b> andquery parameters if existing ones. 2507777dab0Sopenharmony_ci * 2517777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 2527777dab0Sopenharmony_ci * @since 9 2537777dab0Sopenharmony_ci * @version 1.0 2547777dab0Sopenharmony_ci */ 2557777dab0Sopenharmony_citypedef struct { 2567777dab0Sopenharmony_ci int32_t width; ///< Width in pixels 2577777dab0Sopenharmony_ci int32_t height; ///< Height in pixels 2587777dab0Sopenharmony_ci int32_t format; ///< One of PixelFormat 2597777dab0Sopenharmony_ci int32_t usage; ///< Combination of buffer usage 2607777dab0Sopenharmony_ci int32_t stride; ///< the stride of memory 2617777dab0Sopenharmony_ci} OH_NativeBuffer_Config; 2627777dab0Sopenharmony_ci 2637777dab0Sopenharmony_ci/** 2647777dab0Sopenharmony_ci * @brief Holds info for a single image plane. \n 2657777dab0Sopenharmony_ci * 2667777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 2677777dab0Sopenharmony_ci * @since 12 2687777dab0Sopenharmony_ci * @version 1.0 2697777dab0Sopenharmony_ci */ 2707777dab0Sopenharmony_citypedef struct { 2717777dab0Sopenharmony_ci uint64_t offset; ///< Offset in bytes of plane. 2727777dab0Sopenharmony_ci uint32_t rowStride; ///< Distance in bytes from the first value of one row of the image to the first value of the next row. 2737777dab0Sopenharmony_ci uint32_t columnStride; ///< Distance in bytes from the first value of one column of the image to the first value of the next column. 2747777dab0Sopenharmony_ci} OH_NativeBuffer_Plane; 2757777dab0Sopenharmony_ci 2767777dab0Sopenharmony_ci/** 2777777dab0Sopenharmony_ci * @brief Holds all image planes. \n 2787777dab0Sopenharmony_ci * 2797777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 2807777dab0Sopenharmony_ci * @since 12 2817777dab0Sopenharmony_ci * @version 1.0 2827777dab0Sopenharmony_ci */ 2837777dab0Sopenharmony_citypedef struct { 2847777dab0Sopenharmony_ci uint32_t planeCount; ///< Number of distinct planes. 2857777dab0Sopenharmony_ci OH_NativeBuffer_Plane planes[4]; ///< Array of image planes. 2867777dab0Sopenharmony_ci} OH_NativeBuffer_Planes; 2877777dab0Sopenharmony_ci 2887777dab0Sopenharmony_ci/** 2897777dab0Sopenharmony_ci * @brief Alloc a <b>OH_NativeBuffer</b> that matches the passed BufferRequestConfig. \n 2907777dab0Sopenharmony_ci * A new <b>OH_NativeBuffer</b> instance is created each time this function is called.\n 2917777dab0Sopenharmony_ci * This interface needs to be used in conjunction with <b>OH_NativeBuffer_Unreference<\b>, 2927777dab0Sopenharmony_ci * otherwise memory leaks will occur.\n 2937777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 2947777dab0Sopenharmony_ci * 2957777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 2967777dab0Sopenharmony_ci * @param config Indicates the pointer to a <b>BufferRequestConfig</b> instance. 2977777dab0Sopenharmony_ci * @return Returns the pointer to the <b>OH_NativeBuffer</b> instance created if the operation is successful, \n 2987777dab0Sopenharmony_ci * returns <b>NULL</b> otherwise. 2997777dab0Sopenharmony_ci * @since 9 3007777dab0Sopenharmony_ci * @version 1.0 3017777dab0Sopenharmony_ci */ 3027777dab0Sopenharmony_ciOH_NativeBuffer* OH_NativeBuffer_Alloc(const OH_NativeBuffer_Config* config); 3037777dab0Sopenharmony_ci 3047777dab0Sopenharmony_ci/** 3057777dab0Sopenharmony_ci * @brief Adds the reference count of a OH_NativeBuffer.\n 3067777dab0Sopenharmony_ci * This interface needs to be used in conjunction with <b>OH_NativeBuffer_Unreference<\b>, 3077777dab0Sopenharmony_ci * otherwise memory leaks will occur.\n 3087777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3097777dab0Sopenharmony_ci * 3107777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3117777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3127777dab0Sopenharmony_ci * @return Returns an error code, 0 is success, otherwise, failed. 3137777dab0Sopenharmony_ci * @since 9 3147777dab0Sopenharmony_ci * @version 1.0 3157777dab0Sopenharmony_ci */ 3167777dab0Sopenharmony_ciint32_t OH_NativeBuffer_Reference(OH_NativeBuffer *buffer); 3177777dab0Sopenharmony_ci 3187777dab0Sopenharmony_ci/** 3197777dab0Sopenharmony_ci * @brief Decreases the reference count of a OH_NativeBuffer and, when the reference count reaches 0, 3207777dab0Sopenharmony_ci * destroys this OH_NativeBuffer.\n 3217777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3227777dab0Sopenharmony_ci * 3237777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3247777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3257777dab0Sopenharmony_ci * @return Returns an error code, 0 is success, otherwise, failed. 3267777dab0Sopenharmony_ci * @since 9 3277777dab0Sopenharmony_ci * @version 1.0 3287777dab0Sopenharmony_ci */ 3297777dab0Sopenharmony_ciint32_t OH_NativeBuffer_Unreference(OH_NativeBuffer *buffer); 3307777dab0Sopenharmony_ci 3317777dab0Sopenharmony_ci/** 3327777dab0Sopenharmony_ci * @brief Return a config of the OH_NativeBuffer in the passed OHNativeBufferConfig struct.\n 3337777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3347777dab0Sopenharmony_ci * 3357777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3367777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3377777dab0Sopenharmony_ci * @param config Indicates the pointer to the <b>NativeBufferConfig</b> of the buffer. 3387777dab0Sopenharmony_ci * @return <b>void</b> 3397777dab0Sopenharmony_ci * @since 9 3407777dab0Sopenharmony_ci * @version 1.0 3417777dab0Sopenharmony_ci */ 3427777dab0Sopenharmony_civoid OH_NativeBuffer_GetConfig(OH_NativeBuffer *buffer, OH_NativeBuffer_Config* config); 3437777dab0Sopenharmony_ci 3447777dab0Sopenharmony_ci/** 3457777dab0Sopenharmony_ci * @brief Provide direct cpu access to the OH_NativeBuffer in the process's address space.\n 3467777dab0Sopenharmony_ci * This interface needs to be used in conjunction with <b>OH_NativeBuffer_Unmap<\b>.\n 3477777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3487777dab0Sopenharmony_ci * 3497777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3507777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3517777dab0Sopenharmony_ci * @param virAddr Indicates the address of the <b>OH_NativeBuffer</b> in virtual memory. 3527777dab0Sopenharmony_ci * @return Returns an error code, 0 is success, otherwise, failed. 3537777dab0Sopenharmony_ci * @since 9 3547777dab0Sopenharmony_ci * @version 1.0 3557777dab0Sopenharmony_ci */ 3567777dab0Sopenharmony_ci 3577777dab0Sopenharmony_ciint32_t OH_NativeBuffer_Map(OH_NativeBuffer *buffer, void **virAddr); 3587777dab0Sopenharmony_ci 3597777dab0Sopenharmony_ci/** 3607777dab0Sopenharmony_ci * @brief Remove direct cpu access ability of the OH_NativeBuffer in the process's address space.\n 3617777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3627777dab0Sopenharmony_ci * 3637777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3647777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3657777dab0Sopenharmony_ci * @return Returns an error code, 0 is success, otherwise, failed. 3667777dab0Sopenharmony_ci * @since 9 3677777dab0Sopenharmony_ci * @version 1.0 3687777dab0Sopenharmony_ci */ 3697777dab0Sopenharmony_ciint32_t OH_NativeBuffer_Unmap(OH_NativeBuffer *buffer); 3707777dab0Sopenharmony_ci 3717777dab0Sopenharmony_ci/** 3727777dab0Sopenharmony_ci * @brief Get the systen wide unique sequence number of the OH_NativeBuffer.\n 3737777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3747777dab0Sopenharmony_ci * 3757777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3767777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3777777dab0Sopenharmony_ci * @return Returns the sequence number, which is unique for each OH_NativeBuffer. 3787777dab0Sopenharmony_ci * @since 9 3797777dab0Sopenharmony_ci * @version 1.0 3807777dab0Sopenharmony_ci */ 3817777dab0Sopenharmony_ciuint32_t OH_NativeBuffer_GetSeqNum(OH_NativeBuffer *buffer); 3827777dab0Sopenharmony_ci 3837777dab0Sopenharmony_ci/** 3847777dab0Sopenharmony_ci * @brief Provide direct cpu access to the potentially multi-plannar OH_NativeBuffer in the process's address space.\n 3857777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 3867777dab0Sopenharmony_ci * 3877777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 3887777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 3897777dab0Sopenharmony_ci * @param virAddr Indicates the address of the <b>OH_NativeBuffer</b> in virtual memory. 3907777dab0Sopenharmony_ci * @param outPlanes Indicates all image planes that contain the pixel data. 3917777dab0Sopenharmony_ci * @return Returns an error code, 0 is sucess, otherwise, failed. 3927777dab0Sopenharmony_ci * @since 12 3937777dab0Sopenharmony_ci * @version 1.0 3947777dab0Sopenharmony_ci */ 3957777dab0Sopenharmony_ciint32_t OH_NativeBuffer_MapPlanes(OH_NativeBuffer *buffer, void **virAddr, OH_NativeBuffer_Planes *outPlanes); 3967777dab0Sopenharmony_ci 3977777dab0Sopenharmony_ci/** 3987777dab0Sopenharmony_ci * @brief Converts an <b>OHNativeWindowBuffer</b> instance to an <b>OH_NativeBuffer</b>.\n 3997777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 4007777dab0Sopenharmony_ci * 4017777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 4027777dab0Sopenharmony_ci * @param nativeWindowBuffer Indicates the pointer to a <b>OHNativeWindowBuffer</b> instance. 4037777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> pointer. 4047777dab0Sopenharmony_ci * @return Returns an error code, 0 is sucess, otherwise, failed. 4057777dab0Sopenharmony_ci * @since 12 4067777dab0Sopenharmony_ci * @version 1.0 4077777dab0Sopenharmony_ci */ 4087777dab0Sopenharmony_ciint32_t OH_NativeBuffer_FromNativeWindowBuffer(OHNativeWindowBuffer *nativeWindowBuffer, OH_NativeBuffer **buffer); 4097777dab0Sopenharmony_ci 4107777dab0Sopenharmony_ci/** 4117777dab0Sopenharmony_ci * @brief Set the color space of the OH_NativeBuffer.\n 4127777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 4137777dab0Sopenharmony_ci * 4147777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 4157777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 4167777dab0Sopenharmony_ci * @param colorSpace Indicates the color space of native buffer, see <b>OH_NativeBuffer_ColorSpace</b>. 4177777dab0Sopenharmony_ci * @return Returns an error code, 0 is success, otherwise, failed. 4187777dab0Sopenharmony_ci * @since 11 4197777dab0Sopenharmony_ci * @version 1.0 4207777dab0Sopenharmony_ci */ 4217777dab0Sopenharmony_ciint32_t OH_NativeBuffer_SetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace colorSpace); 4227777dab0Sopenharmony_ci 4237777dab0Sopenharmony_ci/** 4247777dab0Sopenharmony_ci * @brief Get the color space of the OH_NativeBuffer.\n 4257777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 4267777dab0Sopenharmony_ci * 4277777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 4287777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 4297777dab0Sopenharmony_ci * @param colorSpace Indicates the color space of native buffer, see <b>OH_NativeBuffer_ColorSpace</b>. 4307777dab0Sopenharmony_ci * @return {@link NATIVE_ERROR_OK} 0 - Success. 4317777dab0Sopenharmony_ci * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - buffer is NULL. 4327777dab0Sopenharmony_ci * {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect colorSpace state. 4337777dab0Sopenharmony_ci * @since 12 4347777dab0Sopenharmony_ci * @version 1.0 4357777dab0Sopenharmony_ci */ 4367777dab0Sopenharmony_ciint32_t OH_NativeBuffer_GetColorSpace(OH_NativeBuffer *buffer, OH_NativeBuffer_ColorSpace *colorSpace); 4377777dab0Sopenharmony_ci 4387777dab0Sopenharmony_ci/** 4397777dab0Sopenharmony_ci * @brief Set the metadata type of the OH_NativeBuffer.\n 4407777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 4417777dab0Sopenharmony_ci * 4427777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 4437777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 4447777dab0Sopenharmony_ci * @param metadataKey Indicates the metadata type of native buffer, see <b>OH_NativeBuffer_MetadataKey</b>. 4457777dab0Sopenharmony_ci * @param size Indicates the size of a uint8_t vector. 4467777dab0Sopenharmony_ci * @param metadata Indicates the pointer to a uint8_t vector. 4477777dab0Sopenharmony_ci * @return {@link NATIVE_ERROR_OK} 0 - Success. 4487777dab0Sopenharmony_ci * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - buffer or metadata is NULL. 4497777dab0Sopenharmony_ci * {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state. 4507777dab0Sopenharmony_ci * {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key. 4517777dab0Sopenharmony_ci * @since 12 4527777dab0Sopenharmony_ci * @version 1.0 4537777dab0Sopenharmony_ci */ 4547777dab0Sopenharmony_ciint32_t OH_NativeBuffer_SetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, 4557777dab0Sopenharmony_ci int32_t size, uint8_t *metadata); 4567777dab0Sopenharmony_ci 4577777dab0Sopenharmony_ci/** 4587777dab0Sopenharmony_ci * @brief Set the metadata type of the OH_NativeBuffer.\n 4597777dab0Sopenharmony_ci * This interface is a non-thread-safe type interface.\n 4607777dab0Sopenharmony_ci * 4617777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeBuffer 4627777dab0Sopenharmony_ci * @param buffer Indicates the pointer to a <b>OH_NativeBuffer</b> instance. 4637777dab0Sopenharmony_ci * @param metadataKey Indicates the metadata type of native buffer, see <b>OH_NativeBuffer_MetadataKey</b>. 4647777dab0Sopenharmony_ci * @param size Indicates the size of a uint8_t vector. 4657777dab0Sopenharmony_ci * @param metadata Indicates the pointer to a uint8_t vector. 4667777dab0Sopenharmony_ci * @return {@link NATIVE_ERROR_OK} 0 - Success. 4677777dab0Sopenharmony_ci * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - buffer, metadata, or size is NULL. 4687777dab0Sopenharmony_ci * {@link NATIVE_ERROR_BUFFER_STATE_INVALID} 41207000 - Incorrect metadata state. 4697777dab0Sopenharmony_ci * {@link NATIVE_ERROR_UNSUPPORTED} 50102000 - Unsupported metadata key. 4707777dab0Sopenharmony_ci * @since 12 4717777dab0Sopenharmony_ci * @version 1.0 4727777dab0Sopenharmony_ci */ 4737777dab0Sopenharmony_ciint32_t OH_NativeBuffer_GetMetadataValue(OH_NativeBuffer *buffer, OH_NativeBuffer_MetadataKey metadataKey, 4747777dab0Sopenharmony_ci int32_t *size, uint8_t **metadata); 4757777dab0Sopenharmony_ci 4767777dab0Sopenharmony_ci#ifdef __cplusplus 4777777dab0Sopenharmony_ci} 4787777dab0Sopenharmony_ci#endif 4797777dab0Sopenharmony_ci 4807777dab0Sopenharmony_ci/** @} */ 4817777dab0Sopenharmony_ci#endif