diff --git a/tools/qtimapper-shim/.clang-format b/tools/qtimapper-shim/.clang-format new file mode 100644 index 0000000..ede5d7e --- /dev/null +++ b/tools/qtimapper-shim/.clang-format @@ -0,0 +1,9 @@ +BasedOnStyle: Google +AllowShortFunctionsOnASingleLine: Inline +ColumnLimit: 100 +CommentPragmas: NOLINT:.* +DerivePointerAlignment: false +IndentWidth: 2 +PointerAlignment: Left +TabWidth: 2 +UseTab: Never diff --git a/tools/qtimapper-shim/Android.bp b/tools/qtimapper-shim/Android.bp index 44f1c87..bc4a66b 100644 --- a/tools/qtimapper-shim/Android.bp +++ b/tools/qtimapper-shim/Android.bp @@ -1,34 +1,37 @@ cc_defaults { - name: "shim_defaults", + name: "shim_defaults", - srcs: [ - "shim.cpp", - ], + srcs: [ + "shim.cpp", + "ext/gr_utils.cpp", + "ext/gr_adreno_info.cpp", + ], - shared_libs: [ - "liblog", - "libcutils", - "libhidlbase", - "libhardware", - "libutils", - ], - cflags: [ - "-Wno-error", - "-Wno-unused-parameter", - ], + shared_libs: [ + "liblog", + "libcutils", + "libhidlbase", + "libhardware", + "libutils", + ], + + cflags: [ + "-Wno-error", + "-Wno-unused-parameter", + ], } cc_library_shared { - name: "vendor.qti.hardware.display.mapperstub", - defaults: ["shim_defaults"], + name: "vendor.qti.hardware.display.mappershim", + defaults: ["shim_defaults"], } cc_library_shared { - name: "vendor.qti.hardware.display.mapperextensionsstub", - defaults: ["shim_defaults"], + name: "vendor.qti.hardware.display.mapperextensionsshim", + defaults: ["shim_defaults"], } cc_library_shared { - name: "android.hardware.graphics.mapperstub", - defaults: ["shim_defaults"], + name: "android.hardware.graphics.mappershim", + defaults: ["shim_defaults"], } diff --git a/tools/qtimapper-shim/README.md b/tools/qtimapper-shim/README.md index 2263db5..6e24893 100644 --- a/tools/qtimapper-shim/README.md +++ b/tools/qtimapper-shim/README.md @@ -12,8 +12,8 @@ The code is fairly ugly but functional enough for the purpose, some functions ar Chuck into a lineage tree, then: ``` -make vendor.qti.hardware.display.mapperstub -make vendor.qti.hardware.display.mapperextensionsstub -make android.hardware.graphics.mapperstub +make vendor.qti.hardware.display.mappershim +make vendor.qti.hardware.display.mapperextensionsshim +make android.hardware.graphics.mappershim ``` and grab SOs out of outputs dir diff --git a/tools/qtimapper-shim/ext/QtiGrallocDefs.h b/tools/qtimapper-shim/ext/QtiGrallocDefs.h new file mode 100644 index 0000000..e0ccbe1 --- /dev/null +++ b/tools/qtimapper-shim/ext/QtiGrallocDefs.h @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __QTIGRALLOCDEFS_H__ +#define __QTIGRALLOCDEFS_H__ + +// From gralloc_priv.h + +/* Gralloc usage bits indicating the type of allocation that should be used */ +/* Refer to BufferUsage in hardware/interfaces/graphics/common//types.hal */ + +/* The bits below are in officially defined vendor space + * i.e bits 28-31 and 48-63*/ +/* Non linear, Universal Bandwidth Compression */ +#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC (UINT32_C(1) << 28) + +/* Set this for allocating uncached memory (using O_DSYNC), + * cannot be used with noncontiguous heaps */ +#define GRALLOC_USAGE_PRIVATE_UNCACHED (UINT32_C(1) << 29) + +/* This flag is used to indicate 10 bit format. + * When both GRALLOC_USAGE_PRIVATE_ALLOC_UBWC & GRALLOC_USAGE_PRIVATE_10BIT + * are set then it will indicate UBWC_TP10 format. + * When only GRALLOC_USAGE_PRIVATE_10BIT is set it will indicate linear P010 format. + */ +#define GRALLOC_USAGE_PRIVATE_10BIT (UINT32_C(1) << 30) + +/* This flag is used for SECURE display usecase */ +#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY (UINT32_C(1) << 31) + +/* This flag is used to indicate video NV21 format */ +#define GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER 1ULL << 48 + +/* unused legacy flags */ +#define GRALLOC_USAGE_PRIVATE_MM_HEAP 0 +#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP 0 + +/* This flag is set for WFD usecase */ +#define GRALLOC_USAGE_PRIVATE_WFD 1ULL << 51 + +/* This flag is set for HEIF usecase */ +#define GRALLOC_USAGE_PRIVATE_HEIF (UINT32_C(1) << 27) + +/* TODO(user): Remove when clients stop referencing this flag */ +#define GRALLOC_USAGE_PRIVATE_10BIT_TP 0 + +/* This flag indicates PI format is being used */ +#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI 1ULL << 49 + +/* This flag is set while CDSP accesses the buffer */ +#define GRALLOC_USAGE_PRIVATE_CDSP 1ULL << 50 + +// OEM specific HAL formats +#define HAL_PIXEL_FORMAT_RGBA_5551 6 +#define HAL_PIXEL_FORMAT_RGBA_4444 7 +#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102 +#define HAL_PIXEL_FORMAT_NV21_ENCODEABLE 0x7FA30C00 +#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04 +#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03 +#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109 +#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01 +#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B +#define HAL_PIXEL_FORMAT_R_8 0x10D +#define HAL_PIXEL_FORMAT_RG_88 0x10E +#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F +#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110 +#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111 +#define HAL_PIXEL_FORMAT_BGRX_8888 0x112 +#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113 +#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114 +#define HAL_PIXEL_FORMAT_BGR_565 0x115 +#define HAL_PIXEL_FORMAT_RAW8 0x123 +#define HAL_PIXEL_FORMAT_NV12_HEIF 0x116 + +// 10 bit +#define HAL_PIXEL_FORMAT_ARGB_2101010 0x117 +#define HAL_PIXEL_FORMAT_RGBX_1010102 0x118 +#define HAL_PIXEL_FORMAT_XRGB_2101010 0x119 +#define HAL_PIXEL_FORMAT_BGRA_1010102 0x11A +#define HAL_PIXEL_FORMAT_ABGR_2101010 0x11B +#define HAL_PIXEL_FORMAT_BGRX_1010102 0x11C +#define HAL_PIXEL_FORMAT_XBGR_2101010 0x11D +#define HAL_PIXEL_FORMAT_YCbCr_420_P010 0x36 // HAL_PIXEL_FORMAT_YCBCR_P010 +#define HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC 0x124 +#define HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS 0x7FA30C0A + +#define HAL_PIXEL_FORMAT_CbYCrY_422_I 0x120 +#define HAL_PIXEL_FORMAT_BGR_888 0x121 + +#define HAL_PIXEL_FORMAT_INTERLACE 0x180 + +// Camera utils format +#define HAL_PIXEL_FORMAT_NV12_LINEAR_FLEX 0x125 +#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX 0x126 +#define HAL_PIXEL_FORMAT_MULTIPLANAR_FLEX 0x127 +#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_2_BATCH 0x128 +#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_4_BATCH 0x129 +#define HAL_PIXEL_FORMAT_NV12_UBWC_FLEX_8_BATCH 0x130 + +// FSC Formats +#define HAL_PIXEL_FORMAT_RGB888_UBWC_FSC 0x131 +#define HAL_PIXEL_FORMAT_RGB101010_UBWC_FSC 0x132 + +// v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component +#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559 + +// v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed +// format reduces the memory access bandwidth +#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259 + +// UBWC aligned Venus format +#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06 +#define HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC 0x7FA30C09 + +// Khronos ASTC formats +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD + +enum { BUFFER_TYPE_UI = 0, BUFFER_TYPE_VIDEO }; + +#endif //__QTIGRALLOCDEFS_H__ diff --git a/tools/qtimapper-shim/ext/common.h b/tools/qtimapper-shim/ext/common.h new file mode 100644 index 0000000..73e80cb --- /dev/null +++ b/tools/qtimapper-shim/ext/common.h @@ -0,0 +1,86 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * 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. + */ + +#pragma once + +#include +#include +#include +#include + +#include "types/common.h" + +using namespace android::hardware; +using namespace android; + +/* Simplified version of hidl::base::V1_0::IBase */ +struct IBase : virtual public RefBase { + virtual bool isRemote() const; + + using interfaceChain_cb = std::function& descriptors)>; + virtual Return interfaceChain(interfaceChain_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return debug(const hidl_handle& fd, const hidl_vec& options) { + ALOGE("%s", __func__); + std::terminate(); + } + + using interfaceDescriptor_cb = std::function; + virtual Return interfaceDescriptor(interfaceDescriptor_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + using getHashChain_cb = std::function>& hashchain)>; + virtual Return getHashChain(getHashChain_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return setHALInstrumentation() { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return linkToDeath(const sp& recipient, uint64_t cookie) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return ping() { + ALOGE("%s", __func__); + std::terminate(); + } + + using getDebugInfo_cb = std::function; + virtual Return getDebugInfo(getDebugInfo_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return notifySyspropsChanged() { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return unlinkToDeath(const sp& recipient) { + ALOGE("%s", __func__); + std::terminate(); + } +}; diff --git a/tools/qtimapper-shim/ext/gr_adreno_info.cpp b/tools/qtimapper-shim/ext/gr_adreno_info.cpp new file mode 100644 index 0000000..30610e8 --- /dev/null +++ b/tools/qtimapper-shim/ext/gr_adreno_info.cpp @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gr_adreno_info.h" + +#include +#include +#include + +#include + +#include "gr_utils.h" +#include "gralloc_priv.h" + +using std::lock_guard; +using std::mutex; + +namespace gralloc { + +AdrenoMemInfo* AdrenoMemInfo::s_instance = nullptr; + +AdrenoMemInfo* AdrenoMemInfo::GetInstance() { + static mutex s_lock; + lock_guard obj(s_lock); + if (!s_instance) { + s_instance = new AdrenoMemInfo(); + } + + return s_instance; +} + +AdrenoMemInfo::AdrenoMemInfo() { + libadreno_utils_ = ::dlopen("libadreno_utils.so", RTLD_NOW); + if (libadreno_utils_) { + *reinterpret_cast(&LINK_adreno_compute_aligned_width_and_height) = + ::dlsym(libadreno_utils_, "compute_aligned_width_and_height"); + *reinterpret_cast(&LINK_adreno_compute_fmt_aligned_width_and_height) = + ::dlsym(libadreno_utils_, "compute_fmt_aligned_width_and_height"); + *reinterpret_cast(&LINK_adreno_compute_padding) = + ::dlsym(libadreno_utils_, "compute_surface_padding"); + *reinterpret_cast(&LINK_adreno_compute_compressedfmt_aligned_width_and_height) = + ::dlsym(libadreno_utils_, "compute_compressedfmt_aligned_width_and_height"); + *reinterpret_cast(&LINK_adreno_isUBWCSupportedByGpu) = + ::dlsym(libadreno_utils_, "isUBWCSupportedByGpu"); + *reinterpret_cast(&LINK_adreno_get_gpu_pixel_alignment) = + ::dlsym(libadreno_utils_, "get_gpu_pixel_alignment"); + *reinterpret_cast(&LINK_adreno_get_metadata_blob_size) = + ::dlsym(libadreno_utils_, "adreno_get_metadata_blob_size"); + *reinterpret_cast(&LINK_adreno_init_memory_layout) = + ::dlsym(libadreno_utils_, "adreno_init_memory_layout"); + *reinterpret_cast(&LINK_adreno_get_aligned_gpu_buffer_size) = + ::dlsym(libadreno_utils_, "adreno_get_aligned_gpu_buffer_size"); + } else { + ALOGE(" Failed to load libadreno_utils.so"); + } + + // Check if the overriding property debug.gralloc.gfx_ubwc_disable + // that disables UBWC allocations for the graphics stack is set + char property[PROPERTY_VALUE_MAX]; + property_get(DISABLE_UBWC_PROP, property, "0"); + if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) || + !(strncmp(property, "true", PROPERTY_VALUE_MAX))) { + gfx_ubwc_disable_ = true; + } + + property_get(DISABLE_AHARDWAREBUFFER_PROP, property, "0"); + if (!(strncmp(property, "1", PROPERTY_VALUE_MAX)) || + !(strncmp(property, "true", PROPERTY_VALUE_MAX))) { + gfx_ahardware_buffer_disable_ = true; + } +} + +AdrenoMemInfo::~AdrenoMemInfo() { + if (libadreno_utils_) { + ::dlclose(libadreno_utils_); + } +} + +void AdrenoMemInfo::AlignUnCompressedRGB(int width, int height, int format, int tile_enabled, + unsigned int* aligned_w, unsigned int* aligned_h) { + *aligned_w = (unsigned int)ALIGN(width, 32); + *aligned_h = (unsigned int)ALIGN(height, 32); + + int bpp = 4; + switch (format) { + case HAL_PIXEL_FORMAT_RGB_888: + case HAL_PIXEL_FORMAT_BGR_888: + bpp = 3; + break; + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + bpp = 2; + break; + default: + break; + } + + int raster_mode = 0; // Adreno unknown raster mode. + int padding_threshold = 512; // Threshold for padding surfaces. + // the function below computes aligned width and aligned height + // based on linear or macro tile mode selected. + if (LINK_adreno_compute_fmt_aligned_width_and_height) { + // We call into adreno_utils only for RGB formats. So plane_id is 0 and + // num_samples is 1 always. We may have to add uitility function to + // find out these if there is a need to call this API for YUV formats. + LINK_adreno_compute_fmt_aligned_width_and_height( + width, height, 0 /*plane_id*/, GetGpuPixelFormat(format), 1 /*num_samples*/, tile_enabled, + raster_mode, padding_threshold, reinterpret_cast(aligned_w), + reinterpret_cast(aligned_h)); + } else if (LINK_adreno_compute_aligned_width_and_height) { + LINK_adreno_compute_aligned_width_and_height( + width, height, bpp, tile_enabled, raster_mode, padding_threshold, + reinterpret_cast(aligned_w), reinterpret_cast(aligned_h)); + } else if (LINK_adreno_compute_padding) { + int surface_tile_height = 1; // Linear surface + *aligned_w = UINT(LINK_adreno_compute_padding(width, bpp, surface_tile_height, raster_mode, + padding_threshold)); + ALOGW("%s: Warning!! Old GFX API is used to calculate stride", __FUNCTION__); + } else { + ALOGW( + "%s: Warning!! Symbols compute_surface_padding and " + "compute_fmt_aligned_width_and_height and " + "compute_aligned_width_and_height not found", + __FUNCTION__); + } +} + +void AdrenoMemInfo::AlignCompressedRGB(int width, int height, int format, unsigned int* aligned_w, + unsigned int* aligned_h) { + if (LINK_adreno_compute_compressedfmt_aligned_width_and_height) { + int bytesPerPixel = 0; + int raster_mode = 0; // Adreno unknown raster mode. + int padding_threshold = 512; // Threshold for padding + // surfaces. + + LINK_adreno_compute_compressedfmt_aligned_width_and_height( + width, height, format, 0, raster_mode, padding_threshold, reinterpret_cast(aligned_w), + reinterpret_cast(aligned_h), &bytesPerPixel); + } else { + *aligned_w = (unsigned int)ALIGN(width, 32); + *aligned_h = (unsigned int)ALIGN(height, 32); + ALOGW("%s: Warning!! compute_compressedfmt_aligned_width_and_height not found", __FUNCTION__); + } +} + +bool AdrenoMemInfo::IsUBWCSupportedByGPU(int format) { + if (!gfx_ubwc_disable_ && LINK_adreno_isUBWCSupportedByGpu) { + ADRENOPIXELFORMAT gpu_format = GetGpuPixelFormat(format); + return LINK_adreno_isUBWCSupportedByGpu(gpu_format); + } + + return false; +} + +uint32_t AdrenoMemInfo::GetGpuPixelAlignment() { + if (LINK_adreno_get_gpu_pixel_alignment) { + return LINK_adreno_get_gpu_pixel_alignment(); + } + + return 1; +} + +ADRENOPIXELFORMAT AdrenoMemInfo::GetGpuPixelFormat(int hal_format) { + switch (hal_format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + return ADRENO_PIXELFORMAT_R8G8B8A8; + case HAL_PIXEL_FORMAT_RGBX_8888: + return ADRENO_PIXELFORMAT_R8G8B8X8; + case HAL_PIXEL_FORMAT_BGRA_8888: + return ADRENO_PIXELFORMAT_B8G8R8A8_UNORM; + case HAL_PIXEL_FORMAT_RGB_888: + return ADRENO_PIXELFORMAT_R8G8B8; + case HAL_PIXEL_FORMAT_RGB_565: + return ADRENO_PIXELFORMAT_B5G6R5; + case HAL_PIXEL_FORMAT_BGR_565: + return ADRENO_PIXELFORMAT_R5G6B5; + case HAL_PIXEL_FORMAT_RGBA_5551: + return ADRENO_PIXELFORMAT_R5G5B5A1; + case HAL_PIXEL_FORMAT_RGBA_4444: + return ADRENO_PIXELFORMAT_R4G4B4A4; + case HAL_PIXEL_FORMAT_RGBA_1010102: + return ADRENO_PIXELFORMAT_R10G10B10A2_UNORM; + case HAL_PIXEL_FORMAT_RGBX_1010102: + return ADRENO_PIXELFORMAT_R10G10B10X2_UNORM; + case HAL_PIXEL_FORMAT_ABGR_2101010: + return ADRENO_PIXELFORMAT_A2B10G10R10_UNORM; + case HAL_PIXEL_FORMAT_RGBA_FP16: + return ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT; + case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: + return ADRENO_PIXELFORMAT_NV12; + case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: + case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: + return ADRENO_PIXELFORMAT_NV12_EXT; + case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: + return ADRENO_PIXELFORMAT_TP10; + case HAL_PIXEL_FORMAT_YCbCr_420_P010: + case HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC: + case HAL_PIXEL_FORMAT_YCbCr_420_P010_VENUS: + return ADRENO_PIXELFORMAT_P010; + case HAL_PIXEL_FORMAT_DEPTH_16: + return ADRENO_PIXELFORMAT_D16_UNORM; + case HAL_PIXEL_FORMAT_DEPTH_24: + return ADRENO_PIXELFORMAT_D24_UNORM_X8_UINT; + case HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: + return ADRENO_PIXELFORMAT_D24_UNORM_S8_UINT; + case HAL_PIXEL_FORMAT_DEPTH_32F: + return ADRENO_PIXELFORMAT_D32_FLOAT; + case HAL_PIXEL_FORMAT_STENCIL_8: + return ADRENO_PIXELFORMAT_S8_UINT; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR: + return ADRENO_PIXELFORMAT_ASTC_4X4; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + return ADRENO_PIXELFORMAT_ASTC_4X4_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR: + return ADRENO_PIXELFORMAT_ASTC_5X4; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + return ADRENO_PIXELFORMAT_ASTC_5X4_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_5X5; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_5X5_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_6X5; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_6X5_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR: + return ADRENO_PIXELFORMAT_ASTC_6X6; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + return ADRENO_PIXELFORMAT_ASTC_6X6_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_8X5; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_8X5_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR: + return ADRENO_PIXELFORMAT_ASTC_8X6; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + return ADRENO_PIXELFORMAT_ASTC_8X6_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR: + return ADRENO_PIXELFORMAT_ASTC_8X8; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + return ADRENO_PIXELFORMAT_ASTC_8X8_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X5; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X5_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X6; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X6_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X8; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X8_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X10; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + return ADRENO_PIXELFORMAT_ASTC_10X10_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR: + return ADRENO_PIXELFORMAT_ASTC_12X10; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + return ADRENO_PIXELFORMAT_ASTC_12X10_SRGB; + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR: + return ADRENO_PIXELFORMAT_ASTC_12X12; + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return ADRENO_PIXELFORMAT_ASTC_12X12_SRGB; + default: + ALOGE("%s: No map for format: 0x%x", __FUNCTION__, hal_format); + break; + } + + return ADRENO_PIXELFORMAT_UNKNOWN; +} + +uint32_t AdrenoMemInfo::AdrenoGetMetadataBlobSize() { + if (LINK_adreno_get_metadata_blob_size) { + return LINK_adreno_get_metadata_blob_size(); + } + return 0; +} + +int AdrenoMemInfo::AdrenoInitMemoryLayout(void* metadata_blob, int width, int height, int depth, + int format, int num_samples, int isUBWC, uint64_t usage, + uint32_t num_planes) { + if (LINK_adreno_init_memory_layout) { + surface_tile_mode_t tile_mode = static_cast(isUBWC); + return LINK_adreno_init_memory_layout(metadata_blob, width, height, depth, + GetGpuPixelFormat(format), num_samples, tile_mode, usage, + num_planes); + } + return -1; +} + +uint32_t AdrenoMemInfo::AdrenoGetAlignedGpuBufferSize(void* metadata_blob) { + if (LINK_adreno_get_aligned_gpu_buffer_size) { + return LINK_adreno_get_aligned_gpu_buffer_size(metadata_blob); + } + return -1; +} + +bool AdrenoMemInfo::AdrenoSizeAPIAvaliable() { + if (gfx_ahardware_buffer_disable_) { + return false; + } + + return (LINK_adreno_get_metadata_blob_size && LINK_adreno_init_memory_layout && + LINK_adreno_get_aligned_gpu_buffer_size); +} + +bool AdrenoMemInfo::IsPISupportedByGPU(int format, uint64_t usage) { + if (LINK_adreno_isPISupportedByGpu) { + return LINK_adreno_isPISupportedByGpu(format, usage); + } + return false; +} + +} // namespace gralloc diff --git a/tools/qtimapper-shim/ext/gr_adreno_info.h b/tools/qtimapper-shim/ext/gr_adreno_info.h new file mode 100644 index 0000000..590d18b --- /dev/null +++ b/tools/qtimapper-shim/ext/gr_adreno_info.h @@ -0,0 +1,234 @@ +/* + * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __GR_ADRENO_INFO_H__ +#define __GR_ADRENO_INFO_H__ + +#include +#include + +namespace gralloc { + +// Adreno Pixel Formats +typedef enum { + ADRENO_PIXELFORMAT_UNKNOWN = 0, + ADRENO_PIXELFORMAT_R16G16B16A16_FLOAT = 10, + ADRENO_PIXELFORMAT_R10G10B10A2_UNORM = 24, // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES + ADRENO_PIXELFORMAT_R8G8B8A8 = 28, + ADRENO_PIXELFORMAT_R8G8B8A8_SRGB = 29, + ADRENO_PIXELFORMAT_D32_FLOAT = 40, + ADRENO_PIXELFORMAT_D24_UNORM_S8_UINT = 45, + ADRENO_PIXELFORMAT_D16_UNORM = 55, + ADRENO_PIXELFORMAT_B5G6R5 = 85, + ADRENO_PIXELFORMAT_B5G5R5A1 = 86, + ADRENO_PIXELFORMAT_B8G8R8A8_UNORM = 87, + ADRENO_PIXELFORMAT_B8G8R8A8 = 90, + ADRENO_PIXELFORMAT_B8G8R8A8_SRGB = 91, + ADRENO_PIXELFORMAT_B8G8R8X8_SRGB = 93, + ADRENO_PIXELFORMAT_NV12 = 103, + ADRENO_PIXELFORMAT_P010 = 104, + ADRENO_PIXELFORMAT_YUY2 = 107, + ADRENO_PIXELFORMAT_B4G4R4A4 = 115, + ADRENO_PIXELFORMAT_NV12_EXT = 506, // NV12 with non-std alignment and offsets + ADRENO_PIXELFORMAT_R8G8B8X8 = 507, // GL_RGB8 (Internal) + ADRENO_PIXELFORMAT_R8G8B8 = 508, // GL_RGB8 + ADRENO_PIXELFORMAT_A1B5G5R5 = 519, // GL_RGB5_A1 + ADRENO_PIXELFORMAT_R8G8B8X8_SRGB = 520, // GL_SRGB8 + ADRENO_PIXELFORMAT_R8G8B8_SRGB = 521, // GL_SRGB8 + ADRENO_PIXELFORMAT_A2B10G10R10_UNORM = 532, + // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES + ADRENO_PIXELFORMAT_R10G10B10X2_UNORM = 537, + ADRENO_PIXELFORMAT_D24_UNORM_X8_UINT = 548, + ADRENO_PIXELFORMAT_D24_UNORM = 549, + ADRENO_PIXELFORMAT_D32_FLOAT_X24S8_UINT = 551, + ADRENO_PIXELFORMAT_S8_UINT = 552, + ADRENO_PIXELFORMAT_ASTC_4X4 = 568, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_5X4 = 569, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_5X5 = 570, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_6X5 = 571, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_6X6 = 572, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_8X5 = 573, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_8X6 = 574, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_8X8 = 575, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X5 = 576, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X6 = 577, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X8 = 578, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X10 = 579, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_12X10 = 580, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_12X12 = 581, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_4X4_SRGB = 582, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_5X4_SRGB = 583, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_5X5_SRGB = 584, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_6X5_SRGB = 585, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_6X6_SRGB = 586, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_8X5_SRGB = 587, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_8X6_SRGB = 588, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_8X8_SRGB = 589, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X5_SRGB = 590, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X6_SRGB = 591, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X8_SRGB = 592, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_10X10_SRGB = 593, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_12X10_SRGB = 594, // ASTC Compressed + ADRENO_PIXELFORMAT_ASTC_12X12_SRGB = 595, // ASTC Compressed + // Vertex, Normalized GL_UNSIGNED_INT_10_10_10_2_OES + ADRENO_PIXELFORMAT_R5G6B5 = 610, // RGBA version of B5G6R5 + ADRENO_PIXELFORMAT_R5G5B5A1 = 611, // RGBA version of B5G5R5A1 + ADRENO_PIXELFORMAT_R4G4B4A4 = 612, // RGBA version of B4G4R4A4 + ADRENO_PIXELFORMAT_UYVY = 614, // YUV 4:2:2 packed progressive (1 plane) + ADRENO_PIXELFORMAT_NV21 = 619, + ADRENO_PIXELFORMAT_Y8U8V8A8 = 620, // YUV 4:4:4 packed (1 plane) + ADRENO_PIXELFORMAT_Y8 = 625, // Single 8-bit luma only channel YUV format + ADRENO_PIXELFORMAT_TP10 = 654, // YUV 4:2:0 planar 10 bits/comp (2 planes) +} ADRENOPIXELFORMAT; + +typedef enum { + SURFACE_TILE_MODE_DISABLE = 0x0, // used for linear surface + SURFACE_TILE_MODE_ENABLE = 0x1 // used for tiled surface +} surface_tile_mode_t; + +class AdrenoMemInfo { + public: + /* + * Function to compute aligned width and aligned height based on + * width, height, format and usage flags. + * + * @return aligned width, aligned height + */ + void GetAlignedWidthAndHeight(int width, int height, int format, int usage, + unsigned int* aligned_w, unsigned int* aligned_h, bool ubwc_enabled, + bool tile_enabled); + + /* + * Function to compute the adreno aligned width and aligned height + * based on the width and format. + * + * @return aligned width, aligned height + */ + void AlignUnCompressedRGB(int width, int height, int format, int tileEnabled, + unsigned int* aligned_w, unsigned int* aligned_h); + + /* + * Function to compute the adreno aligned width and aligned height + * based on the width and format. + * + * @return aligned width, aligned height + */ + void AlignCompressedRGB(int width, int height, int format, unsigned int* aligned_w, + unsigned int* aligned_h); + + /* + * Function to compute the pixel alignment requirement. + * + * @return alignment + */ + uint32_t GetGpuPixelAlignment(); + + /* + * Function to query whether GPU supports UBWC for given HAL format + * @return > 0 : supported + * 0 : not supported + */ + bool IsUBWCSupportedByGPU(int format); + + /* + * Function to check if GPU supports PI or not + */ + bool IsPISupportedByGPU(int format, uint64_t usage); + /* + * Function to get the corresponding Adreno format for given HAL format + */ + ADRENOPIXELFORMAT GetGpuPixelFormat(int hal_format); + + /* + * Function to get graphics metadata blob size + * @return graphics metadata size + */ + uint32_t AdrenoGetMetadataBlobSize(); + + /* + * Function to populate the graphics metadata blob + * @return 1 : Successful + * 2 : Unsuccessful + */ + int AdrenoInitMemoryLayout(void* metadata_blob, int width, int height, int depth, int format, + int num_samples, int isUBWC, uint64_t usage, uint32_t num_planes); + /* + * Function to get buffer size for based on graphcis metadata + * @return buffer size + */ + uint32_t AdrenoGetAlignedGpuBufferSize(void* metadata_blob); + + /* + * Function to check if adreno size calculation APIs are avaliable + * @return true : Avaliable + * false : Unavaliable + */ + bool AdrenoSizeAPIAvaliable(); + + static AdrenoMemInfo* GetInstance(); + + private: + AdrenoMemInfo(); + ~AdrenoMemInfo(); + // link(s)to adreno surface padding library. + int (*LINK_adreno_compute_padding)(int width, int bpp, int surface_tile_height, + int screen_tile_height, int padding_threshold) = NULL; + void (*LINK_adreno_compute_aligned_width_and_height)(int width, int height, int bpp, + int tile_mode, int raster_mode, + int padding_threshold, int* aligned_w, + int* aligned_h) = NULL; + void (*LINK_adreno_compute_fmt_aligned_width_and_height)(int width, int height, int plane_id, + int format, int num_samples, + int tile_mode, int raster_mode, + int padding_threshold, int* aligned_w, + int* aligned_h) = NULL; + void (*LINK_adreno_compute_compressedfmt_aligned_width_and_height)( + int width, int height, int format, int tile_mode, int raster_mode, int padding_threshold, + int* aligned_w, int* aligned_h, int* bpp) = NULL; + int (*LINK_adreno_isUBWCSupportedByGpu)(ADRENOPIXELFORMAT format) = NULL; + unsigned int (*LINK_adreno_get_gpu_pixel_alignment)() = NULL; + + uint32_t (*LINK_adreno_get_metadata_blob_size)() = NULL; + int (*LINK_adreno_init_memory_layout)(void* metadata_blob, int width, int height, int depth, + ADRENOPIXELFORMAT format, int num_samples, + surface_tile_mode_t tile_mode, uint64_t usage, + uint32_t num_planes) = NULL; + uint32_t (*LINK_adreno_get_aligned_gpu_buffer_size)(void* metadata_blob) = NULL; + int (*LINK_adreno_isPISupportedByGpu)(int format, uint64_t usage) = NULL; + + bool gfx_ubwc_disable_ = false; + bool gfx_ahardware_buffer_disable_ = false; + void* libadreno_utils_ = NULL; + + static AdrenoMemInfo* s_instance; +}; + +} // namespace gralloc + +#endif // __GR_ADRENO_INFO_H__ diff --git a/tools/qtimapper-shim/ext_headers/gr_priv_handle.h b/tools/qtimapper-shim/ext/gr_priv_handle.h similarity index 74% rename from tools/qtimapper-shim/ext_headers/gr_priv_handle.h rename to tools/qtimapper-shim/ext/gr_priv_handle.h index 2739779..3efbea4 100644 --- a/tools/qtimapper-shim/ext_headers/gr_priv_handle.h +++ b/tools/qtimapper-shim/ext/gr_priv_handle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. * Not a Contribution * * Copyright (C) 2008 The Android Open Source Project @@ -20,39 +20,28 @@ #ifndef __GR_PRIV_HANDLE_H__ #define __GR_PRIV_HANDLE_H__ -#include -#include #include #include +#include +#ifdef __cplusplus #include - -#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 -#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2 -#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3 -#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4 -#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5 -#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 -#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 -#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 -#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 -#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10 -#define GRALLOC_MODULE_PERFORM_GET_IGC 11 -#define GRALLOC_MODULE_PERFORM_SET_IGC 12 -#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13 -#define GRALLOC1_MODULE_PERFORM_GET_BUFFER_SIZE_AND_DIMENSIONS 14 -#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15 -#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16 +#endif #define GRALLOC1_FUNCTION_PERFORM 0x00001000 #define DBG_HANDLE false -typedef gralloc1_error_t (*GRALLOC1_PFN_PERFORM)(gralloc1_device_t *device, int operation, ...); +typedef gralloc1_error_t (*GRALLOC1_PFN_PERFORM)(gralloc1_device_t* device, int operation, ...); -#define PRIV_HANDLE_CONST(exp) static_cast(exp) +#define PRIV_HANDLE_CONST(exp) static_cast(exp) #pragma pack(push, 4) +#ifdef __cplusplus struct private_handle_t : public native_handle_t { +#else +struct private_handle_t { + native_handle_t nativeHandle; +#endif enum { PRIV_FLAGS_FRAMEBUFFER = 0x00000001, PRIV_FLAGS_USES_ION = 0x00000008, @@ -77,6 +66,7 @@ struct private_handle_t : public native_handle_t { PRIV_FLAGS_UBWC_ALIGNED = 0x08000000, PRIV_FLAGS_DISP_CONSUMER = 0x10000000, PRIV_FLAGS_CLIENT_ALLOCATED = 0x20000000, // Ion buffer allocated outside of gralloc + PRIV_FLAGS_UBWC_ALIGNED_PI = 0x40000000, // PI format }; // file-descriptors dup'd over IPC @@ -102,7 +92,7 @@ struct private_handle_t : public native_handle_t { uint64_t base; uint64_t base_metadata; uint64_t gpuaddr; - +#ifdef __cplusplus static const int kNumFds = 2; static const int kMagic = 'gmsm'; @@ -146,29 +136,30 @@ struct private_handle_t : public native_handle_t { ALOGE_IF(DBG_HANDLE, "Deleting buffer handle %p", this); } - static int validate(const native_handle *h) { - auto *hnd = static_cast(h); + static int validate(const native_handle* h) { + auto* hnd = static_cast(h); if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() || h->numFds != kNumFds) { - ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d) ", - h, h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(), - h ? h->numFds : -1, kNumFds); + ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d)", h, + h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(), + h ? h->numFds : -1, kNumFds); return -EINVAL; } if (hnd->magic != kMagic) { - ALOGE("magic(%c%c%c%c/%c%c%c%c)", - hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 0) & 0xFF) ? ((hnd->magic >> 0) & 0xFF) : '-') : '?', - (kMagic >> 24) & 0xFF, (kMagic >> 16) & 0xFF, (kMagic >> 8) & 0xFF, (kMagic >> 0) & 0xFF); + ALOGE("handle = %p invalid magic(%c%c%c%c/%c%c%c%c)", hnd, + hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?', + hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?', + hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?', + hnd ? (((hnd->magic >> 0) & 0xFF) ? ((hnd->magic >> 0) & 0xFF) : '-') : '?', + (kMagic >> 24) & 0xFF, (kMagic >> 16) & 0xFF, (kMagic >> 8) & 0xFF, + (kMagic >> 0) & 0xFF); return -EINVAL; } return 0; } - static void Dump(const private_handle_t *hnd) { + static void Dump(const private_handle_t* hnd) { ALOGD("handle id:%" PRIu64 " wxh:%dx%d uwxuh:%dx%d size: %d fd:%d fd_meta:%d flags:0x%x " "usage:0x%" PRIx64 " format:0x%x layer_count: %d", @@ -192,6 +183,7 @@ struct private_handle_t : public native_handle_t { uint64_t GetUsage() const { return usage; } uint64_t GetBackingstore() const { return id; } +#endif }; #pragma pack(pop) diff --git a/tools/qtimapper-shim/ext/gr_utils.cpp b/tools/qtimapper-shim/ext/gr_utils.cpp new file mode 100644 index 0000000..a83ef20 --- /dev/null +++ b/tools/qtimapper-shim/ext/gr_utils.cpp @@ -0,0 +1,662 @@ +/* + * Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "gr_utils.h" + +#include + +#include "gr_adreno_info.h" + +#define ASTC_BLOCK_SIZE 16 + +#ifndef COLOR_FMT_P010_UBWC +#define COLOR_FMT_P010_UBWC 9 +#endif + +namespace gralloc { + +bool IsUncompressedRGBFormat(int format) { + switch (format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGB_888: + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + case HAL_PIXEL_FORMAT_R_8: + case HAL_PIXEL_FORMAT_RG_88: + case HAL_PIXEL_FORMAT_BGRX_8888: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_ARGB_2101010: + case HAL_PIXEL_FORMAT_RGBX_1010102: + case HAL_PIXEL_FORMAT_XRGB_2101010: + case HAL_PIXEL_FORMAT_BGRA_1010102: + case HAL_PIXEL_FORMAT_ABGR_2101010: + case HAL_PIXEL_FORMAT_BGRX_1010102: + case HAL_PIXEL_FORMAT_XBGR_2101010: + case HAL_PIXEL_FORMAT_RGBA_FP16: + case HAL_PIXEL_FORMAT_BGR_888: + return true; + default: + break; + } + + return false; +} + +bool IsCompressedRGBFormat(int format) { + switch (format) { + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR: + case HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return true; + default: + break; + } + + return false; +} + +uint32_t GetBppForUncompressedRGB(int format) { + uint32_t bpp = 0; + switch (format) { + case HAL_PIXEL_FORMAT_RGBA_FP16: + bpp = 8; + break; + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_BGRX_8888: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_ARGB_2101010: + case HAL_PIXEL_FORMAT_RGBX_1010102: + case HAL_PIXEL_FORMAT_XRGB_2101010: + case HAL_PIXEL_FORMAT_BGRA_1010102: + case HAL_PIXEL_FORMAT_ABGR_2101010: + case HAL_PIXEL_FORMAT_BGRX_1010102: + case HAL_PIXEL_FORMAT_XBGR_2101010: + bpp = 4; + break; + case HAL_PIXEL_FORMAT_RGB_888: + case HAL_PIXEL_FORMAT_BGR_888: + bpp = 3; + break; + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + bpp = 2; + break; + default: + ALOGE("Error : %s New format request = 0x%x", __FUNCTION__, format); + break; + } + + return bpp; +} + +bool CpuCanAccess(uint64_t usage) { + return CpuCanRead(usage) || CpuCanWrite(usage); +} + +bool CpuCanRead(uint64_t usage) { + if (usage & BufferUsage::CPU_READ_MASK) { + return true; + } + + return false; +} + +bool CpuCanWrite(uint64_t usage) { + if (usage & BufferUsage::CPU_WRITE_MASK) { + // Application intends to use CPU for rendering + return true; + } + + return false; +} + +uint32_t GetDataAlignment(int format, uint64_t usage) { + uint32_t align = UINT(getpagesize()); + if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) { + align = SIZE_8K; + } + + if (usage & BufferUsage::PROTECTED) { + if ((usage & BufferUsage::CAMERA_OUTPUT) || (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY)) { + // The alignment here reflects qsee mmu V7L/V8L requirement + align = SZ_2M; + } else { + align = SECURE_ALIGN; + } + } + + return align; +} + +bool IsGPUFlagSupported(uint64_t usage) { + bool ret = true; + if ((usage & BufferUsage::GPU_MIPMAP_COMPLETE)) { + ALOGE("GPU_MIPMAP_COMPLETE not supported"); + ret = false; + } + + if ((usage & BufferUsage::GPU_CUBE_MAP)) { + ALOGE("GPU_CUBE_MAP not supported"); + ret = false; + } + + return ret; +} + +// Returns the final buffer size meant to be allocated with ion +unsigned int GetSize(const BufferInfo& info, unsigned int alignedw, unsigned int alignedh) { + unsigned int size = 0; + int format = info.format; + int width = info.width; + int height = info.height; + uint64_t usage = info.usage; + + if (!IsGPUFlagSupported(usage)) { + ALOGE("Unsupported GPU usage flags present 0x%" PRIx64, usage); + return 0; + } + + if (IsUBwcEnabled(format, usage)) { + size = GetUBwcSize(width, height, format, alignedw, alignedh); + } else if (IsUncompressedRGBFormat(format)) { + uint32_t bpp = GetBppForUncompressedRGB(format); + size = alignedw * alignedh * bpp; + } else if (IsCompressedRGBFormat(format)) { + size = alignedw * alignedh * ASTC_BLOCK_SIZE; + } else { + // Below switch should be for only YUV/custom formats + switch (format) { + case HAL_PIXEL_FORMAT_RAW16: + case HAL_PIXEL_FORMAT_Y16: + size = alignedw * alignedh * 2; + break; + case HAL_PIXEL_FORMAT_RAW10: + case HAL_PIXEL_FORMAT_RAW12: + size = ALIGN(alignedw * alignedh, SIZE_4K); + break; + case HAL_PIXEL_FORMAT_RAW8: + case HAL_PIXEL_FORMAT_Y8: + size = alignedw * alignedh * 1; + break; + // adreno formats + case HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO: // NV21 + size = ALIGN(alignedw * alignedh, SIZE_4K); + size += (unsigned int)ALIGN(2 * ALIGN(width / 2, 32) * ALIGN(height / 2, 32), SIZE_4K); + break; + case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED: // NV12 + // The chroma plane is subsampled, + // but the pitch in bytes is unchanged + // The GPU needs 4K alignment, but the video decoder needs 8K + size = ALIGN(alignedw * alignedh, SIZE_8K); + size += ALIGN(alignedw * (unsigned int)ALIGN(height / 2, 32), SIZE_8K); + break; + case HAL_PIXEL_FORMAT_YV12: + if ((format == HAL_PIXEL_FORMAT_YV12) && ((width & 1) || (height & 1))) { + ALOGE("w or h is odd for the YV12 format"); + return 0; + } + size = alignedw * alignedh + (ALIGN(alignedw / 2, 16) * (alignedh / 2)) * 2; + size = ALIGN(size, (unsigned int)SIZE_4K); + break; + case HAL_PIXEL_FORMAT_YCbCr_420_SP: + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + size = ALIGN((alignedw * alignedh) + (alignedw * alignedh) / 2 + 1, SIZE_4K); + break; + case HAL_PIXEL_FORMAT_YCbCr_420_P010: + size = ALIGN((alignedw * alignedh * 2) + (alignedw * alignedh) + 1, SIZE_4K); + break; + case HAL_PIXEL_FORMAT_YCbCr_422_SP: + case HAL_PIXEL_FORMAT_YCrCb_422_SP: + case HAL_PIXEL_FORMAT_YCbCr_422_I: + case HAL_PIXEL_FORMAT_YCrCb_422_I: + case HAL_PIXEL_FORMAT_CbYCrY_422_I: + if (width & 1) { + ALOGE("width is odd for the YUV422_SP format"); + return 0; + } + size = ALIGN(alignedw * alignedh * 2, SIZE_4K); + break; + case HAL_PIXEL_FORMAT_BLOB: + case HAL_PIXEL_FORMAT_RAW_OPAQUE: + if (height != 1) { + ALOGE("%s: Buffers with HAL_PIXEL_FORMAT_BLOB must have height 1 ", __FUNCTION__); + return 0; + } + size = (unsigned int)width; + break; + case HAL_PIXEL_FORMAT_NV21_ZSL: + size = ALIGN((alignedw * alignedh) + (alignedw * alignedh) / 2, SIZE_4K); + break; + default: + ALOGE("%s: Unrecognized pixel format: 0x%x", __FUNCTION__, format); + return 0; + } + } + auto align = GetDataAlignment(format, usage); + size = ALIGN(size, align) * info.layer_count; + return size; +} + +// Explicitly defined UBWC formats +bool IsUBwcFormat(int format) { + switch (format) { + case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: + case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: + case HAL_PIXEL_FORMAT_YCbCr_420_P010_UBWC: + return true; + default: + return false; + } +} + +bool IsUBwcSupported(int format) { + // Existing HAL formats with UBWC support + switch (format) { + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_NV12_ENCODEABLE: + case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_RGBX_1010102: + case HAL_PIXEL_FORMAT_DEPTH_16: + case HAL_PIXEL_FORMAT_DEPTH_24: + case HAL_PIXEL_FORMAT_DEPTH_24_STENCIL_8: + case HAL_PIXEL_FORMAT_DEPTH_32F: + case HAL_PIXEL_FORMAT_STENCIL_8: + return true; + default: + break; + } + + return false; +} + +bool IsUBwcPISupported(int format, uint64_t usage) { + if (usage & BufferUsage::COMPOSER_OVERLAY || !(usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI)) { + return false; + } + + // As of now only two formats + switch (format) { + case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC: + case HAL_PIXEL_FORMAT_YCbCr_420_TP10_UBWC: { + if ((usage & BufferUsage::GPU_TEXTURE) || (usage & BufferUsage::GPU_RENDER_TARGET)) { + if (AdrenoMemInfo::GetInstance()) { + return AdrenoMemInfo::GetInstance()->IsPISupportedByGPU(format, usage); + } + } else { + return true; + } + } + } + + return false; +} + +bool IsUBwcEnabled(int format, uint64_t usage) { + // Allow UBWC, if client is using an explicitly defined UBWC pixel format. + if (IsUBwcFormat(format)) { + return true; + } + + // Allow UBWC, if an OpenGL client sets UBWC usage flag and GPU plus MDP + // support the format. OR if a non-OpenGL client like Rotator, sets UBWC + // usage flag and MDP supports the format. + if (((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC) || + (usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI) || + (usage & BufferUsage::COMPOSER_CLIENT_TARGET)) && + IsUBwcSupported(format)) { + bool enable = true; + // Query GPU for UBWC only if buffer is intended to be used by GPU. + if ((usage & BufferUsage::GPU_TEXTURE) || (usage & BufferUsage::GPU_RENDER_TARGET)) { + if (AdrenoMemInfo::GetInstance()) { + enable = AdrenoMemInfo::GetInstance()->IsUBWCSupportedByGPU(format); + } + } + + // Allow UBWC, only if CPU usage flags are not set + if (enable && !(CpuCanAccess(usage))) { + return true; + } + } + + return false; +} + +void GetRgbUBwcBlockSize(uint32_t bpp, int* block_width, int* block_height) { + *block_width = 0; + *block_height = 0; + + switch (bpp) { + case 2: + case 4: + *block_width = 16; + *block_height = 4; + break; + case 8: + *block_width = 8; + *block_height = 4; + break; + case 16: + *block_width = 4; + *block_height = 4; + break; + default: + ALOGE("%s: Unsupported bpp: %d", __FUNCTION__, bpp); + break; + } +} + +unsigned int GetRgbUBwcMetaBufferSize(int width, int height, uint32_t bpp) { + unsigned int size = 0; + int meta_width, meta_height; + int block_width, block_height; + + GetRgbUBwcBlockSize(bpp, &block_width, &block_height); + if (!block_width || !block_height) { + ALOGE("%s: Unsupported bpp: %d", __FUNCTION__, bpp); + return size; + } + + // Align meta buffer height to 16 blocks + meta_height = ALIGN(((height + block_height - 1) / block_height), 16); + + // Align meta buffer width to 64 blocks + meta_width = ALIGN(((width + block_width - 1) / block_width), 64); + + // Align meta buffer size to 4K + size = (unsigned int)ALIGN((meta_width * meta_height), 4096); + + return size; +} + +unsigned int GetUBwcSize(int width, int height, int format, unsigned int alignedw, + unsigned int alignedh) { + unsigned int size = 0; + uint32_t bpp = 0; + switch (format) { + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_RGBX_1010102: + bpp = GetBppForUncompressedRGB(format); + size = alignedw * alignedh * bpp; + size += GetRgbUBwcMetaBufferSize(width, height, bpp); + break; + default: + ALOGE("%s: Unsupported pixel format: 0x%x", __FUNCTION__, format); + break; + } + + return size; +} + +unsigned int GetRgbMetaSize(int format, uint32_t width, uint32_t height, uint64_t usage) { + unsigned int meta_size = 0; + if (!IsUBwcEnabled(format, usage)) { + return meta_size; + } + uint32_t bpp = GetBppForUncompressedRGB(format); + switch (format) { + case HAL_PIXEL_FORMAT_BGR_565: + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_RGBX_1010102: + case HAL_PIXEL_FORMAT_RGBA_FP16: + meta_size = GetRgbUBwcMetaBufferSize(width, height, bpp); + break; + default: + ALOGE("%s:Unsupported RGB format: 0x%x", __FUNCTION__, format); + break; + } + return meta_size; +} + +bool CanUseAdrenoForSize(int buffer_type, uint64_t usage) { + if (buffer_type == BUFFER_TYPE_VIDEO || !GetAdrenoSizeAPIStatus()) { + return false; + } + + if ((usage & BufferUsage::PROTECTED) && + ((usage & BufferUsage::CAMERA_OUTPUT) || (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY))) { + return false; + } + + return true; +} + +bool GetAdrenoSizeAPIStatus() { + AdrenoMemInfo* adreno_mem_info = AdrenoMemInfo::GetInstance(); + if (adreno_mem_info) { + return adreno_mem_info->AdrenoSizeAPIAvaliable(); + } + return false; +} + +bool UseUncached(int format, uint64_t usage) { + if ((usage & GRALLOC_USAGE_PRIVATE_UNCACHED) || (usage & BufferUsage::PROTECTED)) { + return true; + } + + // CPU read rarely + if ((usage & BufferUsage::CPU_READ_MASK) == static_cast(BufferUsage::CPU_READ_RARELY)) { + return true; + } + + // CPU write rarely + if ((usage & BufferUsage::CPU_WRITE_MASK) == + static_cast(BufferUsage::CPU_WRITE_RARELY)) { + return true; + } + + if ((usage & BufferUsage::SENSOR_DIRECT_DATA) || (usage & BufferUsage::GPU_DATA_BUFFER)) { + return true; + } + + if (format && IsUBwcEnabled(format, usage)) { + return true; + } + + return false; +} + +uint64_t GetHandleFlags(int format, uint64_t usage) { + uint64_t priv_flags = 0; + + if (usage & BufferUsage::VIDEO_ENCODER) { + priv_flags |= private_handle_t::PRIV_FLAGS_VIDEO_ENCODER; + } + + if (usage & BufferUsage::CAMERA_OUTPUT) { + priv_flags |= private_handle_t::PRIV_FLAGS_CAMERA_WRITE; + } + + if (usage & BufferUsage::CAMERA_INPUT) { + priv_flags |= private_handle_t::PRIV_FLAGS_CAMERA_READ; + } + + if (usage & BufferUsage::COMPOSER_OVERLAY) { + priv_flags |= private_handle_t::PRIV_FLAGS_DISP_CONSUMER; + } + + if (usage & BufferUsage::GPU_TEXTURE) { + priv_flags |= private_handle_t::PRIV_FLAGS_HW_TEXTURE; + } + + if (usage & GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY) { + priv_flags |= private_handle_t::PRIV_FLAGS_SECURE_DISPLAY; + } + + if (IsUBwcEnabled(format, usage)) { + if (IsUBwcPISupported(format, usage)) { + priv_flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED_PI; + } else { + priv_flags |= private_handle_t::PRIV_FLAGS_UBWC_ALIGNED; + } + } + + if (usage & (BufferUsage::CPU_READ_MASK | BufferUsage::CPU_WRITE_MASK)) { + priv_flags |= private_handle_t::PRIV_FLAGS_CPU_RENDERED; + } + + if ((usage & (BufferUsage::VIDEO_ENCODER | BufferUsage::VIDEO_DECODER | + BufferUsage::CAMERA_OUTPUT | BufferUsage::GPU_RENDER_TARGET))) { + priv_flags |= private_handle_t::PRIV_FLAGS_NON_CPU_WRITER; + } + + if (!UseUncached(format, usage)) { + priv_flags |= private_handle_t::PRIV_FLAGS_CACHED; + } + + return priv_flags; +} + +int GetImplDefinedFormat(uint64_t usage, int format) { + int gr_format = format; + + // If input format is HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED then based on + // the usage bits, gralloc assigns a format. + if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED || + format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + if ((usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC || usage & GRALLOC_USAGE_PRIVATE_ALLOC_UBWC_PI) && + format != HAL_PIXEL_FORMAT_YCbCr_420_888) { + gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC; + } else if (usage & BufferUsage::VIDEO_ENCODER) { + if (usage & GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER) { + gr_format = HAL_PIXEL_FORMAT_NV21_ENCODEABLE; // NV21 + } else if (usage & GRALLOC_USAGE_PRIVATE_HEIF) { + gr_format = HAL_PIXEL_FORMAT_NV12_HEIF; + } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS; + } else { + gr_format = HAL_PIXEL_FORMAT_NV12_ENCODEABLE; // NV12 + } + } else if (usage & BufferUsage::CAMERA_INPUT) { + if (usage & BufferUsage::CAMERA_OUTPUT) { + // Assumed ZSL if both producer and consumer camera flags set + gr_format = HAL_PIXEL_FORMAT_NV21_ZSL; // NV21 + } else { + gr_format = HAL_PIXEL_FORMAT_YCrCb_420_SP; // NV21 + } + } else if (usage & BufferUsage::CAMERA_OUTPUT) { + if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + gr_format = HAL_PIXEL_FORMAT_NV21_ZSL; // NV21 + } else { + gr_format = HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS; // NV12 preview + } + } else if (usage & BufferUsage::COMPOSER_OVERLAY) { + // XXX: If we still haven't set a format, default to RGBA8888 + gr_format = HAL_PIXEL_FORMAT_RGBA_8888; + } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_888) { + // If no other usage flags are detected, default the + // flexible YUV format to NV21_ZSL + gr_format = HAL_PIXEL_FORMAT_NV21_ZSL; + } + } + + return gr_format; +} + +bool HasAlphaComponent(int32_t format) { + switch (format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + case HAL_PIXEL_FORMAT_RGBA_1010102: + case HAL_PIXEL_FORMAT_ARGB_2101010: + case HAL_PIXEL_FORMAT_BGRA_1010102: + case HAL_PIXEL_FORMAT_ABGR_2101010: + case HAL_PIXEL_FORMAT_RGBA_FP16: + return true; + default: + return false; + } +} + +void GetRGBPlaneInfo(const BufferInfo& info, int32_t format, int32_t width, int32_t height, + int32_t /* flags */, int* plane_count, PlaneLayoutInfo* plane_info) { + uint64_t usage = info.usage; + *plane_count = 1; + uint32_t bpp = 0; + if (IsUncompressedRGBFormat(format)) { + bpp = GetBppForUncompressedRGB(format); + } + plane_info->component = + (PlaneComponent)(PLANE_COMPONENT_R | PLANE_COMPONENT_G | PLANE_COMPONENT_B); + if (HasAlphaComponent(format)) { + plane_info->component = (PlaneComponent)(plane_info->component | PLANE_COMPONENT_A); + } + plane_info->size = GetSize(info, width, height); + plane_info->step = bpp; + plane_info->offset = GetRgbMetaSize(format, width, height, usage); + plane_info->h_subsampling = 0; + plane_info->v_subsampling = 0; + plane_info->stride = width; + plane_info->stride_bytes = width * plane_info->step; + plane_info->scanlines = height; +} + +} // namespace gralloc diff --git a/tools/qtimapper-shim/ext/gr_utils.h b/tools/qtimapper-shim/ext/gr_utils.h new file mode 100644 index 0000000..13b2157 --- /dev/null +++ b/tools/qtimapper-shim/ext/gr_utils.h @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2011-2016,2018-2019, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __GR_UTILS_H__ +#define __GR_UTILS_H__ + +#include "gralloc_priv.h" +#include "types/common.h" + +#define SZ_2M 0x200000 +#define SZ_1M 0x100000 +#define SZ_4K 0x1000 + +#define SIZE_4K 4096 +#define SIZE_8K 8192 + +#ifdef SLAVE_SIDE_CP +#define SECURE_ALIGN SZ_1M +#else // MASTER_SIDE_CP +#define SECURE_ALIGN SZ_4K +#endif + +#define INT(exp) static_cast(exp) +#define UINT(exp) static_cast(exp) + +using android::hardware::graphics::common::V1_1::BufferUsage; + +namespace gralloc { +struct BufferInfo { + BufferInfo(int w, int h, int f, uint64_t usage = 0) + : width(w), height(h), format(f), layer_count(1), usage(usage) {} + int width; + int height; + int format; + int layer_count; + uint64_t usage; +}; + +template +inline Type1 ALIGN(Type1 x, Type2 align) { + return (Type1)((x + (Type1)align - 1) & ~((Type1)align - 1)); +} + +enum PlaneComponent { + /* luma */ + PLANE_COMPONENT_Y = 1 << 0, + /* chroma blue */ + PLANE_COMPONENT_Cb = 1 << 1, + /* chroma red */ + PLANE_COMPONENT_Cr = 1 << 2, + + /* red */ + PLANE_COMPONENT_R = 1 << 10, + /* green */ + PLANE_COMPONENT_G = 1 << 11, + /* blue */ + PLANE_COMPONENT_B = 1 << 12, + + /* alpha */ + PLANE_COMPONENT_A = 1 << 20, + + /* raw data plane */ + PLANE_COMPONENT_RAW = 1 << 30, + + /* meta information plane */ + PLANE_COMPONENT_META = 1 << 31, +}; + +struct PlaneLayoutInfo { + /** Components represented the type of plane. */ + PlaneComponent component; + + /** horizontal subsampling. Must be a positive power of 2. */ + uint32_t h_subsampling; + + /** vertical subsampling. Must be a positive power of 2. */ + uint32_t v_subsampling; + + /** offset to the first byte of the top-left pixel of the plane + * and it is calculated from the start of the buffer. + * Add base of the handle with offset to get the first byte of the plane. + */ + uint32_t offset; + + /** step is the distance in bytes from one pixel value to the next. */ + int32_t step; + + /** stride of the plane in pixels */ + int32_t stride; + + /** stride of the plane in in bytes */ + int32_t stride_bytes; + + /** plane height or vertical stride */ + int32_t scanlines; + + /** size of the plane in bytes */ + uint32_t size; +}; + +bool IsCompressedRGBFormat(int format); +bool IsUncompressedRGBFormat(int format); +uint32_t GetBppForUncompressedRGB(int format); +bool CpuCanAccess(uint64_t usage); +bool CpuCanRead(uint64_t usage); +bool CpuCanWrite(uint64_t usage); +unsigned int GetSize(const BufferInfo& d, unsigned int alignedw, unsigned int alignedh); +void GetRGBPlaneInfo(const BufferInfo& info, int32_t format, int32_t width, int32_t height, + int32_t flags, int* plane_count, PlaneLayoutInfo* plane_info); +unsigned int GetRgbMetaSize(int format, uint32_t width, uint32_t height, uint64_t usage); +bool IsUBwcFormat(int format); +bool IsUBwcSupported(int format); +bool IsUBwcPISupported(int format, uint64_t usage); +bool IsUBwcEnabled(int format, uint64_t usage); +void GetRgbUBwcBlockSize(uint32_t bpp, int* block_width, int* block_height); +unsigned int GetRgbUBwcMetaBufferSize(int width, int height, uint32_t bpp); +unsigned int GetUBwcSize(int width, int height, int format, unsigned int alignedw, + unsigned int alignedh); +uint32_t GetDataAlignment(int format, uint64_t usage); +bool CanUseAdrenoForSize(int buffer_type, uint64_t usage); +bool GetAdrenoSizeAPIStatus(); +bool UseUncached(int format, uint64_t usage); +uint64_t GetHandleFlags(int format, uint64_t usage); +int GetImplDefinedFormat(uint64_t usage, int format); +int GetCustomFormatFlags(int format, uint64_t usage, int* custom_format, uint64_t* priv_flags); +bool IsGPUFlagSupported(uint64_t usage); +bool HasAlphaComponent(int32_t format); +} // namespace gralloc + +#endif // __GR_UTILS_H__ diff --git a/tools/qtimapper-shim/ext/gralloc_priv.h b/tools/qtimapper-shim/ext/gralloc_priv.h new file mode 100644 index 0000000..8a333a6 --- /dev/null +++ b/tools/qtimapper-shim/ext/gralloc_priv.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2011-2021, The Linux Foundation. All rights reserved. + * Not a Contribution + * + * Copyright (C) 2008 The Android Open Source Project + * + * 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 __GRALLOC_PRIV_H__ +#define __GRALLOC_PRIV_H__ + +#include +#include + +#include "QtiGrallocDefs.h" +#include "gr_priv_handle.h" + +//#pragma message "Warning: gralloc_priv.h is deprecated" + +#define GRALLOC_PROP_PREFIX "vendor.gralloc." +#define GRALLOC_PROP(prop_name) GRALLOC_PROP_PREFIX prop_name + +#define DISABLE_UBWC_PROP GRALLOC_PROP("disable_ubwc") +#define DISABLE_AHARDWAREBUFFER_PROP GRALLOC_PROP("disable_ahardware_buffer") +#define ENABLE_FB_UBWC_PROP GRALLOC_PROP("enable_fb_ubwc") +#define MAP_FB_MEMORY_PROP GRALLOC_PROP("map_fb_memory") +#define USE_SYSTEM_HEAP_FOR_SENSORS GRALLOC_PROP("use_system_heap_for_sensors") + +#define ROUND_UP_PAGESIZE(x) roundUpToPageSize(x) +inline int roundUpToPageSize(int x) { + return (x + (getpagesize() - 1)) & ~(getpagesize() - 1); +} + +/* Legacy gralloc1 definitions */ +/* Some clients may still be using the old flags */ +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ADSP_HEAP GRALLOC_USAGE_PRIVATE_ADSP_HEAP +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_ALLOC_UBWC +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_UNCACHED GRALLOC_USAGE_PRIVATE_UNCACHED +#define GRALLOC1_CONSUMER_USAGE_PRIVATE_SECURE_DISPLAY GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_MM_HEAP +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT GRALLOC_USAGE_PRIVATE_10BIT +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP +#define GRALLOC1_CONSUMER_USAGE_PRIVATE_10BIT_TP GRALLOC_USAGE_PRIVATE_10BIT_TP +#define GRALLOC1_PRODUCER_USAGE_PRIVATE_VIDEO_NV21_ENCODER GRALLOC_USAGE_PRIVATE_VIDEO_NV21_ENCODER + +// for PERFORM API : +#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 +#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2 +#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3 +#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4 +#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5 +#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 +#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 +#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 +#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 +#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10 +#define GRALLOC_MODULE_PERFORM_GET_IGC 11 +#define GRALLOC_MODULE_PERFORM_SET_IGC 12 +#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13 +#define GRALLOC1_MODULE_PERFORM_GET_BUFFER_SIZE_AND_DIMENSIONS 14 +#define GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG 15 +#define GRALLOC_MODULE_PERFORM_GET_GRAPHICS_METADATA 16 + +/* possible values for inverse gamma correction */ +#define HAL_IGC_NOT_SPECIFIED 0 +#define HAL_IGC_s_RGB 1 + +/* Color Space: Values maps to ColorSpace_t in qdMetadata.h */ +#define HAL_CSC_ITU_R_601 0 +#define HAL_CSC_ITU_R_601_FR 1 +#define HAL_CSC_ITU_R_709 2 +#define HAL_CSC_ITU_R_709_FR 3 +#define HAL_CSC_ITU_R_2020 4 +#define HAL_CSC_ITU_R_2020_FR 5 + +/* possible formats for 3D content*/ +enum { + HAL_NO_3D = 0x0, + HAL_3D_SIDE_BY_SIDE_L_R = 0x1, + HAL_3D_SIDE_BY_SIDE_R_L = 0x2, + HAL_3D_TOP_BOTTOM = 0x4, + HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, // unused legacy format +}; + +/* Flag to determine interlaced content + * Value maps to Flags presents in types.hal of QtiMapperextensions + */ +enum { + LAYOUT_INTERLACED_FLAG = 1 << 0, +}; + +#endif // __GRALLOC_PRIV_H__ diff --git a/tools/qtimapper-shim/ext/mapper.h b/tools/qtimapper-shim/ext/mapper.h new file mode 100644 index 0000000..c7bbf08 --- /dev/null +++ b/tools/qtimapper-shim/ext/mapper.h @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2016-2022, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "types/mapper.h" + +namespace vendor::qti::hardware::display::mapperextensions::V1_0 { +struct IQtiMapperExtensions; +} + +namespace android::hardware::graphics::mapper { +namespace V2_0 { + +struct IMapper : public IBase { + struct BufferDescriptorInfo final { + uint32_t width __attribute__((aligned(4))); + uint32_t height __attribute__((aligned(4))); + uint32_t layerCount __attribute__((aligned(4))); + graphics::common::V1_0::PixelFormat format __attribute__((aligned(4))); + hidl_bitfield usage __attribute__((aligned(8))); + }; + + struct Rect final { + int32_t left __attribute__((aligned(4))); + int32_t top __attribute__((aligned(4))); + int32_t width __attribute__((aligned(4))); + int32_t height __attribute__((aligned(4))); + }; + +#ifdef SHIM_MODE + static sp getService(const std::string& /* serviceName */, const bool /* getStub */); +#endif +}; + +} // namespace V2_0 +namespace V3_0 { + +struct IMapper : public IBase { + static sp getService(const std::string& /* serviceName */, const bool /* getStub */); +}; + +} // namespace V3_0 +namespace V4_0 { + +struct IMapper : public IBase { + static sp getService(const std::string& /* serviceName */, const bool /* getStub */); +}; + +} // namespace V4_0 +} // namespace android::hardware::graphics::mapper + +namespace vendor::qti::hardware::display::mapper { +namespace V4_0 { + +struct IQtiMapper : public IBase { + static Return> castFrom(const sp& /* parent */, + bool /* emitError */); +}; + +} // namespace V4_0 +namespace V3_0 { + +struct IQtiMapper : public IBase { + static Return> castFrom(const sp& /* parent */, + bool /* emitError */); +}; + +} // namespace V3_0 +#ifdef SHIM_MODE +namespace V2_0 { + +struct IQtiMapper : public IBase { + using createDescriptor_cb = std::function& descriptor)>; + virtual Return createDescriptor( + const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo& descriptorInfo, + createDescriptor_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + using importBuffer_cb = std::function; + virtual Return importBuffer(const hidl_handle& rawHandle, importBuffer_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return freeBuffer(void* buffer) { + ALOGE("%s", __func__); + std::terminate(); + } + + using lock_cb = std::function; + virtual Return lock(void* buffer, + hidl_bitfield cpuUsage, + const graphics::mapper::V2_0::IMapper::Rect& accessRegion, + const hidl_handle& acquireFence, lock_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + using lockYCbCr_cb = std::function; + virtual Return lockYCbCr(void* buffer, + hidl_bitfield cpuUsage, + const graphics::mapper::V2_0::IMapper::Rect& accessRegion, + const hidl_handle& acquireFence, lockYCbCr_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + using unlock_cb = + std::function; + virtual Return unlock(void* buffer, unlock_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual Return validateBufferSize( + void* buffer, const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo& descriptorInfo, + uint32_t stride) { + ALOGE("%s", __func__); + std::terminate(); + } + + using getTransportSize_cb = + std::function; + virtual Return getTransportSize(void* buffer, getTransportSize_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + using createDescriptor_2_1_cb = std::function& descriptor)>; + virtual Return createDescriptor_2_1( + const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo& descriptorInfo, + createDescriptor_2_1_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + using getMapperExtensions_cb = + std::function& extensions)>; + virtual Return getMapperExtensions(getMapperExtensions_cb _hidl_cb); + + static Return> castFrom(const sp& /* parent */, + bool /* emitError */); +}; + +} // namespace V2_0 +#endif +} // namespace vendor::qti::hardware::display::mapper diff --git a/tools/qtimapper-shim/ext/mapperextensions.h b/tools/qtimapper-shim/ext/mapperextensions.h new file mode 100644 index 0000000..078cb90 --- /dev/null +++ b/tools/qtimapper-shim/ext/mapperextensions.h @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2016-2022, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "gralloc_priv.h" +#include "types/mapperextensions.h" + +namespace vendor::qti::hardware::display::mapperextensions { +namespace V1_0 { + +struct IQtiMapperExtensions : public IBase { + IQtiMapperExtensions(){}; +}; + +} // namespace V1_0 +namespace V1_1 { +using Error = V1_0::Error; +using PlaneLayout = V1_0::PlaneLayout; + +struct IQtiMapperExtensions : public IBase { + IQtiMapperExtensions(); + + gralloc1_device_t* gralloc; + GRALLOC1_PFN_PERFORM perform; + + using getMapSecureBufferFlag_cb = std::function; + virtual ::android::hardware::Return getMapSecureBufferFlag( + void* buffer, getMapSecureBufferFlag_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + // Used, passthrough + using getInterlacedFlag_cb = std::function; + virtual ::android::hardware::Return getInterlacedFlag(void* buffer, + getInterlacedFlag_cb _hidl_cb); + + using getCustomDimensions_cb = + std::function; + virtual ::android::hardware::Return getCustomDimensions(void* buffer, + getCustomDimensions_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + // Used, passthrough + using getRgbDataAddress_cb = std::function; + virtual ::android::hardware::Return getRgbDataAddress(void* buffer, + getRgbDataAddress_cb _hidl_cb); + + using calculateBufferAttributes_cb = + std::function; + virtual ::android::hardware::Return calculateBufferAttributes( + int32_t width, int32_t height, int32_t format, uint64_t usage, + calculateBufferAttributes_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + // Used, passhthrough + using getColorSpace_cb = std::function; + virtual ::android::hardware::Return getColorSpace(void* buffer, getColorSpace_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + // Used, passthrough with hidl fixups + using getYuvPlaneInfo_cb = std::function& layout)>; + virtual ::android::hardware::Return getYuvPlaneInfo(void* buffer, + getYuvPlaneInfo_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + virtual ::android::hardware::Return< + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error> + setSingleBufferMode(void* buffer, bool enable) { + ALOGE("%s", __func__); + std::terminate(); + } + + using getCustomFormatFlags_cb = + std::function; + virtual ::android::hardware::Return getCustomFormatFlags(int32_t format, uint64_t usage, + getCustomFormatFlags_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + // Used, cast private data with no passthrough + using getFd_cb = std::function; + virtual ::android::hardware::Return getFd(void* buffer, getFd_cb _hidl_cb); + + // Used, cast private data with no passthrough + using getWidth_cb = std::function; + virtual ::android::hardware::Return getWidth(void* buffer, getWidth_cb _hidl_cb); + + // Used, cast private data with no passthrough + using getHeight_cb = std::function; + virtual ::android::hardware::Return getHeight(void* buffer, getHeight_cb _hidl_cb); + + // Used, cast private data with no passthrough + using getOffset_cb = std::function; + virtual ::android::hardware::Return getOffset(void* buffer, getOffset_cb _hidl_cb); + + // Used, cast private data with no passthrough + using getSize_cb = std::function; + virtual ::android::hardware::Return getSize(void* buffer, getSize_cb _hidl_cb); + + using getUnalignedWidth_cb = + std::function; + virtual ::android::hardware::Return getUnalignedWidth(void* buffer, + getUnalignedWidth_cb _hidl_cb); + + using getUnalignedHeight_cb = + std::function; + virtual ::android::hardware::Return getUnalignedHeight(void* buffer, + getUnalignedHeight_cb _hidl_cb); + + using getLayerCount_cb = std::function; + virtual ::android::hardware::Return getLayerCount(void* buffer, getLayerCount_cb _hidl_cb); + + using getId_cb = std::function; + virtual ::android::hardware::Return getId(void* buffer, getId_cb _hidl_cb); + + using getUsageFlags_cb = std::function; + virtual ::android::hardware::Return getUsageFlags(void* buffer, getUsageFlags_cb _hidl_cb); + + // Used, cast private data with no passthrough + using getFormat_cb = std::function; + virtual ::android::hardware::Return getFormat(void* buffer, getFormat_cb _hidl_cb); + + // Used, cast private data with no passthrough + using getPrivateFlags_cb = std::function; + virtual ::android::hardware::Return getPrivateFlags(void* buffer, + getPrivateFlags_cb _hidl_cb); + + using getSurfaceMetadata_cb = std::function; + virtual ::android::hardware::Return getSurfaceMetadata(void* buffer, + getSurfaceMetadata_cb _hidl_cb) { + ALOGE("%s", __func__); + std::terminate(); + } + + // Used, PAIN + using getFormatLayout_cb = std::function& plane_info)>; + virtual ::android::hardware::Return getFormatLayout(int32_t format, uint64_t usage, + int32_t flags, int32_t width, + int32_t height, + getFormatLayout_cb _hidl_cb); + + // V1.1, Used, passthrough + virtual ::android::hardware::Return< + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error> + getSurfaceMetadata_V1(void* buffer, void* metadata) { + ALOGE("%s", __func__); + std::terminate(); + } + + static Return> castFrom( + android::sp const& /* parent */, bool /* emitError */); +}; + +} // namespace V1_1 +} // namespace vendor::qti::hardware::display::mapperextensions diff --git a/tools/qtimapper-shim/ext/types/common.h b/tools/qtimapper-shim/ext/types/common.h new file mode 100644 index 0000000..6f327ba --- /dev/null +++ b/tools/qtimapper-shim/ext/types/common.h @@ -0,0 +1,6744 @@ +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H +#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H + +#include +#include +#include +#include + +namespace android { +namespace hardware { +namespace graphics { +namespace common { +namespace V1_0 { + +// Forward declaration for forward reference support: +enum class PixelFormat : int32_t; +enum class BufferUsage : uint64_t; +enum class Transform : int32_t; +enum class Dataspace : int32_t; +enum class ColorMode : int32_t; +enum class ColorTransform : int32_t; +enum class Hdr : int32_t; + +/** + * Common enumeration and structure definitions for all graphics HALs. + * + * + * Pixel formats for graphics buffers. + */ +enum class PixelFormat : int32_t { + /** + * 32-bit format that has 8-bit R, G, B, and A components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGBA_8888 = 1 /* 0x1 */, + /** + * 32-bit format that has 8-bit R, G, B, and unused components, in that + * order, from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGBX_8888 = 2 /* 0x2 */, + /** + * 24-bit format that has 8-bit R, G, and B components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGB_888 = 3 /* 0x3 */, + /** + * 16-bit packed format that has 5-bit R, 6-bit G, and 5-bit B components, + * in that order, from the most-sigfinicant bits to the least-significant + * bits. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGB_565 = 4 /* 0x4 */, + /** + * 32-bit format that has 8-bit B, G, R, and A components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + BGRA_8888 = 5 /* 0x5 */, + /** + * Legacy formats deprecated in favor of YCBCR_420_888. + */ + YCBCR_422_SP = 16 /* 0x10 */, + YCRCB_420_SP = 17 /* 0x11 */, + YCBCR_422_I = 20 /* 0x14 */, + /** + * 64-bit format that has 16-bit R, G, B, and A components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are signed floats, whose interpretation is defined + * by the dataspace. + */ + RGBA_FP16 = 22 /* 0x16 */, + /** + * RAW16 is a single-channel, 16-bit, little endian format, typically + * representing raw Bayer-pattern images from an image sensor, with minimal + * processing. + * + * The exact pixel layout of the data in the buffer is sensor-dependent, and + * needs to be queried from the camera device. + * + * Generally, not all 16 bits are used; more common values are 10 or 12 + * bits. If not all bits are used, the lower-order bits are filled first. + * All parameters to interpret the raw data (black and white points, + * color space, etc) must be queried from the camera device. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * - strides are specified in pixels, not in bytes + * + * size = stride * height * 2 + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW16 is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data, layout is as + * | defined above. + * Dataspace::DEPTH | Unprocessed implementation-dependent raw + * | depth measurements, opaque with 16 bit + * | samples. + * Other | Unsupported + */ + RAW16 = 32 /* 0x20 */, + /** + * BLOB is used to carry task-specific data which does not have a standard + * image structure. The details of the format are left to the two + * endpoints. + * + * A typical use case is for transporting JPEG-compressed images from the + * Camera HAL to the framework or to applications. + * + * Buffers of this format must have a height of 1, and width equal to their + * size in bytes. + * + * The mapping of the dataspace to buffer contents for BLOB is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::JFIF | An encoded JPEG image + * Dataspace::DEPTH | An android_depth_points buffer + * Dataspace::SENSOR | Sensor event data. + * Other | Unsupported + */ + BLOB = 33 /* 0x21 */, + /** + * A format indicating that the choice of format is entirely up to the + * allocator. + * + * The allocator should examine the usage bits passed in when allocating a + * buffer with this format, and it should derive the pixel format from + * those usage flags. This format must never be used with any of the + * BufferUsage::CPU_* usage flags. + * + * Even when the internally chosen format has an alpha component, the + * clients must assume the alpha vlaue to be 1.0. + * + * The interpretation of the component values is defined by the dataspace. + */ + IMPLEMENTATION_DEFINED = 34 /* 0x22 */, + /** + * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 + * buffer layout, while still describing the general format in a + * layout-independent manner. While called YCbCr, it can be used to + * describe formats with either chromatic ordering, as well as + * whole planar or semiplanar layouts. + * + * This format must be accepted by the allocator when BufferUsage::CPU_* + * are set. + * + * Buffers with this format must be locked with IMapper::lockYCbCr. + * Locking with IMapper::lock must return an error. + * + * The interpretation of the component values is defined by the dataspace. + */ + YCBCR_420_888 = 35 /* 0x23 */, + /** + * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an + * image sensor. The actual structure of buffers of this format is + * implementation-dependent. + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW_OPAQUE is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data. + * Other | Unsupported + */ + RAW_OPAQUE = 36 /* 0x24 */, + /** + * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, + * unprocessed format, usually representing raw Bayer-pattern images coming from + * an image sensor. + * + * In an image buffer with this format, starting from the first pixel of each + * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one + * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte + * contains the 2 least significant bits of the 4 pixels, the exact layout data + * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth + * bit of the ith pixel): + * + * bit 7 bit 0 + * =====|=====|=====|=====|=====|=====|=====|=====| + * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| + * =============================================== + * + * This format assumes + * - a width multiple of 4 pixels + * - an even height + * - a vertical stride equal to the height + * - strides are specified in bytes, not in pixels + * + * size = stride * height + * + * When stride is equal to width * (10 / 8), there will be no padding bytes at + * the end of each row, the entire image data is densely packed. When stride is + * larger than width * (10 / 8), padding bytes will be present at the end of each + * row (including the last row). + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW10 is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data. + * Other | Unsupported + */ + RAW10 = 37 /* 0x25 */, + /** + * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, + * unprocessed format, usually representing raw Bayer-pattern images coming from + * an image sensor. + * + * In an image buffer with this format, starting from the first pixel of each + * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first + * and second byte contains the top 8 bits of first and second pixel. The third + * byte contains the 4 least significant bits of the two pixels, the exact layout + * data for each two consecutive pixels is illustrated below (Pi[j] stands for + * the jth bit of the ith pixel): + * + * bit 7 bit 0 + * ======|======|======|======|======|======|======|======| + * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| + * |------|------|------|------|------|------|------|------| + * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| + * |------|------|------|------|------|------|------|------| + * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| + * ======================================================= + * + * This format assumes: + * - a width multiple of 4 pixels + * - an even height + * - a vertical stride equal to the height + * - strides are specified in bytes, not in pixels + * + * size = stride * height + * + * When stride is equal to width * (12 / 8), there will be no padding bytes at + * the end of each row, the entire image data is densely packed. When stride is + * larger than width * (12 / 8), padding bytes will be present at the end of + * each row (including the last row). + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW12 is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data. + * Other | Unsupported + */ + RAW12 = 38 /* 0x26 */, + /** + * 0x27 to 0x2A are reserved for flexible formats + * + * + * 32-bit packed format that has 2-bit A, 10-bit B, G, and R components, + * in that order, from the most-sigfinicant bits to the least-significant + * bits. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGBA_1010102 = 43 /* 0x2B */, + /** + * 0x100 - 0x1FF + * + * This range is reserved for vendor extensions. Formats in this range + * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not + * have an alpha component. + * + * + * Y8 is a YUV planar format comprised of a WxH Y plane, with each pixel + * being represented by 8 bits. It is equivalent to just the Y plane from + * YV12. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * + * size = stride * height + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + Y8 = 538982489 /* 0x20203859 */, + /** + * Y16 is a YUV planar format comprised of a WxH Y plane, with each pixel + * being represented by 16 bits. It is just like Y8, but has double the + * bits per pixel (little endian). + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * - strides are specified in pixels, not in bytes + * + * size = stride * height * 2 + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. When the dataspace is + * Dataspace::DEPTH, each pixel is a distance value measured by a depth + * camera, plus an associated confidence value. + */ + Y16 = 540422489 /* 0x20363159 */, + /** + * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed + * by (W/2) x (H/2) Cr and Cb planes. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * + * y_size = stride * height + * c_stride = ALIGN(stride/2, 16) + * c_size = c_stride * height/2 + * size = y_size + c_size * 2 + * cr_offset = y_size + * cb_offset = y_size + c_size + * + * This range is reserved for vendor extensions. Formats in this range + * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not + * have an alpha component. + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::GPU_TEXTURE + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + YV12 = 842094169 /* 0x32315659 */, +}; + +/** + * Buffer usage definitions. + */ +enum class BufferUsage : uint64_t { + /** + * bit 0-3 is an enum + */ + CPU_READ_MASK = 15ull /* 0xfULL */, + /** + * buffer is never read by CPU + */ + CPU_READ_NEVER = 0ull, + /** + * buffer is rarely read by CPU + */ + CPU_READ_RARELY = 2ull, + /** + * buffer is often read by CPU + */ + CPU_READ_OFTEN = 3ull, + /** + * bit 4-7 is an enum + */ + CPU_WRITE_MASK = 240ull /* (0xfULL << 4) */, + /** + * buffer is never written by CPU + */ + CPU_WRITE_NEVER = 0ull /* (0 << 4) */, + /** + * buffer is rarely written by CPU + */ + CPU_WRITE_RARELY = 32ull /* (2 << 4) */, + /** + * buffer is often written by CPU + */ + CPU_WRITE_OFTEN = 48ull /* (3 << 4) */, + /** + * buffer is used as a GPU texture + */ + GPU_TEXTURE = 256ull /* (1ULL << 8) */, + /** + * buffer is used as a GPU render target + */ + GPU_RENDER_TARGET = 512ull /* (1ULL << 9) */, + /** + * bit 10 must be zero + * + * + * buffer is used as a composer HAL overlay layer + */ + COMPOSER_OVERLAY = 2048ull /* (1ULL << 11) */, + /** + * buffer is used as a composer HAL client target + */ + COMPOSER_CLIENT_TARGET = 4096ull /* (1ULL << 12) */, + /** + * bit 13 must be zero + * + * + * Buffer is allocated with hardware-level protection against copying the + * contents (or information derived from the contents) into unprotected + * memory. + */ + PROTECTED = 16384ull /* (1ULL << 14) */, + /** + * buffer is used as a hwcomposer HAL cursor layer + */ + COMPOSER_CURSOR = 32768ull /* (1ULL << 15) */, + /** + * buffer is used as a video encoder input + */ + VIDEO_ENCODER = 65536ull /* (1ULL << 16) */, + /** + * buffer is used as a camera HAL output + */ + CAMERA_OUTPUT = 131072ull /* (1ULL << 17) */, + /** + * buffer is used as a camera HAL input + */ + CAMERA_INPUT = 262144ull /* (1ULL << 18) */, + /** + * bit 19 must be zero + * + * + * buffer is used as a renderscript allocation + */ + RENDERSCRIPT = 1048576ull /* (1ULL << 20) */, + /** + * bit 21 must be zero + * + * + * buffer is used as a video decoder output + */ + VIDEO_DECODER = 4194304ull /* (1ULL << 22) */, + /** + * buffer is used as a sensor direct report output + */ + SENSOR_DIRECT_DATA = 8388608ull /* (1ULL << 23) */, + /** + * buffer is used as as an OpenGL shader storage or uniform + * buffer object + */ + GPU_DATA_BUFFER = 16777216ull /* (1ULL << 24) */, + /** + * bits 25-27 must be zero and are reserved for future versions + * + * + * bits 28-31 are reserved for vendor extensions + */ + VENDOR_MASK = 4026531840ull /* (0xfULL << 28) */, + /** + * bits 32-47 must be zero and are reserved for future versions + * + * + * bits 48-63 are reserved for vendor extensions + */ + VENDOR_MASK_HI = 18446462598732840960ull /* (0xffffULL << 48) */, +}; + +/** + * Transformation definitions + */ +enum class Transform : int32_t { + /** + * Horizontal flip. FLIP_H/FLIP_V is applied before ROT_90. + */ + FLIP_H = 1 /* (1 << 0) */, + /** + * Vertical flip. FLIP_H/FLIP_V is applied before ROT_90. + */ + FLIP_V = 2 /* (1 << 1) */, + /** + * 90 degree clockwise rotation. FLIP_H/FLIP_V is applied before ROT_90. + */ + ROT_90 = 4 /* (1 << 2) */, + /** + * Commonly used combinations. + */ + ROT_180 = 3 /* (FLIP_H | FLIP_V) */, + ROT_270 = 7 /* ((FLIP_H | FLIP_V) | ROT_90) */, +}; + +/** + * Dataspace Definitions + * ====================== + * + * Dataspace is the definition of how pixel values should be interpreted. + * + * For many formats, this is the colorspace of the image data, which includes + * primaries (including white point) and the transfer characteristic function, + * which describes both gamma curve and numeric range (within the bit depth). + * + * Other dataspaces include depth measurement data from a depth camera. + * + * A dataspace is comprised of a number of fields. + * + * Version + * -------- + * The top 2 bits represent the revision of the field specification. This is + * currently always 0. + * + * + * bits 31-30 29 - 0 + * +-----+----------------------------------------------------+ + * fields | Rev | Revision specific fields | + * +-----+----------------------------------------------------+ + * + * Field layout for version = 0: + * ---------------------------- + * + * A dataspace is comprised of the following fields: + * Standard + * Transfer function + * Range + * + * bits 31-30 29-27 26 - 22 21 - 16 15 - 0 + * +-----+-----+--------+--------+----------------------------+ + * fields | 0 |Range|Transfer|Standard| Legacy and custom | + * +-----+-----+--------+--------+----------------------------+ + * VV RRR TTTTT SSSSSS LLLLLLLL LLLLLLLL + * + * If range, transfer and standard fields are all 0 (e.g. top 16 bits are + * all zeroes), the bottom 16 bits contain either a legacy dataspace value, + * or a custom value. + */ +enum class Dataspace : int32_t { + /** + * Default-assumption data space, when not explicitly specified. + * + * It is safest to assume the buffer is an image with sRGB primaries and + * encoding ranges, but the consumer and/or the producer of the data may + * simply be using defaults. No automatic gamma transform should be + * expected, except for a possible display gamma transform when drawn to a + * screen. + */ + UNKNOWN = 0 /* 0x0 */, + /** + * Arbitrary dataspace with manually defined characteristics. Definition + * for colorspaces or other meaning must be communicated separately. + * + * This is used when specifying primaries, transfer characteristics, + * etc. separately. + * + * A typical use case is in video encoding parameters (e.g. for H.264), + * where a colorspace can have separately defined primaries, transfer + * characteristics, etc. + */ + ARBITRARY = 1 /* 0x1 */, + /** + * Color-description aspects + * + * The following aspects define various characteristics of the color + * specification. These represent bitfields, so that a data space value + * can specify each of them independently. + */ + STANDARD_SHIFT = 16, + /** + * Standard aspect + * + * Defines the chromaticity coordinates of the source primaries in terms of + * the CIE 1931 definition of x and y specified in ISO 11664-1. + */ + STANDARD_MASK = 4128768 /* (63 << STANDARD_SHIFT) */, + /** + * Chromacity coordinates are unknown or are determined by the application. + * Implementations shall use the following suggested standards: + * + * All YCbCr formats: BT709 if size is 720p or larger (since most video + * content is letterboxed this corresponds to width is + * 1280 or greater, or height is 720 or greater). + * BT601_625 if size is smaller than 720p or is JPEG. + * All RGB formats: BT709. + * + * For all other formats standard is undefined, and implementations should use + * an appropriate standard for the data represented. + */ + STANDARD_UNSPECIFIED = 0 /* (0 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT709 = 65536 /* (1 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + */ + STANDARD_BT601_625 = 131072 /* (2 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT601_625_UNADJUSTED = 196608 /* (3 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + */ + STANDARD_BT601_525 = 262144 /* (4 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation + * for RGB conversion (as in SMPTE 240M). + */ + STANDARD_BT601_525_UNADJUSTED = 327680 /* (5 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.170 0.797 + * blue 0.131 0.046 + * red 0.708 0.292 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT2020 = 393216 /* (6 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.170 0.797 + * blue 0.131 0.046 + * red 0.708 0.292 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation + * for RGB conversion using the linear domain. + */ + STANDARD_BT2020_CONSTANT_LUMINANCE = 458752 /* (7 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.21 0.71 + * blue 0.14 0.08 + * red 0.67 0.33 + * white (C) 0.310 0.316 + * + * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT470M = 524288 /* (8 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.243 0.692 + * blue 0.145 0.049 + * red 0.681 0.319 + * white (C) 0.310 0.316 + * + * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation + * for RGB conversion. + */ + STANDARD_FILM = 589824 /* (9 << STANDARD_SHIFT) */, + /** + * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3) + * Primaries: x y + * green 0.265 0.690 + * blue 0.150 0.060 + * red 0.680 0.320 + * white (D65) 0.3127 0.3290 + */ + STANDARD_DCI_P3 = 655360 /* (10 << STANDARD_SHIFT) */, + /** + * Adobe RGB + * Primaries: x y + * green 0.210 0.710 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + */ + STANDARD_ADOBE_RGB = 720896 /* (11 << STANDARD_SHIFT) */, + TRANSFER_SHIFT = 22, + /** + * Transfer aspect + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + * + * For digital signals, E corresponds to the recorded value. Normally, the + * transfer function is applied in RGB space to each of the R, G and B + * components independently. This may result in color shift that can be + * minized by applying the transfer function in Lab space only for the L + * component. Implementation may apply the transfer function in RGB space + * for all pixel formats if desired. + */ + TRANSFER_MASK = 130023424 /* (31 << TRANSFER_SHIFT) */, + /** + * Transfer characteristics are unknown or are determined by the + * application. + * + * Implementations should use the following transfer functions: + * + * For YCbCr formats: use TRANSFER_SMPTE_170M + * For RGB formats: use TRANSFER_SRGB + * + * For all other formats transfer function is undefined, and implementations + * should use an appropriate standard for the data represented. + */ + TRANSFER_UNSPECIFIED = 0 /* (0 << TRANSFER_SHIFT) */, + /** + * Transfer characteristic curve: + * E = L + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_LINEAR = 4194304 /* (1 << TRANSFER_SHIFT) */, + /** + * Transfer characteristic curve: + * + * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1 + * = 12.92 * L for 0 <= L < 0.0031308 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_SRGB = 8388608 /* (2 << TRANSFER_SHIFT) */, + /** + * BT.601 525, BT.601 625, BT.709, BT.2020 + * + * Transfer characteristic curve: + * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1 + * = 4.500 * L for 0 <= L < 0.018 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_SMPTE_170M = 12582912 /* (3 << TRANSFER_SHIFT) */, + /** + * Assumed display gamma 2.2. + * + * Transfer characteristic curve: + * E = L ^ (1/2.2) + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_GAMMA2_2 = 16777216 /* (4 << TRANSFER_SHIFT) */, + /** + * display gamma 2.6. + * + * Transfer characteristic curve: + * E = L ^ (1/2.6) + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_GAMMA2_6 = 20971520 /* (5 << TRANSFER_SHIFT) */, + /** + * display gamma 2.8. + * + * Transfer characteristic curve: + * E = L ^ (1/2.8) + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_GAMMA2_8 = 25165824 /* (6 << TRANSFER_SHIFT) */, + /** + * SMPTE ST 2084 (Dolby Perceptual Quantizer) + * + * Transfer characteristic curve: + * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m + * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375 + * c2 = 32 * 2413 / 4096 = 18.8515625 + * c3 = 32 * 2392 / 4096 = 18.6875 + * m = 128 * 2523 / 4096 = 78.84375 + * n = 0.25 * 2610 / 4096 = 0.1593017578125 + * L - luminance of image 0 <= L <= 1 for HDR colorimetry. + * L = 1 corresponds to 10000 cd/m2 + * E - corresponding electrical signal + */ + TRANSFER_ST2084 = 29360128 /* (7 << TRANSFER_SHIFT) */, + /** + * ARIB STD-B67 Hybrid Log Gamma + * + * Transfer characteristic curve: + * E = r * L^0.5 for 0 <= L <= 1 + * = a * ln(L - b) + c for 1 < L + * a = 0.17883277 + * b = 0.28466892 + * c = 0.55991073 + * r = 0.5 + * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds + * to reference white level of 100 cd/m2 + * E - corresponding electrical signal + */ + TRANSFER_HLG = 33554432 /* (8 << TRANSFER_SHIFT) */, + RANGE_SHIFT = 27, + /** + * Range aspect + * + * Defines the range of values corresponding to the unit range of 0-1. + * This is defined for YCbCr only, but can be expanded to RGB space. + */ + RANGE_MASK = 939524096 /* (7 << RANGE_SHIFT) */, + /** + * Range is unknown or are determined by the application. Implementations + * shall use the following suggested ranges: + * + * All YCbCr formats: limited range. + * All RGB or RGBA formats (including RAW and Bayer): full range. + * All Y formats: full range + * + * For all other formats range is undefined, and implementations should use + * an appropriate range for the data represented. + */ + RANGE_UNSPECIFIED = 0 /* (0 << RANGE_SHIFT) */, + /** + * Full range uses all values for Y, Cb and Cr from + * 0 to 2^b-1, where b is the bit depth of the color format. + */ + RANGE_FULL = 134217728 /* (1 << RANGE_SHIFT) */, + /** + * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and + * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of + * the color format. + * + * E.g. For 8-bit-depth formats: + * Luma (Y) samples should range from 16 to 235, inclusive + * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive + * + * For 10-bit-depth formats: + * Luma (Y) samples should range from 64 to 940, inclusive + * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive + */ + RANGE_LIMITED = 268435456 /* (2 << RANGE_SHIFT) */, + /** + * Extended range is used for scRGB. Intended for use with + * floating point pixel formats. [0.0 - 1.0] is the standard + * sRGB space. Values outside the range 0.0 - 1.0 can encode + * color outside the sRGB gamut. + * Used to blend / merge multiple dataspaces on a single display. + */ + RANGE_EXTENDED = 402653184 /* (3 << RANGE_SHIFT) */, + /** + * Legacy dataspaces + * + * + * sRGB linear encoding: + * + * The red, green, and blue components are stored in sRGB space, but + * are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are encoded using the full range ([0,255] for 8-bit) for all + * components. + */ + SRGB_LINEAR = 512 /* 0x200 */, + V0_SRGB_LINEAR = 138477568 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * scRGB linear encoding: + * + * The red, green, and blue components are stored in extended sRGB space, + * but are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are floating point. + * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. + * Values beyond the range [0.0 - 1.0] would correspond to other colors + * spaces and/or HDR content. + */ + V0_SCRGB_LINEAR = 406913024 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_EXTENDED) */, + /** + * sRGB gamma encoding: + * + * The red, green and blue components are stored in sRGB space, and + * converted to linear space when read, using the SRGB transfer function + * for each of the R, G and B components. When written, the inverse + * transformation is performed. + * + * The alpha component, if present, is always stored in linear space and + * is left unmodified when read or written. + * + * Use full range and BT.709 standard. + */ + SRGB = 513 /* 0x201 */, + V0_SRGB = 142671872 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_FULL) */, + /** + * scRGB: + * + * The red, green, and blue components are stored in extended sRGB space, + * but are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are floating point. + * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. + * Values beyond the range [0.0 - 1.0] would correspond to other colors + * spaces and/or HDR content. + */ + V0_SCRGB = 411107328 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_EXTENDED) */, + /** + * YCbCr Colorspaces + * ----------------- + * + * Primaries are given using (x,y) coordinates in the CIE 1931 definition + * of x and y specified by ISO 11664-1. + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + * + * + * JPEG File Interchange Format (JFIF) + * + * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 + * + * Use full range, BT.601 transfer and BT.601_625 standard. + */ + JFIF = 257 /* 0x101 */, + V0_JFIF = 146931712 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, + /** + * ITU-R Recommendation 601 (BT.601) - 625-line + * + * Standard-definition television, 625 Lines (PAL) + * + * Use limited range, BT.601 transfer and BT.601_625 standard. + */ + BT601_625 = 258 /* 0x102 */, + V0_BT601_625 = 281149440 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * ITU-R Recommendation 601 (BT.601) - 525-line + * + * Standard-definition television, 525 Lines (NTSC) + * + * Use limited range, BT.601 transfer and BT.601_525 standard. + */ + BT601_525 = 259 /* 0x103 */, + V0_BT601_525 = 281280512 /* ((STANDARD_BT601_525 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * ITU-R Recommendation 709 (BT.709) + * + * High-definition television + * + * Use limited range, BT.709 transfer and BT.709 standard. + */ + BT709 = 260 /* 0x104 */, + V0_BT709 = 281083904 /* ((STANDARD_BT709 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * SMPTE EG 432-1 and SMPTE RP 431-2. + * + * Digital Cinema DCI-P3 + * + * Use full range, linear transfer and D65 DCI-P3 standard + */ + DCI_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * SMPTE EG 432-1 and SMPTE RP 431-2. + * + * Digital Cinema DCI-P3 + * + * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard + * Note: Application is responsible for gamma encoding the data as + * a 2.6 gamma encoding is not supported in HW. + */ + DCI_P3 = 155844608 /* ((STANDARD_DCI_P3 | TRANSFER_GAMMA2_6) | RANGE_FULL) */, + /** + * Display P3 + * + * Display P3 uses same primaries and white-point as DCI-P3 + * linear transfer function makes this the same as DCI_P3_LINEAR. + */ + DISPLAY_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * Display P3 + * + * Use same primaries and white-point as DCI-P3 + * but sRGB transfer function. + */ + DISPLAY_P3 = 143261696 /* ((STANDARD_DCI_P3 | TRANSFER_SRGB) | RANGE_FULL) */, + /** + * Adobe RGB + * + * Use full range, gamma 2.2 transfer and Adobe RGB primaries + * Note: Application is responsible for gamma encoding the data as + * a 2.2 gamma encoding is not supported in HW. + */ + ADOBE_RGB = 151715840 /* ((STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2) | RANGE_FULL) */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, linear transfer and BT2020 standard + */ + BT2020_LINEAR = 138805248 /* ((STANDARD_BT2020 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, BT.709 transfer and BT2020 standard + */ + BT2020 = 147193856 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard + */ + BT2020_PQ = 163971072 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_FULL) */, + /** + * Data spaces for non-color formats + * + * + * The buffer contains depth ranging measurements from a depth camera. + * This value is valid with formats: + * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement + * and an associated confidence value. The 3 MSBs of the sample make + * up the confidence value, and the low 13 LSBs of the sample make up + * the depth measurement. + * For the confidence section, 0 means 100% confidence, 1 means 0% + * confidence. The mapping to a linear float confidence value between + * 0.f and 1.f can be obtained with + * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; + * The depth measurement can be extracted simply with + * uint16_t range = (depthSample & 0x1FFF); + * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as + * a variable-length float (x,y,z, confidence) coordinate point list. + * The point cloud will be represented with the android_depth_points + * structure. + */ + DEPTH = 4096 /* 0x1000 */, + /** + * The buffer contains sensor events from sensor direct report. + * This value is valid with formats: + * HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms + * a lock free queue. Format of sensor event structure is specified + * in Sensors HAL. + */ + SENSOR = 4097 /* 0x1001 */, +}; + +/** + * Color modes that may be supported by a display. + * + * Definitions: + * Rendering intent generally defines the goal in mapping a source (input) + * color to a destination device color for a given color mode. + * + * It is important to keep in mind three cases where mapping may be applied: + * 1. The source gamut is much smaller than the destination (display) gamut + * 2. The source gamut is much larger than the destination gamut (this will + * ordinarily be handled using colorimetric rendering, below) + * 3. The source and destination gamuts are roughly equal, although not + * completely overlapping + * Also, a common requirement for mappings is that skin tones should be + * preserved, or at least remain natural in appearance. + * + * Colorimetric Rendering Intent (All cases): + * Colorimetric indicates that colors should be preserved. In the case + * that the source gamut lies wholly within the destination gamut or is + * about the same (#1, #3), this will simply mean that no manipulations + * (no saturation boost, for example) are applied. In the case where some + * source colors lie outside the destination gamut (#2, #3), those will + * need to be mapped to colors that are within the destination gamut, + * while the already in-gamut colors remain unchanged. + * + * Non-colorimetric transforms can take many forms. There are no hard + * rules and it's left to the implementation to define. + * Two common intents are described below. + * + * Stretched-Gamut Enhancement Intent (Source < Destination): + * When the destination gamut is much larger than the source gamut (#1), the + * source primaries may be redefined to reflect the full extent of the + * destination space, or to reflect an intermediate gamut. + * Skin-tone preservation would likely be applied. An example might be sRGB + * input displayed on a DCI-P3 capable device, with skin-tone preservation. + * + * Within-Gamut Enhancement Intent (Source >= Destination): + * When the device (destination) gamut is not larger than the source gamut + * (#2 or #3), but the appearance of a larger gamut is desired, techniques + * such as saturation boost may be applied to the source colors. Skin-tone + * preservation may be applied. There is no unique method for within-gamut + * enhancement; it would be defined within a flexible color mode. + * + */ +enum class ColorMode : int32_t { + /** + * DEFAULT is the "native" gamut of the display. + * White Point: Vendor/OEM defined + * Panel Gamma: Vendor/OEM defined (typically 2.2) + * Rendering Intent: Vendor/OEM defined (typically 'enhanced') + */ + NATIVE = 0, + /** + * STANDARD_BT601_625 corresponds with display + * settings that implement the ITU-R Recommendation BT.601 + * or Rec 601. Using 625 line version + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_625 = 1, + /** + * Primaries: + * x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation + * for RGB conversion. + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_625_UNADJUSTED = 2, + /** + * Primaries: + * x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_525 = 3, + /** + * Primaries: + * x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation + * for RGB conversion (as in SMPTE 240M). + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_525_UNADJUSTED = 4, + /** + * REC709 corresponds with display settings that implement + * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television. + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized + * (with [0 to 1] range) value of R, G, or B. + * + * if Vnonlinear < 0.081 + * Vlinear = Vnonlinear / 4.5 + * else + * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45) + * + * HDTV REC709 Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.5 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099 + */ + STANDARD_BT709 = 5, + /** + * DCI_P3 corresponds with display settings that implement + * SMPTE EG 432-1 and SMPTE RP 431-2 + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.265 0.690 + * blue 0.150 0.060 + * red 0.680 0.320 + * white (D65) 0.3127 0.3290 + * + * Gamma: 2.6 + */ + DCI_P3 = 6, + /** + * SRGB corresponds with display settings that implement + * the sRGB color space. Uses the same primaries as ITU-R Recommendation + * BT.709 + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * PC/Internet (sRGB) Inverse Gamma Correction (IGC): + * + * if Vnonlinear ≤ 0.03928 + * Vlinear = Vnonlinear / 12.92 + * else + * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4 + * + * PC/Internet (sRGB) Gamma Correction (GC): + * + * if Vlinear ≤ 0.0031308 + * Vnonlinear = 12.92 * Vlinear + * else + * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 + */ + SRGB = 7, + /** + * ADOBE_RGB corresponds with the RGB color space developed + * by Adobe Systems, Inc. in 1998. + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.210 0.710 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Gamma: 2.2 + */ + ADOBE_RGB = 8, + /** + * DISPLAY_P3 is a color space that uses the DCI_P3 primaries, + * the D65 white point and the SRGB transfer functions. + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.265 0.690 + * blue 0.150 0.060 + * red 0.680 0.320 + * white (D65) 0.3127 0.3290 + * + * PC/Internet (sRGB) Gamma Correction (GC): + * + * if Vlinear ≤ 0.0030186 + * Vnonlinear = 12.92 * Vlinear + * else + * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 + * + * Note: In most cases sRGB transfer function will be fine. + */ + DISPLAY_P3 = 9, +}; + +/** + * Color transforms that may be applied by hardware composer to the whole + * display. + */ +enum class ColorTransform : int32_t { + /** + * Applies no transform to the output color + */ + IDENTITY = 0, + /** + * Applies an arbitrary transform defined by a 4x4 affine matrix + */ + ARBITRARY_MATRIX = 1, + /** + * Applies a transform that inverts the value or luminance of the color, but + * does not modify hue or saturation + */ + VALUE_INVERSE = 2, + /** + * Applies a transform that maps all colors to shades of gray + */ + GRAYSCALE = 3, + /** + * Applies a transform which corrects for protanopic color blindness + */ + CORRECT_PROTANOPIA = 4, + /** + * Applies a transform which corrects for deuteranopic color blindness + */ + CORRECT_DEUTERANOPIA = 5, + /** + * Applies a transform which corrects for tritanopic color blindness + */ + CORRECT_TRITANOPIA = 6, +}; + +/** + * Supported HDR formats. Must be kept in sync with equivalents in Display.java. + */ +enum class Hdr : int32_t { + /** + * Device supports Dolby Vision HDR + */ + DOLBY_VISION = 1, + /** + * Device supports HDR10 + */ + HDR10 = 2, + /** + * Device supports hybrid log-gamma HDR + */ + HLG = 3, +}; + +// +// type declarations for package +// + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::PixelFormat o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, + const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, + const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::PixelFormat e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::PixelFormat e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(uint64_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::BufferUsage o); + +constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, + const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr uint64_t operator|(const uint64_t lhs, + const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, + const uint64_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, + const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr uint64_t operator&(const uint64_t lhs, + const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, + const uint64_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr uint64_t& operator|=(uint64_t& v, + const ::android::hardware::graphics::common::V1_0::BufferUsage e) { + v |= static_cast(e); + return v; +} +constexpr uint64_t& operator&=(uint64_t& v, + const ::android::hardware::graphics::common::V1_0::BufferUsage e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::Transform o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Transform lhs, + const ::android::hardware::graphics::common::V1_0::Transform rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::Transform rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Transform lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Transform lhs, + const ::android::hardware::graphics::common::V1_0::Transform rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::Transform rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Transform lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::Transform e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::Transform e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::Dataspace o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, + const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, + const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::Dataspace e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::Dataspace e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorMode o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, + const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, + const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::ColorMode e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::ColorMode e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorTransform o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, + const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, + const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::ColorTransform e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::ColorTransform e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_0::Hdr o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Hdr lhs, + const ::android::hardware::graphics::common::V1_0::Hdr rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::Hdr rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Hdr lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Hdr lhs, + const ::android::hardware::graphics::common::V1_0::Hdr rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_0::Hdr rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Hdr lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::Hdr e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_0::Hdr e) { + v &= static_cast(e); + return v; +} + +// +// type header definitions for package +// + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::PixelFormat>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::PixelFormat> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888)) { + os += (first ? "" : " | "); + os += "RGBA_8888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888)) { + os += (first ? "" : " | "); + os += "RGBX_8888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888)) { + os += (first ? "" : " | "); + os += "RGB_888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565)) { + os += (first ? "" : " | "); + os += "RGB_565"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888)) { + os += (first ? "" : " | "); + os += "BGRA_8888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP) == + static_cast( + ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP)) { + os += (first ? "" : " | "); + os += "YCBCR_422_SP"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP) == + static_cast( + ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP)) { + os += (first ? "" : " | "); + os += "YCRCB_420_SP"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I)) { + os += (first ? "" : " | "); + os += "YCBCR_422_I"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16)) { + os += (first ? "" : " | "); + os += "RGBA_FP16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW16)) { + os += (first ? "" : " | "); + os += "RAW16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::BLOB)) { + os += (first ? "" : " | "); + os += "BLOB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED) == + static_cast( + ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED)) { + os += (first ? "" : " | "); + os += "IMPLEMENTATION_DEFINED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888) == + static_cast( + ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888)) { + os += (first ? "" : " | "); + os += "YCBCR_420_888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE)) { + os += (first ? "" : " | "); + os += "RAW_OPAQUE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW10)) { + os += (first ? "" : " | "); + os += "RAW10"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW12)) { + os += (first ? "" : " | "); + os += "RAW12"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102) == + static_cast( + ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102)) { + os += (first ? "" : " | "); + os += "RGBA_1010102"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::Y8) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::Y8)) { + os += (first ? "" : " | "); + os += "Y8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::Y8; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::Y16) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::Y16)) { + os += (first ? "" : " | "); + os += "Y16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::Y16; + } + if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YV12) == + static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YV12)) { + os += (first ? "" : " | "); + os += "YV12"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YV12; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::PixelFormat o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888) { + return "RGBA_8888"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888) { + return "RGBX_8888"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888) { + return "RGB_888"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565) { + return "RGB_565"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888) { + return "BGRA_8888"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP) { + return "YCBCR_422_SP"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP) { + return "YCRCB_420_SP"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I) { + return "YCBCR_422_I"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16) { + return "RGBA_FP16"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16) { + return "RAW16"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB) { + return "BLOB"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED) { + return "IMPLEMENTATION_DEFINED"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888) { + return "YCBCR_420_888"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE) { + return "RAW_OPAQUE"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10) { + return "RAW10"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12) { + return "RAW12"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102) { + return "RGBA_1010102"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::Y8) { + return "Y8"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::Y16) { + return "Y16"; + } + if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YV12) { + return "YV12"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::BufferUsage>(uint64_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::BufferUsage> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK)) { + os += (first ? "" : " | "); + os += "CPU_READ_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER)) { + os += (first ? "" : " | "); + os += "CPU_READ_NEVER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY)) { + os += (first ? "" : " | "); + os += "CPU_READ_RARELY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN)) { + os += (first ? "" : " | "); + os += "CPU_READ_OFTEN"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_NEVER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_RARELY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_OFTEN"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE)) { + os += (first ? "" : " | "); + os += "GPU_TEXTURE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET)) { + os += (first ? "" : " | "); + os += "GPU_RENDER_TARGET"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY)) { + os += (first ? "" : " | "); + os += "COMPOSER_OVERLAY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET)) { + os += (first ? "" : " | "); + os += "COMPOSER_CLIENT_TARGET"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED) == + static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED)) { + os += (first ? "" : " | "); + os += "PROTECTED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR)) { + os += (first ? "" : " | "); + os += "COMPOSER_CURSOR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER)) { + os += (first ? "" : " | "); + os += "VIDEO_ENCODER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT)) { + os += (first ? "" : " | "); + os += "CAMERA_OUTPUT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT)) { + os += (first ? "" : " | "); + os += "CAMERA_INPUT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT)) { + os += (first ? "" : " | "); + os += "RENDERSCRIPT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER)) { + os += (first ? "" : " | "); + os += "VIDEO_DECODER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA)) { + os += (first ? "" : " | "); + os += "SENSOR_DIRECT_DATA"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER)) { + os += (first ? "" : " | "); + os += "GPU_DATA_BUFFER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK)) { + os += (first ? "" : " | "); + os += "VENDOR_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI) == + static_cast( + ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI)) { + os += (first ? "" : " | "); + os += "VENDOR_MASK_HI"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::BufferUsage o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK) { + return "CPU_READ_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER) { + return "CPU_READ_NEVER"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY) { + return "CPU_READ_RARELY"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN) { + return "CPU_READ_OFTEN"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK) { + return "CPU_WRITE_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER) { + return "CPU_WRITE_NEVER"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY) { + return "CPU_WRITE_RARELY"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN) { + return "CPU_WRITE_OFTEN"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE) { + return "GPU_TEXTURE"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET) { + return "GPU_RENDER_TARGET"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY) { + return "COMPOSER_OVERLAY"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET) { + return "COMPOSER_CLIENT_TARGET"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED) { + return "PROTECTED"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR) { + return "COMPOSER_CURSOR"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) { + return "VIDEO_ENCODER"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT) { + return "CAMERA_OUTPUT"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT) { + return "CAMERA_INPUT"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT) { + return "RENDERSCRIPT"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER) { + return "VIDEO_DECODER"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA) { + return "SENSOR_DIRECT_DATA"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER) { + return "GPU_DATA_BUFFER"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK) { + return "VENDOR_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI) { + return "VENDOR_MASK_HI"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::Transform>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Transform> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::Transform::FLIP_H) == + static_cast(::android::hardware::graphics::common::V1_0::Transform::FLIP_H)) { + os += (first ? "" : " | "); + os += "FLIP_H"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Transform::FLIP_H; + } + if ((o & ::android::hardware::graphics::common::V1_0::Transform::FLIP_V) == + static_cast(::android::hardware::graphics::common::V1_0::Transform::FLIP_V)) { + os += (first ? "" : " | "); + os += "FLIP_V"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Transform::FLIP_V; + } + if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_90) == + static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_90)) { + os += (first ? "" : " | "); + os += "ROT_90"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_90; + } + if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_180) == + static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_180)) { + os += (first ? "" : " | "); + os += "ROT_180"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_180; + } + if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_270) == + static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_270)) { + os += (first ? "" : " | "); + os += "ROT_270"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_270; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::Transform o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::Transform::FLIP_H) { + return "FLIP_H"; + } + if (o == ::android::hardware::graphics::common::V1_0::Transform::FLIP_V) { + return "FLIP_V"; + } + if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_90) { + return "ROT_90"; + } + if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_180) { + return "ROT_180"; + } + if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_270) { + return "ROT_270"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::Dataspace>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Dataspace> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN)) { + os += (first ? "" : " | "); + os += "UNKNOWN"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY)) { + os += (first ? "" : " | "); + os += "ARBITRARY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT)) { + os += (first ? "" : " | "); + os += "STANDARD_SHIFT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK)) { + os += (first ? "" : " | "); + os += "STANDARD_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED)) { + os += (first ? "" : " | "); + os += "STANDARD_UNSPECIFIED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709)) { + os += (first ? "" : " | "); + os += "STANDARD_BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020)) { + os += (first ? "" : " | "); + os += "STANDARD_BT2020"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace:: + STANDARD_BT2020_CONSTANT_LUMINANCE) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace:: + STANDARD_BT2020_CONSTANT_LUMINANCE)) { + os += (first ? "" : " | "); + os += "STANDARD_BT2020_CONSTANT_LUMINANCE"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M)) { + os += (first ? "" : " | "); + os += "STANDARD_BT470M"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM)) { + os += (first ? "" : " | "); + os += "STANDARD_FILM"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3)) { + os += (first ? "" : " | "); + os += "STANDARD_DCI_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB)) { + os += (first ? "" : " | "); + os += "STANDARD_ADOBE_RGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT)) { + os += (first ? "" : " | "); + os += "TRANSFER_SHIFT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK)) { + os += (first ? "" : " | "); + os += "TRANSFER_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED)) { + os += (first ? "" : " | "); + os += "TRANSFER_UNSPECIFIED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR)) { + os += (first ? "" : " | "); + os += "TRANSFER_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB)) { + os += (first ? "" : " | "); + os += "TRANSFER_SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M)) { + os += (first ? "" : " | "); + os += "TRANSFER_SMPTE_170M"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2)) { + os += (first ? "" : " | "); + os += "TRANSFER_GAMMA2_2"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6)) { + os += (first ? "" : " | "); + os += "TRANSFER_GAMMA2_6"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8)) { + os += (first ? "" : " | "); + os += "TRANSFER_GAMMA2_8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084)) { + os += (first ? "" : " | "); + os += "TRANSFER_ST2084"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG)) { + os += (first ? "" : " | "); + os += "TRANSFER_HLG"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT)) { + os += (first ? "" : " | "); + os += "RANGE_SHIFT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK)) { + os += (first ? "" : " | "); + os += "RANGE_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED)) { + os += (first ? "" : " | "); + os += "RANGE_UNSPECIFIED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL)) { + os += (first ? "" : " | "); + os += "RANGE_FULL"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED)) { + os += (first ? "" : " | "); + os += "RANGE_LIMITED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED)) { + os += (first ? "" : " | "); + os += "RANGE_EXTENDED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR)) { + os += (first ? "" : " | "); + os += "SRGB_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR)) { + os += (first ? "" : " | "); + os += "V0_SRGB_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR)) { + os += (first ? "" : " | "); + os += "V0_SCRGB_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SRGB) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SRGB)) { + os += (first ? "" : " | "); + os += "SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB)) { + os += (first ? "" : " | "); + os += "V0_SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB)) { + os += (first ? "" : " | "); + os += "V0_SCRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::JFIF) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::JFIF)) { + os += (first ? "" : " | "); + os += "JFIF"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::JFIF; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF)) { + os += (first ? "" : " | "); + os += "V0_JFIF"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT601_625)) { + os += (first ? "" : " | "); + os += "BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625)) { + os += (first ? "" : " | "); + os += "V0_BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT601_525)) { + os += (first ? "" : " | "); + os += "BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525)) { + os += (first ? "" : " | "); + os += "V0_BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT709) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT709)) { + os += (first ? "" : " | "); + os += "BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT709; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709)) { + os += (first ? "" : " | "); + os += "V0_BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR)) { + os += (first ? "" : " | "); + os += "DCI_P3_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3)) { + os += (first ? "" : " | "); + os += "DCI_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR)) { + os += (first ? "" : " | "); + os += "DISPLAY_P3_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3)) { + os += (first ? "" : " | "); + os += "DISPLAY_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB)) { + os += (first ? "" : " | "); + os += "ADOBE_RGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR)) { + os += (first ? "" : " | "); + os += "BT2020_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020)) { + os += (first ? "" : " | "); + os += "BT2020"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ)) { + os += (first ? "" : " | "); + os += "BT2020_PQ"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DEPTH)) { + os += (first ? "" : " | "); + os += "DEPTH"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH; + } + if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR) == + static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SENSOR)) { + os += (first ? "" : " | "); + os += "SENSOR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::Dataspace o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN) { + return "UNKNOWN"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY) { + return "ARBITRARY"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT) { + return "STANDARD_SHIFT"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK) { + return "STANDARD_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED) { + return "STANDARD_UNSPECIFIED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709) { + return "STANDARD_BT709"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625) { + return "STANDARD_BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED) { + return "STANDARD_BT601_625_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525) { + return "STANDARD_BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED) { + return "STANDARD_BT601_525_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020) { + return "STANDARD_BT2020"; + } + if (o == + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE) { + return "STANDARD_BT2020_CONSTANT_LUMINANCE"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M) { + return "STANDARD_BT470M"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM) { + return "STANDARD_FILM"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3) { + return "STANDARD_DCI_P3"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB) { + return "STANDARD_ADOBE_RGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT) { + return "TRANSFER_SHIFT"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK) { + return "TRANSFER_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED) { + return "TRANSFER_UNSPECIFIED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR) { + return "TRANSFER_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB) { + return "TRANSFER_SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M) { + return "TRANSFER_SMPTE_170M"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2) { + return "TRANSFER_GAMMA2_2"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6) { + return "TRANSFER_GAMMA2_6"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8) { + return "TRANSFER_GAMMA2_8"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084) { + return "TRANSFER_ST2084"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG) { + return "TRANSFER_HLG"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT) { + return "RANGE_SHIFT"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK) { + return "RANGE_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED) { + return "RANGE_UNSPECIFIED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL) { + return "RANGE_FULL"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED) { + return "RANGE_LIMITED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED) { + return "RANGE_EXTENDED"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR) { + return "SRGB_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR) { + return "V0_SRGB_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR) { + return "V0_SCRGB_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SRGB) { + return "SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB) { + return "V0_SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB) { + return "V0_SCRGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::JFIF) { + return "JFIF"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF) { + return "V0_JFIF"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625) { + return "BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625) { + return "V0_BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525) { + return "BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525) { + return "V0_BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT709) { + return "BT709"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709) { + return "V0_BT709"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR) { + return "DCI_P3_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3) { + return "DCI_P3"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR) { + return "DISPLAY_P3_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3) { + return "DISPLAY_P3"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB) { + return "ADOBE_RGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR) { + return "BT2020_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020) { + return "BT2020"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ) { + return "BT2020_PQ"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH) { + return "DEPTH"; + } + if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR) { + return "SENSOR"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::ColorMode>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::ColorMode> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE) == + static_cast(::android::hardware::graphics::common::V1_0::ColorMode::NATIVE)) { + os += (first ? "" : " | "); + os += "NATIVE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709)) { + os += (first ? "" : " | "); + os += "STANDARD_BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3) == + static_cast(::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3)) { + os += (first ? "" : " | "); + os += "DCI_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::SRGB) == + static_cast(::android::hardware::graphics::common::V1_0::ColorMode::SRGB)) { + os += (first ? "" : " | "); + os += "SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB) == + static_cast(::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB)) { + os += (first ? "" : " | "); + os += "ADOBE_RGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3) == + static_cast(::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3)) { + os += (first ? "" : " | "); + os += "DISPLAY_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorMode o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE) { + return "NATIVE"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625) { + return "STANDARD_BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED) { + return "STANDARD_BT601_625_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525) { + return "STANDARD_BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED) { + return "STANDARD_BT601_525_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709) { + return "STANDARD_BT709"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3) { + return "DCI_P3"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::SRGB) { + return "SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB) { + return "ADOBE_RGB"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3) { + return "DISPLAY_P3"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::ColorTransform>( + int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::ColorTransform> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY) == + static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY)) { + os += (first ? "" : " | "); + os += "IDENTITY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX)) { + os += (first ? "" : " | "); + os += "ARBITRARY_MATRIX"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE)) { + os += (first ? "" : " | "); + os += "VALUE_INVERSE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE)) { + os += (first ? "" : " | "); + os += "GRAYSCALE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA)) { + os += (first ? "" : " | "); + os += "CORRECT_PROTANOPIA"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA)) { + os += (first ? "" : " | "); + os += "CORRECT_DEUTERANOPIA"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA; + } + if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA) == + static_cast( + ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA)) { + os += (first ? "" : " | "); + os += "CORRECT_TRITANOPIA"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorTransform o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY) { + return "IDENTITY"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX) { + return "ARBITRARY_MATRIX"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE) { + return "VALUE_INVERSE"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE) { + return "GRAYSCALE"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA) { + return "CORRECT_PROTANOPIA"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA) { + return "CORRECT_DEUTERANOPIA"; + } + if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA) { + return "CORRECT_TRITANOPIA"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_0::Hdr>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Hdr> flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION) == + static_cast(::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION)) { + os += (first ? "" : " | "); + os += "DOLBY_VISION"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION; + } + if ((o & ::android::hardware::graphics::common::V1_0::Hdr::HDR10) == + static_cast(::android::hardware::graphics::common::V1_0::Hdr::HDR10)) { + os += (first ? "" : " | "); + os += "HDR10"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Hdr::HDR10; + } + if ((o & ::android::hardware::graphics::common::V1_0::Hdr::HLG) == + static_cast(::android::hardware::graphics::common::V1_0::Hdr::HLG)) { + os += (first ? "" : " | "); + os += "HLG"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_0::Hdr::HLG; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_0::Hdr o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION) { + return "DOLBY_VISION"; + } + if (o == ::android::hardware::graphics::common::V1_0::Hdr::HDR10) { + return "HDR10"; + } + if (o == ::android::hardware::graphics::common::V1_0::Hdr::HLG) { + return "HLG"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +} // namespace V1_0 +} // namespace common +} // namespace graphics +} // namespace hardware +} // namespace android + +// +// global type declarations for package +// + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::PixelFormat, 20> + hidl_enum_values<::android::hardware::graphics::common::V1_0::PixelFormat> = { + ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888, + ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888, + ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888, + ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565, + ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888, + ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP, + ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP, + ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I, + ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16, + ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16, + ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB, + ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED, + ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888, + ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE, + ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10, + ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12, + ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102, + ::android::hardware::graphics::common::V1_0::PixelFormat::Y8, + ::android::hardware::graphics::common::V1_0::PixelFormat::Y16, + ::android::hardware::graphics::common::V1_0::PixelFormat::YV12, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::BufferUsage, 23> + hidl_enum_values<::android::hardware::graphics::common::V1_0::BufferUsage> = { + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY, + ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN, + ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE, + ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET, + ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY, + ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET, + ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED, + ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR, + ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER, + ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT, + ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT, + ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT, + ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER, + ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA, + ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER, + ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK, + ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::Transform, 5> + hidl_enum_values<::android::hardware::graphics::common::V1_0::Transform> = { + ::android::hardware::graphics::common::V1_0::Transform::FLIP_H, + ::android::hardware::graphics::common::V1_0::Transform::FLIP_V, + ::android::hardware::graphics::common::V1_0::Transform::ROT_90, + ::android::hardware::graphics::common::V1_0::Transform::ROT_180, + ::android::hardware::graphics::common::V1_0::Transform::ROT_270, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::Dataspace, 57> + hidl_enum_values<::android::hardware::graphics::common::V1_0::Dataspace> = { + ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN, + ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3, + ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084, + ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG, + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT, + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK, + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED, + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL, + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED, + ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED, + ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::SRGB, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB, + ::android::hardware::graphics::common::V1_0::Dataspace::JFIF, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF, + ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625, + ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525, + ::android::hardware::graphics::common::V1_0::Dataspace::BT709, + ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709, + ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3, + ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3, + ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB, + ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR, + ::android::hardware::graphics::common::V1_0::Dataspace::BT2020, + ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ, + ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH, + ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::ColorMode, 10> + hidl_enum_values<::android::hardware::graphics::common::V1_0::ColorMode> = { + ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE, + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625, + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED, + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525, + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED, + ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709, + ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3, + ::android::hardware::graphics::common::V1_0::ColorMode::SRGB, + ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB, + ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::ColorTransform, 7> + hidl_enum_values<::android::hardware::graphics::common::V1_0::ColorTransform> = { + ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY, + ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX, + ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE, + ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE, + ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA, + ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA, + ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_0::Hdr, 3> + hidl_enum_values<::android::hardware::graphics::common::V1_0::Hdr> = { + ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION, + ::android::hardware::graphics::common::V1_0::Hdr::HDR10, + ::android::hardware::graphics::common::V1_0::Hdr::HLG, +}; +} // namespace details +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H + +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_TYPES_H +#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_TYPES_H + +#include +#include +#include +#include + +namespace android { +namespace hardware { +namespace graphics { +namespace common { +namespace V1_1 { + +// Forward declaration for forward reference support: +enum class PixelFormat : int32_t; +enum class BufferUsage : uint64_t; +enum class Dataspace : int32_t; +enum class ColorMode : int32_t; +enum class RenderIntent : int32_t; + +/** + * Pixel formats for graphics buffers. + */ +enum class PixelFormat : int32_t { + /** + * 32-bit format that has 8-bit R, G, B, and A components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGBA_8888 = 1 /* 0x1 */, + /** + * 32-bit format that has 8-bit R, G, B, and unused components, in that + * order, from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGBX_8888 = 2 /* 0x2 */, + /** + * 24-bit format that has 8-bit R, G, and B components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGB_888 = 3 /* 0x3 */, + /** + * 16-bit packed format that has 5-bit R, 6-bit G, and 5-bit B components, + * in that order, from the most-sigfinicant bits to the least-significant + * bits. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGB_565 = 4 /* 0x4 */, + /** + * 32-bit format that has 8-bit B, G, R, and A components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + BGRA_8888 = 5 /* 0x5 */, + /** + * Legacy formats deprecated in favor of YCBCR_420_888. + */ + YCBCR_422_SP = 16 /* 0x10 */, + YCRCB_420_SP = 17 /* 0x11 */, + YCBCR_422_I = 20 /* 0x14 */, + /** + * 64-bit format that has 16-bit R, G, B, and A components, in that order, + * from the lowest memory address to the highest memory address. + * + * The component values are signed floats, whose interpretation is defined + * by the dataspace. + */ + RGBA_FP16 = 22 /* 0x16 */, + /** + * RAW16 is a single-channel, 16-bit, little endian format, typically + * representing raw Bayer-pattern images from an image sensor, with minimal + * processing. + * + * The exact pixel layout of the data in the buffer is sensor-dependent, and + * needs to be queried from the camera device. + * + * Generally, not all 16 bits are used; more common values are 10 or 12 + * bits. If not all bits are used, the lower-order bits are filled first. + * All parameters to interpret the raw data (black and white points, + * color space, etc) must be queried from the camera device. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * - strides are specified in pixels, not in bytes + * + * size = stride * height * 2 + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW16 is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data, layout is as + * | defined above. + * Dataspace::DEPTH | Unprocessed implementation-dependent raw + * | depth measurements, opaque with 16 bit + * | samples. + * Other | Unsupported + */ + RAW16 = 32 /* 0x20 */, + /** + * BLOB is used to carry task-specific data which does not have a standard + * image structure. The details of the format are left to the two + * endpoints. + * + * A typical use case is for transporting JPEG-compressed images from the + * Camera HAL to the framework or to applications. + * + * Buffers of this format must have a height of 1, and width equal to their + * size in bytes. + * + * The mapping of the dataspace to buffer contents for BLOB is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::JFIF | An encoded JPEG image + * Dataspace::DEPTH | An android_depth_points buffer + * Dataspace::SENSOR | Sensor event data. + * Other | Unsupported + */ + BLOB = 33 /* 0x21 */, + /** + * A format indicating that the choice of format is entirely up to the + * allocator. + * + * The allocator should examine the usage bits passed in when allocating a + * buffer with this format, and it should derive the pixel format from + * those usage flags. This format must never be used with any of the + * BufferUsage::CPU_* usage flags. + * + * Even when the internally chosen format has an alpha component, the + * clients must assume the alpha vlaue to be 1.0. + * + * The interpretation of the component values is defined by the dataspace. + */ + IMPLEMENTATION_DEFINED = 34 /* 0x22 */, + /** + * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 + * buffer layout, while still describing the general format in a + * layout-independent manner. While called YCbCr, it can be used to + * describe formats with either chromatic ordering, as well as + * whole planar or semiplanar layouts. + * + * This format must be accepted by the allocator when BufferUsage::CPU_* + * are set. + * + * Buffers with this format must be locked with IMapper::lockYCbCr. + * Locking with IMapper::lock must return an error. + * + * The interpretation of the component values is defined by the dataspace. + */ + YCBCR_420_888 = 35 /* 0x23 */, + /** + * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an + * image sensor. The actual structure of buffers of this format is + * implementation-dependent. + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW_OPAQUE is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data. + * Other | Unsupported + */ + RAW_OPAQUE = 36 /* 0x24 */, + /** + * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, + * unprocessed format, usually representing raw Bayer-pattern images coming from + * an image sensor. + * + * In an image buffer with this format, starting from the first pixel of each + * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one + * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte + * contains the 2 least significant bits of the 4 pixels, the exact layout data + * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth + * bit of the ith pixel): + * + * bit 7 bit 0 + * =====|=====|=====|=====|=====|=====|=====|=====| + * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| + * =============================================== + * + * This format assumes + * - a width multiple of 4 pixels + * - an even height + * - a vertical stride equal to the height + * - strides are specified in bytes, not in pixels + * + * size = stride * height + * + * When stride is equal to width * (10 / 8), there will be no padding bytes at + * the end of each row, the entire image data is densely packed. When stride is + * larger than width * (10 / 8), padding bytes will be present at the end of each + * row (including the last row). + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW10 is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data. + * Other | Unsupported + */ + RAW10 = 37 /* 0x25 */, + /** + * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, + * unprocessed format, usually representing raw Bayer-pattern images coming from + * an image sensor. + * + * In an image buffer with this format, starting from the first pixel of each + * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first + * and second byte contains the top 8 bits of first and second pixel. The third + * byte contains the 4 least significant bits of the two pixels, the exact layout + * data for each two consecutive pixels is illustrated below (Pi[j] stands for + * the jth bit of the ith pixel): + * + * bit 7 bit 0 + * ======|======|======|======|======|======|======|======| + * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| + * |------|------|------|------|------|------|------|------| + * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| + * |------|------|------|------|------|------|------|------| + * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| + * ======================================================= + * + * This format assumes: + * - a width multiple of 4 pixels + * - an even height + * - a vertical stride equal to the height + * - strides are specified in bytes, not in pixels + * + * size = stride * height + * + * When stride is equal to width * (12 / 8), there will be no padding bytes at + * the end of each row, the entire image data is densely packed. When stride is + * larger than width * (12 / 8), padding bytes will be present at the end of + * each row (including the last row). + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::RENDERSCRIPT + * + * The mapping of the dataspace to buffer contents for RAW12 is as + * follows: + * + * Dataspace value | Buffer contents + * -------------------------------+----------------------------------------- + * Dataspace::ARBITRARY | Raw image sensor data. + * Other | Unsupported + */ + RAW12 = 38 /* 0x26 */, + /** + * 0x27 to 0x2A are reserved for flexible formats + * + * + * 32-bit packed format that has 2-bit A, 10-bit B, G, and R components, + * in that order, from the most-sigfinicant bits to the least-significant + * bits. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + RGBA_1010102 = 43 /* 0x2B */, + /** + * 0x100 - 0x1FF + * + * This range is reserved for vendor extensions. Formats in this range + * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not + * have an alpha component. + * + * + * Y8 is a YUV planar format comprised of a WxH Y plane, with each pixel + * being represented by 8 bits. It is equivalent to just the Y plane from + * YV12. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * + * size = stride * height + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + Y8 = 538982489 /* 0x20203859 */, + /** + * Y16 is a YUV planar format comprised of a WxH Y plane, with each pixel + * being represented by 16 bits. It is just like Y8, but has double the + * bits per pixel (little endian). + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * - strides are specified in pixels, not in bytes + * + * size = stride * height * 2 + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. When the dataspace is + * Dataspace::DEPTH, each pixel is a distance value measured by a depth + * camera, plus an associated confidence value. + */ + Y16 = 540422489 /* 0x20363159 */, + /** + * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed + * by (W/2) x (H/2) Cr and Cb planes. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * + * y_size = stride * height + * c_stride = ALIGN(stride/2, 16) + * c_size = c_stride * height/2 + * size = y_size + c_size * 2 + * cr_offset = y_size + * cb_offset = y_size + c_size + * + * This range is reserved for vendor extensions. Formats in this range + * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not + * have an alpha component. + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::CAMERA_* + * - BufferUsage::CPU_* + * - BufferUsage::GPU_TEXTURE + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + YV12 = 842094169 /* 0x32315659 */, + /** + * 16-bit format that has a single 16-bit depth component. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + DEPTH_16 = 48 /* 0x30 */, + /** + * 32-bit format that has a single 24-bit depth component and, optionally, + * 8 bits that are unused. + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + */ + DEPTH_24 = 49 /* 0x31 */, + /** + * 32-bit format that has a 24-bit depth component and an 8-bit stencil + * component packed into 32-bits. + * + * The depth component values are unsigned normalized to the range [0, 1], + * whose interpretation is defined by the dataspace. The stencil values are + * unsigned integers, whose interpretation is defined by the dataspace. + */ + DEPTH_24_STENCIL_8 = 50 /* 0x32 */, + /** + * 32-bit format that has a single 32-bit depth component. + * + * The component values are signed floats, whose interpretation is defined + * by the dataspace. + */ + DEPTH_32F = 51 /* 0x33 */, + /** + * Two-component format that has a 32-bit depth component, an 8-bit stencil + * component, and optionally 24-bits unused. + * + * The depth component values are signed floats, whose interpretation is + * defined by the dataspace. The stencil bits are unsigned integers, whose + * interpretation is defined by the dataspace. + */ + DEPTH_32F_STENCIL_8 = 52 /* 0x34 */, + /** + * 8-bit format that has a single 8-bit stencil component. + * + * The component values are unsigned integers, whose interpretation is + * defined by the dataspace. + */ + STENCIL_8 = 53 /* 0x35 */, + /** + * P010 is a 4:2:0 YCbCr semiplanar format comprised of a WxH Y plane + * followed immediately by a Wx(H/2) CbCr plane. Each sample is + * represented by a 16-bit little-endian value, with the lower 6 bits set + * to zero. + * + * This format assumes + * - an even height + * - a vertical stride equal to the height + * + * stride_in_bytes = stride * 2 + * y_size = stride_in_bytes * height + * cbcr_size = stride_in_bytes * (height / 2) + * cb_offset = y_size + * cr_offset = cb_offset + 2 + * + * This format must be accepted by the allocator when used with the + * following usage flags: + * + * - BufferUsage::VIDEO_* + * - BufferUsage::CPU_* + * - BufferUsage::GPU_TEXTURE + * + * The component values are unsigned normalized to the range [0, 1], whose + * interpretation is defined by the dataspace. + * + * This format is appropriate for 10bit video content. + * + * Buffers with this format must be locked with IMapper::lockYCbCr + * or with IMapper::lock. + */ + YCBCR_P010 = 54 /* 0x36 */, +}; + +/** + * Buffer usage definitions. + */ +enum class BufferUsage : uint64_t { + /** + * bit 0-3 is an enum + */ + CPU_READ_MASK = 15ull /* 0xfULL */, + /** + * buffer is never read by CPU + */ + CPU_READ_NEVER = 0ull, + /** + * buffer is rarely read by CPU + */ + CPU_READ_RARELY = 2ull, + /** + * buffer is often read by CPU + */ + CPU_READ_OFTEN = 3ull, + /** + * bit 4-7 is an enum + */ + CPU_WRITE_MASK = 240ull /* (0xfULL << 4) */, + /** + * buffer is never written by CPU + */ + CPU_WRITE_NEVER = 0ull /* (0 << 4) */, + /** + * buffer is rarely written by CPU + */ + CPU_WRITE_RARELY = 32ull /* (2 << 4) */, + /** + * buffer is often written by CPU + */ + CPU_WRITE_OFTEN = 48ull /* (3 << 4) */, + /** + * buffer is used as a GPU texture + */ + GPU_TEXTURE = 256ull /* (1ULL << 8) */, + /** + * buffer is used as a GPU render target + */ + GPU_RENDER_TARGET = 512ull /* (1ULL << 9) */, + /** + * bit 10 must be zero + * + * + * buffer is used as a composer HAL overlay layer + */ + COMPOSER_OVERLAY = 2048ull /* (1ULL << 11) */, + /** + * buffer is used as a composer HAL client target + */ + COMPOSER_CLIENT_TARGET = 4096ull /* (1ULL << 12) */, + /** + * bit 13 must be zero + * + * + * Buffer is allocated with hardware-level protection against copying the + * contents (or information derived from the contents) into unprotected + * memory. + */ + PROTECTED = 16384ull /* (1ULL << 14) */, + /** + * buffer is used as a hwcomposer HAL cursor layer + */ + COMPOSER_CURSOR = 32768ull /* (1ULL << 15) */, + /** + * buffer is used as a video encoder input + */ + VIDEO_ENCODER = 65536ull /* (1ULL << 16) */, + /** + * buffer is used as a camera HAL output + */ + CAMERA_OUTPUT = 131072ull /* (1ULL << 17) */, + /** + * buffer is used as a camera HAL input + */ + CAMERA_INPUT = 262144ull /* (1ULL << 18) */, + /** + * bit 19 must be zero + * + * + * buffer is used as a renderscript allocation + */ + RENDERSCRIPT = 1048576ull /* (1ULL << 20) */, + /** + * bit 21 must be zero + * + * + * buffer is used as a video decoder output + */ + VIDEO_DECODER = 4194304ull /* (1ULL << 22) */, + /** + * buffer is used as a sensor direct report output + */ + SENSOR_DIRECT_DATA = 8388608ull /* (1ULL << 23) */, + /** + * buffer is used as as an OpenGL shader storage or uniform + * buffer object + */ + GPU_DATA_BUFFER = 16777216ull /* (1ULL << 24) */, + /** + * bits 25-27 must be zero and are reserved for future versions + * + * + * bits 28-31 are reserved for vendor extensions + */ + VENDOR_MASK = 4026531840ull /* (0xfULL << 28) */, + /** + * bits 32-47 must be zero and are reserved for future versions + * + * + * bits 48-63 are reserved for vendor extensions + */ + VENDOR_MASK_HI = 18446462598732840960ull /* (0xffffULL << 48) */, + /** + * buffer is used as a cube map texture + */ + GPU_CUBE_MAP = 33554432ull /* (1ULL << 25) */, + /** + * buffer contains a complete mipmap hierarchy + */ + GPU_MIPMAP_COMPLETE = 67108864ull /* (1ULL << 26) */, +}; + +enum class Dataspace : int32_t { + /** + * Default-assumption data space, when not explicitly specified. + * + * It is safest to assume the buffer is an image with sRGB primaries and + * encoding ranges, but the consumer and/or the producer of the data may + * simply be using defaults. No automatic gamma transform should be + * expected, except for a possible display gamma transform when drawn to a + * screen. + */ + UNKNOWN = 0 /* 0x0 */, + /** + * Arbitrary dataspace with manually defined characteristics. Definition + * for colorspaces or other meaning must be communicated separately. + * + * This is used when specifying primaries, transfer characteristics, + * etc. separately. + * + * A typical use case is in video encoding parameters (e.g. for H.264), + * where a colorspace can have separately defined primaries, transfer + * characteristics, etc. + */ + ARBITRARY = 1 /* 0x1 */, + /** + * Color-description aspects + * + * The following aspects define various characteristics of the color + * specification. These represent bitfields, so that a data space value + * can specify each of them independently. + */ + STANDARD_SHIFT = 16, + /** + * Standard aspect + * + * Defines the chromaticity coordinates of the source primaries in terms of + * the CIE 1931 definition of x and y specified in ISO 11664-1. + */ + STANDARD_MASK = 4128768 /* (63 << STANDARD_SHIFT) */, + /** + * Chromacity coordinates are unknown or are determined by the application. + * Implementations shall use the following suggested standards: + * + * All YCbCr formats: BT709 if size is 720p or larger (since most video + * content is letterboxed this corresponds to width is + * 1280 or greater, or height is 720 or greater). + * BT601_625 if size is smaller than 720p or is JPEG. + * All RGB formats: BT709. + * + * For all other formats standard is undefined, and implementations should use + * an appropriate standard for the data represented. + */ + STANDARD_UNSPECIFIED = 0 /* (0 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT709 = 65536 /* (1 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + */ + STANDARD_BT601_625 = 131072 /* (2 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT601_625_UNADJUSTED = 196608 /* (3 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + */ + STANDARD_BT601_525 = 262144 /* (4 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation + * for RGB conversion (as in SMPTE 240M). + */ + STANDARD_BT601_525_UNADJUSTED = 327680 /* (5 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.170 0.797 + * blue 0.131 0.046 + * red 0.708 0.292 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT2020 = 393216 /* (6 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.170 0.797 + * blue 0.131 0.046 + * red 0.708 0.292 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation + * for RGB conversion using the linear domain. + */ + STANDARD_BT2020_CONSTANT_LUMINANCE = 458752 /* (7 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.21 0.71 + * blue 0.14 0.08 + * red 0.67 0.33 + * white (C) 0.310 0.316 + * + * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation + * for RGB conversion. + */ + STANDARD_BT470M = 524288 /* (8 << STANDARD_SHIFT) */, + /** + * Primaries: x y + * green 0.243 0.692 + * blue 0.145 0.049 + * red 0.681 0.319 + * white (C) 0.310 0.316 + * + * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation + * for RGB conversion. + */ + STANDARD_FILM = 589824 /* (9 << STANDARD_SHIFT) */, + /** + * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3) + * Primaries: x y + * green 0.265 0.690 + * blue 0.150 0.060 + * red 0.680 0.320 + * white (D65) 0.3127 0.3290 + */ + STANDARD_DCI_P3 = 655360 /* (10 << STANDARD_SHIFT) */, + /** + * Adobe RGB + * Primaries: x y + * green 0.210 0.710 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + */ + STANDARD_ADOBE_RGB = 720896 /* (11 << STANDARD_SHIFT) */, + TRANSFER_SHIFT = 22, + /** + * Transfer aspect + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + * + * For digital signals, E corresponds to the recorded value. Normally, the + * transfer function is applied in RGB space to each of the R, G and B + * components independently. This may result in color shift that can be + * minized by applying the transfer function in Lab space only for the L + * component. Implementation may apply the transfer function in RGB space + * for all pixel formats if desired. + */ + TRANSFER_MASK = 130023424 /* (31 << TRANSFER_SHIFT) */, + /** + * Transfer characteristics are unknown or are determined by the + * application. + * + * Implementations should use the following transfer functions: + * + * For YCbCr formats: use TRANSFER_SMPTE_170M + * For RGB formats: use TRANSFER_SRGB + * + * For all other formats transfer function is undefined, and implementations + * should use an appropriate standard for the data represented. + */ + TRANSFER_UNSPECIFIED = 0 /* (0 << TRANSFER_SHIFT) */, + /** + * Transfer characteristic curve: + * E = L + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_LINEAR = 4194304 /* (1 << TRANSFER_SHIFT) */, + /** + * Transfer characteristic curve: + * + * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1 + * = 12.92 * L for 0 <= L < 0.0031308 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_SRGB = 8388608 /* (2 << TRANSFER_SHIFT) */, + /** + * BT.601 525, BT.601 625, BT.709, BT.2020 + * + * Transfer characteristic curve: + * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1 + * = 4.500 * L for 0 <= L < 0.018 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_SMPTE_170M = 12582912 /* (3 << TRANSFER_SHIFT) */, + /** + * Assumed display gamma 2.2. + * + * Transfer characteristic curve: + * E = L ^ (1/2.2) + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_GAMMA2_2 = 16777216 /* (4 << TRANSFER_SHIFT) */, + /** + * display gamma 2.6. + * + * Transfer characteristic curve: + * E = L ^ (1/2.6) + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_GAMMA2_6 = 20971520 /* (5 << TRANSFER_SHIFT) */, + /** + * display gamma 2.8. + * + * Transfer characteristic curve: + * E = L ^ (1/2.8) + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + */ + TRANSFER_GAMMA2_8 = 25165824 /* (6 << TRANSFER_SHIFT) */, + /** + * SMPTE ST 2084 (Dolby Perceptual Quantizer) + * + * Transfer characteristic curve: + * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m + * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375 + * c2 = 32 * 2413 / 4096 = 18.8515625 + * c3 = 32 * 2392 / 4096 = 18.6875 + * m = 128 * 2523 / 4096 = 78.84375 + * n = 0.25 * 2610 / 4096 = 0.1593017578125 + * L - luminance of image 0 <= L <= 1 for HDR colorimetry. + * L = 1 corresponds to 10000 cd/m2 + * E - corresponding electrical signal + */ + TRANSFER_ST2084 = 29360128 /* (7 << TRANSFER_SHIFT) */, + /** + * ARIB STD-B67 Hybrid Log Gamma + * + * Transfer characteristic curve: + * E = r * L^0.5 for 0 <= L <= 1 + * = a * ln(L - b) + c for 1 < L + * a = 0.17883277 + * b = 0.28466892 + * c = 0.55991073 + * r = 0.5 + * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds + * to reference white level of 100 cd/m2 + * E - corresponding electrical signal + */ + TRANSFER_HLG = 33554432 /* (8 << TRANSFER_SHIFT) */, + RANGE_SHIFT = 27, + /** + * Range aspect + * + * Defines the range of values corresponding to the unit range of 0-1. + * This is defined for YCbCr only, but can be expanded to RGB space. + */ + RANGE_MASK = 939524096 /* (7 << RANGE_SHIFT) */, + /** + * Range is unknown or are determined by the application. Implementations + * shall use the following suggested ranges: + * + * All YCbCr formats: limited range. + * All RGB or RGBA formats (including RAW and Bayer): full range. + * All Y formats: full range + * + * For all other formats range is undefined, and implementations should use + * an appropriate range for the data represented. + */ + RANGE_UNSPECIFIED = 0 /* (0 << RANGE_SHIFT) */, + /** + * Full range uses all values for Y, Cb and Cr from + * 0 to 2^b-1, where b is the bit depth of the color format. + */ + RANGE_FULL = 134217728 /* (1 << RANGE_SHIFT) */, + /** + * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and + * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of + * the color format. + * + * E.g. For 8-bit-depth formats: + * Luma (Y) samples should range from 16 to 235, inclusive + * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive + * + * For 10-bit-depth formats: + * Luma (Y) samples should range from 64 to 940, inclusive + * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive + */ + RANGE_LIMITED = 268435456 /* (2 << RANGE_SHIFT) */, + /** + * Extended range is used for scRGB. Intended for use with + * floating point pixel formats. [0.0 - 1.0] is the standard + * sRGB space. Values outside the range 0.0 - 1.0 can encode + * color outside the sRGB gamut. + * Used to blend / merge multiple dataspaces on a single display. + */ + RANGE_EXTENDED = 402653184 /* (3 << RANGE_SHIFT) */, + /** + * Legacy dataspaces + * + * + * sRGB linear encoding: + * + * The red, green, and blue components are stored in sRGB space, but + * are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are encoded using the full range ([0,255] for 8-bit) for all + * components. + */ + SRGB_LINEAR = 512 /* 0x200 */, + V0_SRGB_LINEAR = 138477568 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * scRGB linear encoding: + * + * The red, green, and blue components are stored in extended sRGB space, + * but are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are floating point. + * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. + * Values beyond the range [0.0 - 1.0] would correspond to other colors + * spaces and/or HDR content. + */ + V0_SCRGB_LINEAR = 406913024 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_EXTENDED) */, + /** + * sRGB gamma encoding: + * + * The red, green and blue components are stored in sRGB space, and + * converted to linear space when read, using the SRGB transfer function + * for each of the R, G and B components. When written, the inverse + * transformation is performed. + * + * The alpha component, if present, is always stored in linear space and + * is left unmodified when read or written. + * + * Use full range and BT.709 standard. + */ + SRGB = 513 /* 0x201 */, + V0_SRGB = 142671872 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_FULL) */, + /** + * scRGB: + * + * The red, green, and blue components are stored in extended sRGB space, + * but are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are floating point. + * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. + * Values beyond the range [0.0 - 1.0] would correspond to other colors + * spaces and/or HDR content. + */ + V0_SCRGB = 411107328 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_EXTENDED) */, + /** + * YCbCr Colorspaces + * ----------------- + * + * Primaries are given using (x,y) coordinates in the CIE 1931 definition + * of x and y specified by ISO 11664-1. + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + * + * + * JPEG File Interchange Format (JFIF) + * + * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 + * + * Use full range, BT.601 transfer and BT.601_625 standard. + */ + JFIF = 257 /* 0x101 */, + V0_JFIF = 146931712 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, + /** + * ITU-R Recommendation 601 (BT.601) - 625-line + * + * Standard-definition television, 625 Lines (PAL) + * + * Use limited range, BT.601 transfer and BT.601_625 standard. + */ + BT601_625 = 258 /* 0x102 */, + V0_BT601_625 = 281149440 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * ITU-R Recommendation 601 (BT.601) - 525-line + * + * Standard-definition television, 525 Lines (NTSC) + * + * Use limited range, BT.601 transfer and BT.601_525 standard. + */ + BT601_525 = 259 /* 0x103 */, + V0_BT601_525 = 281280512 /* ((STANDARD_BT601_525 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * ITU-R Recommendation 709 (BT.709) + * + * High-definition television + * + * Use limited range, BT.709 transfer and BT.709 standard. + */ + BT709 = 260 /* 0x104 */, + V0_BT709 = 281083904 /* ((STANDARD_BT709 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * SMPTE EG 432-1 and SMPTE RP 431-2. + * + * Digital Cinema DCI-P3 + * + * Use full range, linear transfer and D65 DCI-P3 standard + */ + DCI_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * SMPTE EG 432-1 and SMPTE RP 431-2. + * + * Digital Cinema DCI-P3 + * + * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard + * Note: Application is responsible for gamma encoding the data as + * a 2.6 gamma encoding is not supported in HW. + */ + DCI_P3 = 155844608 /* ((STANDARD_DCI_P3 | TRANSFER_GAMMA2_6) | RANGE_FULL) */, + /** + * Display P3 + * + * Display P3 uses same primaries and white-point as DCI-P3 + * linear transfer function makes this the same as DCI_P3_LINEAR. + */ + DISPLAY_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * Display P3 + * + * Use same primaries and white-point as DCI-P3 + * but sRGB transfer function. + */ + DISPLAY_P3 = 143261696 /* ((STANDARD_DCI_P3 | TRANSFER_SRGB) | RANGE_FULL) */, + /** + * Adobe RGB + * + * Use full range, gamma 2.2 transfer and Adobe RGB primaries + * Note: Application is responsible for gamma encoding the data as + * a 2.2 gamma encoding is not supported in HW. + */ + ADOBE_RGB = 151715840 /* ((STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2) | RANGE_FULL) */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, linear transfer and BT2020 standard + */ + BT2020_LINEAR = 138805248 /* ((STANDARD_BT2020 | TRANSFER_LINEAR) | RANGE_FULL) */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, BT.709 transfer and BT2020 standard + */ + BT2020 = 147193856 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard + */ + BT2020_PQ = 163971072 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_FULL) */, + /** + * Data spaces for non-color formats + * + * + * The buffer contains depth ranging measurements from a depth camera. + * This value is valid with formats: + * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement + * and an associated confidence value. The 3 MSBs of the sample make + * up the confidence value, and the low 13 LSBs of the sample make up + * the depth measurement. + * For the confidence section, 0 means 100% confidence, 1 means 0% + * confidence. The mapping to a linear float confidence value between + * 0.f and 1.f can be obtained with + * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; + * The depth measurement can be extracted simply with + * uint16_t range = (depthSample & 0x1FFF); + * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as + * a variable-length float (x,y,z, confidence) coordinate point list. + * The point cloud will be represented with the android_depth_points + * structure. + */ + DEPTH = 4096 /* 0x1000 */, + /** + * The buffer contains sensor events from sensor direct report. + * This value is valid with formats: + * HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms + * a lock free queue. Format of sensor event structure is specified + * in Sensors HAL. + */ + SENSOR = 4097 /* 0x1001 */, + /** + * ITU-R Recommendation 2020 (BT.2020) + * + * Ultra High-definition television + * + * Use limited range, BT.709 transfer and BT2020 standard + */ + BT2020_ITU = 281411584 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, + /** + * ITU-R Recommendation 2100 (BT.2100) + * + * High dynamic range television + * + * Use limited/full range, PQ/HLG transfer, and BT2020 standard + * limited range is the preferred / normative definition for BT.2100 + */ + BT2020_ITU_PQ = 298188800 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_LIMITED) */, + BT2020_ITU_HLG = 302383104 /* ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_LIMITED) */, + BT2020_HLG = 168165376 /* ((STANDARD_BT2020 | TRANSFER_HLG) | RANGE_FULL) */, +}; + +enum class ColorMode : int32_t { + /** + * DEFAULT is the "native" gamut of the display. + * White Point: Vendor/OEM defined + * Panel Gamma: Vendor/OEM defined (typically 2.2) + * Rendering Intent: Vendor/OEM defined (typically 'enhanced') + */ + NATIVE = 0, + /** + * STANDARD_BT601_625 corresponds with display + * settings that implement the ITU-R Recommendation BT.601 + * or Rec 601. Using 625 line version + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_625 = 1, + /** + * Primaries: + * x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation + * for RGB conversion. + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_625_UNADJUSTED = 2, + /** + * Primaries: + * x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation + * for RGB conversion from the one purely determined by the primaries + * to minimize the color shift into RGB space that uses BT.709 + * primaries. + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_525 = 3, + /** + * Primaries: + * x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + * + * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation + * for RGB conversion (as in SMPTE 240M). + * + * Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.500 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 + */ + STANDARD_BT601_525_UNADJUSTED = 4, + /** + * REC709 corresponds with display settings that implement + * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television. + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized + * (with [0 to 1] range) value of R, G, or B. + * + * if Vnonlinear < 0.081 + * Vlinear = Vnonlinear / 4.5 + * else + * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45) + * + * HDTV REC709 Gamma Correction (GC): + * + * if Vlinear < 0.018 + * Vnonlinear = 4.5 * Vlinear + * else + * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099 + */ + STANDARD_BT709 = 5, + /** + * DCI_P3 corresponds with display settings that implement + * SMPTE EG 432-1 and SMPTE RP 431-2 + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.265 0.690 + * blue 0.150 0.060 + * red 0.680 0.320 + * white (D65) 0.3127 0.3290 + * + * Gamma: 2.6 + */ + DCI_P3 = 6, + /** + * SRGB corresponds with display settings that implement + * the sRGB color space. Uses the same primaries as ITU-R Recommendation + * BT.709 + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * PC/Internet (sRGB) Inverse Gamma Correction (IGC): + * + * if Vnonlinear ≤ 0.03928 + * Vlinear = Vnonlinear / 12.92 + * else + * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4 + * + * PC/Internet (sRGB) Gamma Correction (GC): + * + * if Vlinear ≤ 0.0031308 + * Vnonlinear = 12.92 * Vlinear + * else + * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 + */ + SRGB = 7, + /** + * ADOBE_RGB corresponds with the RGB color space developed + * by Adobe Systems, Inc. in 1998. + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.210 0.710 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + * + * Gamma: 2.2 + */ + ADOBE_RGB = 8, + /** + * DISPLAY_P3 is a color space that uses the DCI_P3 primaries, + * the D65 white point and the SRGB transfer functions. + * Rendering Intent: Colorimetric + * Primaries: + * x y + * green 0.265 0.690 + * blue 0.150 0.060 + * red 0.680 0.320 + * white (D65) 0.3127 0.3290 + * + * PC/Internet (sRGB) Gamma Correction (GC): + * + * if Vlinear ≤ 0.0030186 + * Vnonlinear = 12.92 * Vlinear + * else + * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 + * + * Note: In most cases sRGB transfer function will be fine. + */ + DISPLAY_P3 = 9, + /** + * BT2020 corresponds with display settings that implement the ITU-R + * Recommendation BT.2020 / Rec. 2020 for UHDTV. + * + * Primaries: + * x y + * green 0.170 0.797 + * blue 0.131 0.046 + * red 0.708 0.292 + * white (D65) 0.3127 0.3290 + * + * Inverse Gamma Correction (IGC): V represents normalized (with [0 to 1] + * range) value of R, G, or B. + * + * if Vnonlinear < b * 4.5 + * Vlinear = Vnonlinear / 4.5 + * else + * Vlinear = ((Vnonlinear + (a - 1)) / a) ^ (1/0.45) + * + * Gamma Correction (GC): + * + * if Vlinear < b + * Vnonlinear = 4.5 * Vlinear + * else + * Vnonlinear = a * Vlinear ^ 0.45 - (a - 1) + * + * where + * + * a = 1.09929682680944, b = 0.018053968510807 + * + * For practical purposes, these a/b values can be used instead + * + * a = 1.099, b = 0.018 for 10-bit display systems + * a = 1.0993, b = 0.0181 for 12-bit display systems + */ + BT2020 = 10, + /** + * BT2100_PQ and BT2100_HLG correspond with display settings that + * implement the ITU-R Recommendation BT.2100 / Rec. 2100 for HDR TV. + * + * Primaries: + * x y + * green 0.170 0.797 + * blue 0.131 0.046 + * red 0.708 0.292 + * white (D65) 0.3127 0.3290 + * + * For BT2100_PQ, the transfer function is Perceptual Quantizer (PQ). For + * BT2100_HLG, the transfer function is Hybrid Log-Gamma (HLG). + */ + BT2100_PQ = 11, + BT2100_HLG = 12, +}; + +/** + * RenderIntent defines the mapping from color mode colors to display colors. + * + * A render intent must not change how it maps colors when the color mode + * changes. That is to say that when a render intent maps color C to color C', + * the fact that color C can have different pixel values in different color + * modes should not affect the mapping. + * + * RenderIntent overrides the render intents defined for individual color + * modes. It is ignored when the color mode is ColorMode::NATIVE, because + * ColorMode::NATIVE colors are already display colors. + */ +enum class RenderIntent : int32_t { + /** + * Colors in the display gamut are unchanged. Colors out of the display + * gamut are hard-clipped. + * + * This implies that the display must have been calibrated unless + * ColorMode::NATIVE is the only supported color mode. + */ + COLORIMETRIC = 0, + /** + * Enhance colors that are in the display gamut. Colors out of the display + * gamut are hard-clipped. + * + * The enhancement typically picks the biggest standard color space (e.g. + * DCI-P3) that is narrower than the display gamut and stretches it to the + * display gamut. The stretching is recommended to preserve skin tones. + */ + ENHANCE = 1, + /** + * Tone map high-dynamic-range colors to the display's dynamic range. The + * dynamic range of the colors are communicated separately. After tone + * mapping, the mapping to the display gamut is as defined in + * COLORIMETRIC. + */ + TONE_MAP_COLORIMETRIC = 2, + /** + * Tone map high-dynamic-range colors to the display's dynamic range. The + * dynamic range of the colors are communicated separately. After tone + * mapping, the mapping to the display gamut is as defined in ENHANCE. + * + * The tone mapping step and the enhancing step must match + * TONE_MAP_COLORIMETRIC and ENHANCE respectively when they are also + * supported. + */ + TONE_MAP_ENHANCE = 3, +}; + +// +// type declarations for package +// + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_1::PixelFormat o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, + const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, + const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::PixelFormat rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::PixelFormat lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::PixelFormat e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::PixelFormat e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(uint64_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_1::BufferUsage o); + +constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, + const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr uint64_t operator|(const uint64_t lhs, + const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, + const uint64_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, + const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr uint64_t operator&(const uint64_t lhs, + const ::android::hardware::graphics::common::V1_1::BufferUsage rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_1::BufferUsage lhs, + const uint64_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr uint64_t& operator|=(uint64_t& v, + const ::android::hardware::graphics::common::V1_1::BufferUsage e) { + v |= static_cast(e); + return v; +} +constexpr uint64_t& operator&=(uint64_t& v, + const ::android::hardware::graphics::common::V1_1::BufferUsage e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_1::Dataspace o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, + const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, + const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::Dataspace rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::Dataspace lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::Dataspace e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::Dataspace e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_1::ColorMode o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, + const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, + const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::ColorMode rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::ColorMode lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::ColorMode e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::ColorMode e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::common::V1_1::RenderIntent o); + +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, + const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, + const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::common::V1_1::RenderIntent rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_1::RenderIntent lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::RenderIntent e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::common::V1_1::RenderIntent e) { + v &= static_cast(e); + return v; +} + +// +// type header definitions for package +// + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_1::PixelFormat>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::PixelFormat> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888)) { + os += (first ? "" : " | "); + os += "RGBA_8888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888)) { + os += (first ? "" : " | "); + os += "RGBX_8888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888)) { + os += (first ? "" : " | "); + os += "RGB_888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565)) { + os += (first ? "" : " | "); + os += "RGB_565"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888)) { + os += (first ? "" : " | "); + os += "BGRA_8888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP)) { + os += (first ? "" : " | "); + os += "YCBCR_422_SP"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP)) { + os += (first ? "" : " | "); + os += "YCRCB_420_SP"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I)) { + os += (first ? "" : " | "); + os += "YCBCR_422_I"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16)) { + os += (first ? "" : " | "); + os += "RGBA_FP16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW16)) { + os += (first ? "" : " | "); + os += "RAW16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::BLOB)) { + os += (first ? "" : " | "); + os += "BLOB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED)) { + os += (first ? "" : " | "); + os += "IMPLEMENTATION_DEFINED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888)) { + os += (first ? "" : " | "); + os += "YCBCR_420_888"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE)) { + os += (first ? "" : " | "); + os += "RAW_OPAQUE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW10)) { + os += (first ? "" : " | "); + os += "RAW10"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::RAW12)) { + os += (first ? "" : " | "); + os += "RAW12"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102)) { + os += (first ? "" : " | "); + os += "RGBA_1010102"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::Y8) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::Y8)) { + os += (first ? "" : " | "); + os += "Y8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::Y8; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::Y16) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::Y16)) { + os += (first ? "" : " | "); + os += "Y16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::Y16; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YV12) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::YV12)) { + os += (first ? "" : " | "); + os += "YV12"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YV12; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16)) { + os += (first ? "" : " | "); + os += "DEPTH_16"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24)) { + os += (first ? "" : " | "); + os += "DEPTH_24"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8)) { + os += (first ? "" : " | "); + os += "DEPTH_24_STENCIL_8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F)) { + os += (first ? "" : " | "); + os += "DEPTH_32F"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8) == + static_cast( + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8)) { + os += (first ? "" : " | "); + os += "DEPTH_32F_STENCIL_8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8)) { + os += (first ? "" : " | "); + os += "STENCIL_8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8; + } + if ((o & ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010) == + static_cast(::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010)) { + os += (first ? "" : " | "); + os += "YCBCR_P010"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_1::PixelFormat o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888) { + return "RGBA_8888"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888) { + return "RGBX_8888"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888) { + return "RGB_888"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565) { + return "RGB_565"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888) { + return "BGRA_8888"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP) { + return "YCBCR_422_SP"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP) { + return "YCRCB_420_SP"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I) { + return "YCBCR_422_I"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16) { + return "RGBA_FP16"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16) { + return "RAW16"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB) { + return "BLOB"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED) { + return "IMPLEMENTATION_DEFINED"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888) { + return "YCBCR_420_888"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE) { + return "RAW_OPAQUE"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10) { + return "RAW10"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12) { + return "RAW12"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102) { + return "RGBA_1010102"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::Y8) { + return "Y8"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::Y16) { + return "Y16"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YV12) { + return "YV12"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16) { + return "DEPTH_16"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24) { + return "DEPTH_24"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8) { + return "DEPTH_24_STENCIL_8"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F) { + return "DEPTH_32F"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8) { + return "DEPTH_32F_STENCIL_8"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8) { + return "STENCIL_8"; + } + if (o == ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010) { + return "YCBCR_P010"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_1::BufferUsage>(uint64_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::BufferUsage> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK)) { + os += (first ? "" : " | "); + os += "CPU_READ_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER)) { + os += (first ? "" : " | "); + os += "CPU_READ_NEVER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY)) { + os += (first ? "" : " | "); + os += "CPU_READ_RARELY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN)) { + os += (first ? "" : " | "); + os += "CPU_READ_OFTEN"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_NEVER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_RARELY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN)) { + os += (first ? "" : " | "); + os += "CPU_WRITE_OFTEN"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE)) { + os += (first ? "" : " | "); + os += "GPU_TEXTURE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET)) { + os += (first ? "" : " | "); + os += "GPU_RENDER_TARGET"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY)) { + os += (first ? "" : " | "); + os += "COMPOSER_OVERLAY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET)) { + os += (first ? "" : " | "); + os += "COMPOSER_CLIENT_TARGET"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED) == + static_cast(::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED)) { + os += (first ? "" : " | "); + os += "PROTECTED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR)) { + os += (first ? "" : " | "); + os += "COMPOSER_CURSOR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER)) { + os += (first ? "" : " | "); + os += "VIDEO_ENCODER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT)) { + os += (first ? "" : " | "); + os += "CAMERA_OUTPUT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT)) { + os += (first ? "" : " | "); + os += "CAMERA_INPUT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT)) { + os += (first ? "" : " | "); + os += "RENDERSCRIPT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER)) { + os += (first ? "" : " | "); + os += "VIDEO_DECODER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA)) { + os += (first ? "" : " | "); + os += "SENSOR_DIRECT_DATA"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER)) { + os += (first ? "" : " | "); + os += "GPU_DATA_BUFFER"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK)) { + os += (first ? "" : " | "); + os += "VENDOR_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI)) { + os += (first ? "" : " | "); + os += "VENDOR_MASK_HI"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP)) { + os += (first ? "" : " | "); + os += "GPU_CUBE_MAP"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP; + } + if ((o & ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE) == + static_cast( + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE)) { + os += (first ? "" : " | "); + os += "GPU_MIPMAP_COMPLETE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_1::BufferUsage o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK) { + return "CPU_READ_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER) { + return "CPU_READ_NEVER"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY) { + return "CPU_READ_RARELY"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN) { + return "CPU_READ_OFTEN"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK) { + return "CPU_WRITE_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER) { + return "CPU_WRITE_NEVER"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY) { + return "CPU_WRITE_RARELY"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN) { + return "CPU_WRITE_OFTEN"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE) { + return "GPU_TEXTURE"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET) { + return "GPU_RENDER_TARGET"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY) { + return "COMPOSER_OVERLAY"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET) { + return "COMPOSER_CLIENT_TARGET"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED) { + return "PROTECTED"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR) { + return "COMPOSER_CURSOR"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER) { + return "VIDEO_ENCODER"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT) { + return "CAMERA_OUTPUT"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT) { + return "CAMERA_INPUT"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT) { + return "RENDERSCRIPT"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER) { + return "VIDEO_DECODER"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA) { + return "SENSOR_DIRECT_DATA"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER) { + return "GPU_DATA_BUFFER"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK) { + return "VENDOR_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI) { + return "VENDOR_MASK_HI"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP) { + return "GPU_CUBE_MAP"; + } + if (o == ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE) { + return "GPU_MIPMAP_COMPLETE"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_1::Dataspace>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::Dataspace> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN)) { + os += (first ? "" : " | "); + os += "UNKNOWN"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY)) { + os += (first ? "" : " | "); + os += "ARBITRARY"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT)) { + os += (first ? "" : " | "); + os += "STANDARD_SHIFT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK)) { + os += (first ? "" : " | "); + os += "STANDARD_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED)) { + os += (first ? "" : " | "); + os += "STANDARD_UNSPECIFIED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709)) { + os += (first ? "" : " | "); + os += "STANDARD_BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020)) { + os += (first ? "" : " | "); + os += "STANDARD_BT2020"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace:: + STANDARD_BT2020_CONSTANT_LUMINANCE) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace:: + STANDARD_BT2020_CONSTANT_LUMINANCE)) { + os += (first ? "" : " | "); + os += "STANDARD_BT2020_CONSTANT_LUMINANCE"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M)) { + os += (first ? "" : " | "); + os += "STANDARD_BT470M"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM)) { + os += (first ? "" : " | "); + os += "STANDARD_FILM"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3)) { + os += (first ? "" : " | "); + os += "STANDARD_DCI_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB)) { + os += (first ? "" : " | "); + os += "STANDARD_ADOBE_RGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT)) { + os += (first ? "" : " | "); + os += "TRANSFER_SHIFT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK)) { + os += (first ? "" : " | "); + os += "TRANSFER_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED)) { + os += (first ? "" : " | "); + os += "TRANSFER_UNSPECIFIED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR)) { + os += (first ? "" : " | "); + os += "TRANSFER_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB)) { + os += (first ? "" : " | "); + os += "TRANSFER_SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M)) { + os += (first ? "" : " | "); + os += "TRANSFER_SMPTE_170M"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2)) { + os += (first ? "" : " | "); + os += "TRANSFER_GAMMA2_2"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6)) { + os += (first ? "" : " | "); + os += "TRANSFER_GAMMA2_6"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8)) { + os += (first ? "" : " | "); + os += "TRANSFER_GAMMA2_8"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084)) { + os += (first ? "" : " | "); + os += "TRANSFER_ST2084"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG)) { + os += (first ? "" : " | "); + os += "TRANSFER_HLG"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT)) { + os += (first ? "" : " | "); + os += "RANGE_SHIFT"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK)) { + os += (first ? "" : " | "); + os += "RANGE_MASK"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED)) { + os += (first ? "" : " | "); + os += "RANGE_UNSPECIFIED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL)) { + os += (first ? "" : " | "); + os += "RANGE_FULL"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED)) { + os += (first ? "" : " | "); + os += "RANGE_LIMITED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED)) { + os += (first ? "" : " | "); + os += "RANGE_EXTENDED"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR)) { + os += (first ? "" : " | "); + os += "SRGB_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR)) { + os += (first ? "" : " | "); + os += "V0_SRGB_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR)) { + os += (first ? "" : " | "); + os += "V0_SCRGB_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::SRGB) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::SRGB)) { + os += (first ? "" : " | "); + os += "SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB)) { + os += (first ? "" : " | "); + os += "V0_SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB)) { + os += (first ? "" : " | "); + os += "V0_SCRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::JFIF) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::JFIF)) { + os += (first ? "" : " | "); + os += "JFIF"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::JFIF; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF)) { + os += (first ? "" : " | "); + os += "V0_JFIF"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT601_625)) { + os += (first ? "" : " | "); + os += "BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625)) { + os += (first ? "" : " | "); + os += "V0_BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT601_525)) { + os += (first ? "" : " | "); + os += "BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525)) { + os += (first ? "" : " | "); + os += "V0_BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT709) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT709)) { + os += (first ? "" : " | "); + os += "BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT709; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709)) { + os += (first ? "" : " | "); + os += "V0_BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR)) { + os += (first ? "" : " | "); + os += "DCI_P3_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3)) { + os += (first ? "" : " | "); + os += "DCI_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR)) { + os += (first ? "" : " | "); + os += "DISPLAY_P3_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3)) { + os += (first ? "" : " | "); + os += "DISPLAY_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB)) { + os += (first ? "" : " | "); + os += "ADOBE_RGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR)) { + os += (first ? "" : " | "); + os += "BT2020_LINEAR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020)) { + os += (first ? "" : " | "); + os += "BT2020"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ)) { + os += (first ? "" : " | "); + os += "BT2020_PQ"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::DEPTH)) { + os += (first ? "" : " | "); + os += "DEPTH"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::SENSOR)) { + os += (first ? "" : " | "); + os += "SENSOR"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU)) { + os += (first ? "" : " | "); + os += "BT2020_ITU"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ)) { + os += (first ? "" : " | "); + os += "BT2020_ITU_PQ"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG) == + static_cast( + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG)) { + os += (first ? "" : " | "); + os += "BT2020_ITU_HLG"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG; + } + if ((o & ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG) == + static_cast(::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG)) { + os += (first ? "" : " | "); + os += "BT2020_HLG"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_1::Dataspace o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN) { + return "UNKNOWN"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY) { + return "ARBITRARY"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT) { + return "STANDARD_SHIFT"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK) { + return "STANDARD_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED) { + return "STANDARD_UNSPECIFIED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709) { + return "STANDARD_BT709"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625) { + return "STANDARD_BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED) { + return "STANDARD_BT601_625_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525) { + return "STANDARD_BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED) { + return "STANDARD_BT601_525_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020) { + return "STANDARD_BT2020"; + } + if (o == + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE) { + return "STANDARD_BT2020_CONSTANT_LUMINANCE"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M) { + return "STANDARD_BT470M"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM) { + return "STANDARD_FILM"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3) { + return "STANDARD_DCI_P3"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB) { + return "STANDARD_ADOBE_RGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT) { + return "TRANSFER_SHIFT"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK) { + return "TRANSFER_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED) { + return "TRANSFER_UNSPECIFIED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR) { + return "TRANSFER_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB) { + return "TRANSFER_SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M) { + return "TRANSFER_SMPTE_170M"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2) { + return "TRANSFER_GAMMA2_2"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6) { + return "TRANSFER_GAMMA2_6"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8) { + return "TRANSFER_GAMMA2_8"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084) { + return "TRANSFER_ST2084"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG) { + return "TRANSFER_HLG"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT) { + return "RANGE_SHIFT"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK) { + return "RANGE_MASK"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED) { + return "RANGE_UNSPECIFIED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL) { + return "RANGE_FULL"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED) { + return "RANGE_LIMITED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED) { + return "RANGE_EXTENDED"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR) { + return "SRGB_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR) { + return "V0_SRGB_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR) { + return "V0_SCRGB_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::SRGB) { + return "SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB) { + return "V0_SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB) { + return "V0_SCRGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::JFIF) { + return "JFIF"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF) { + return "V0_JFIF"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625) { + return "BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625) { + return "V0_BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525) { + return "BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525) { + return "V0_BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT709) { + return "BT709"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709) { + return "V0_BT709"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR) { + return "DCI_P3_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3) { + return "DCI_P3"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR) { + return "DISPLAY_P3_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3) { + return "DISPLAY_P3"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB) { + return "ADOBE_RGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR) { + return "BT2020_LINEAR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020) { + return "BT2020"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ) { + return "BT2020_PQ"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH) { + return "DEPTH"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR) { + return "SENSOR"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU) { + return "BT2020_ITU"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ) { + return "BT2020_ITU_PQ"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG) { + return "BT2020_ITU_HLG"; + } + if (o == ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG) { + return "BT2020_HLG"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_1::ColorMode>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::ColorMode> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::NATIVE)) { + os += (first ? "" : " | "); + os += "NATIVE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625) == + static_cast( + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_625_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525) == + static_cast( + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED) == + static_cast( + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED)) { + os += (first ? "" : " | "); + os += "STANDARD_BT601_525_UNADJUSTED"; + first = false; + flipped |= + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709) == + static_cast( + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709)) { + os += (first ? "" : " | "); + os += "STANDARD_BT709"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3)) { + os += (first ? "" : " | "); + os += "DCI_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::SRGB) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::SRGB)) { + os += (first ? "" : " | "); + os += "SRGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::SRGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB)) { + os += (first ? "" : " | "); + os += "ADOBE_RGB"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3)) { + os += (first ? "" : " | "); + os += "DISPLAY_P3"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::BT2020) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::BT2020)) { + os += (first ? "" : " | "); + os += "BT2020"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::BT2020; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ)) { + os += (first ? "" : " | "); + os += "BT2100_PQ"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ; + } + if ((o & ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG) == + static_cast(::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG)) { + os += (first ? "" : " | "); + os += "BT2100_HLG"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_1::ColorMode o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE) { + return "NATIVE"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625) { + return "STANDARD_BT601_625"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED) { + return "STANDARD_BT601_625_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525) { + return "STANDARD_BT601_525"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED) { + return "STANDARD_BT601_525_UNADJUSTED"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709) { + return "STANDARD_BT709"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3) { + return "DCI_P3"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::SRGB) { + return "SRGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB) { + return "ADOBE_RGB"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3) { + return "DISPLAY_P3"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::BT2020) { + return "BT2020"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ) { + return "BT2100_PQ"; + } + if (o == ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG) { + return "BT2100_HLG"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::android::hardware::graphics::common::V1_1::RenderIntent>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_1::RenderIntent> + flipped = 0; + bool first = true; + if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC) == + static_cast( + ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC)) { + os += (first ? "" : " | "); + os += "COLORIMETRIC"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC; + } + if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE) == + static_cast(::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE)) { + os += (first ? "" : " | "); + os += "ENHANCE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE; + } + if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC) == + static_cast( + ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC)) { + os += (first ? "" : " | "); + os += "TONE_MAP_COLORIMETRIC"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC; + } + if ((o & ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE) == + static_cast( + ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE)) { + os += (first ? "" : " | "); + os += "TONE_MAP_ENHANCE"; + first = false; + flipped |= ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::common::V1_1::RenderIntent o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC) { + return "COLORIMETRIC"; + } + if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE) { + return "ENHANCE"; + } + if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC) { + return "TONE_MAP_COLORIMETRIC"; + } + if (o == ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE) { + return "TONE_MAP_ENHANCE"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +} // namespace V1_1 +} // namespace common +} // namespace graphics +} // namespace hardware +} // namespace android + +// +// global type declarations for package +// + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_1::PixelFormat, 27> + hidl_enum_values<::android::hardware::graphics::common::V1_1::PixelFormat> = { + ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_8888, + ::android::hardware::graphics::common::V1_1::PixelFormat::RGBX_8888, + ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_888, + ::android::hardware::graphics::common::V1_1::PixelFormat::RGB_565, + ::android::hardware::graphics::common::V1_1::PixelFormat::BGRA_8888, + ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_SP, + ::android::hardware::graphics::common::V1_1::PixelFormat::YCRCB_420_SP, + ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_422_I, + ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_FP16, + ::android::hardware::graphics::common::V1_1::PixelFormat::RAW16, + ::android::hardware::graphics::common::V1_1::PixelFormat::BLOB, + ::android::hardware::graphics::common::V1_1::PixelFormat::IMPLEMENTATION_DEFINED, + ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_420_888, + ::android::hardware::graphics::common::V1_1::PixelFormat::RAW_OPAQUE, + ::android::hardware::graphics::common::V1_1::PixelFormat::RAW10, + ::android::hardware::graphics::common::V1_1::PixelFormat::RAW12, + ::android::hardware::graphics::common::V1_1::PixelFormat::RGBA_1010102, + ::android::hardware::graphics::common::V1_1::PixelFormat::Y8, + ::android::hardware::graphics::common::V1_1::PixelFormat::Y16, + ::android::hardware::graphics::common::V1_1::PixelFormat::YV12, + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_16, + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24, + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_24_STENCIL_8, + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F, + ::android::hardware::graphics::common::V1_1::PixelFormat::DEPTH_32F_STENCIL_8, + ::android::hardware::graphics::common::V1_1::PixelFormat::STENCIL_8, + ::android::hardware::graphics::common::V1_1::PixelFormat::YCBCR_P010, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_1::BufferUsage, 25> + hidl_enum_values<::android::hardware::graphics::common::V1_1::BufferUsage> = { + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_MASK, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_NEVER, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_RARELY, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_READ_OFTEN, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_MASK, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_NEVER, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_RARELY, + ::android::hardware::graphics::common::V1_1::BufferUsage::CPU_WRITE_OFTEN, + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_TEXTURE, + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_RENDER_TARGET, + ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_OVERLAY, + ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CLIENT_TARGET, + ::android::hardware::graphics::common::V1_1::BufferUsage::PROTECTED, + ::android::hardware::graphics::common::V1_1::BufferUsage::COMPOSER_CURSOR, + ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_ENCODER, + ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_OUTPUT, + ::android::hardware::graphics::common::V1_1::BufferUsage::CAMERA_INPUT, + ::android::hardware::graphics::common::V1_1::BufferUsage::RENDERSCRIPT, + ::android::hardware::graphics::common::V1_1::BufferUsage::VIDEO_DECODER, + ::android::hardware::graphics::common::V1_1::BufferUsage::SENSOR_DIRECT_DATA, + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_DATA_BUFFER, + ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK, + ::android::hardware::graphics::common::V1_1::BufferUsage::VENDOR_MASK_HI, + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_CUBE_MAP, + ::android::hardware::graphics::common::V1_1::BufferUsage::GPU_MIPMAP_COMPLETE, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_1::Dataspace, 61> + hidl_enum_values<::android::hardware::graphics::common::V1_1::Dataspace> = { + ::android::hardware::graphics::common::V1_1::Dataspace::UNKNOWN, + ::android::hardware::graphics::common::V1_1::Dataspace::ARBITRARY, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_SHIFT, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_MASK, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_UNSPECIFIED, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT709, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_625_UNADJUSTED, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT601_525_UNADJUSTED, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_BT470M, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_FILM, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_DCI_P3, + ::android::hardware::graphics::common::V1_1::Dataspace::STANDARD_ADOBE_RGB, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SHIFT, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_MASK, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_UNSPECIFIED, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SRGB, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_SMPTE_170M, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_2, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_6, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_GAMMA2_8, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_ST2084, + ::android::hardware::graphics::common::V1_1::Dataspace::TRANSFER_HLG, + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_SHIFT, + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_MASK, + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_UNSPECIFIED, + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_FULL, + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_LIMITED, + ::android::hardware::graphics::common::V1_1::Dataspace::RANGE_EXTENDED, + ::android::hardware::graphics::common::V1_1::Dataspace::SRGB_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::SRGB, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_SRGB, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_SCRGB, + ::android::hardware::graphics::common::V1_1::Dataspace::JFIF, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_JFIF, + ::android::hardware::graphics::common::V1_1::Dataspace::BT601_625, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_625, + ::android::hardware::graphics::common::V1_1::Dataspace::BT601_525, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT601_525, + ::android::hardware::graphics::common::V1_1::Dataspace::BT709, + ::android::hardware::graphics::common::V1_1::Dataspace::V0_BT709, + ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::DCI_P3, + ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::DISPLAY_P3, + ::android::hardware::graphics::common::V1_1::Dataspace::ADOBE_RGB, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_LINEAR, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_PQ, + ::android::hardware::graphics::common::V1_1::Dataspace::DEPTH, + ::android::hardware::graphics::common::V1_1::Dataspace::SENSOR, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_PQ, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_ITU_HLG, + ::android::hardware::graphics::common::V1_1::Dataspace::BT2020_HLG, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_1::ColorMode, 13> + hidl_enum_values<::android::hardware::graphics::common::V1_1::ColorMode> = { + ::android::hardware::graphics::common::V1_1::ColorMode::NATIVE, + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625, + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_625_UNADJUSTED, + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525, + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT601_525_UNADJUSTED, + ::android::hardware::graphics::common::V1_1::ColorMode::STANDARD_BT709, + ::android::hardware::graphics::common::V1_1::ColorMode::DCI_P3, + ::android::hardware::graphics::common::V1_1::ColorMode::SRGB, + ::android::hardware::graphics::common::V1_1::ColorMode::ADOBE_RGB, + ::android::hardware::graphics::common::V1_1::ColorMode::DISPLAY_P3, + ::android::hardware::graphics::common::V1_1::ColorMode::BT2020, + ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_PQ, + ::android::hardware::graphics::common::V1_1::ColorMode::BT2100_HLG, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::common::V1_1::RenderIntent, 4> + hidl_enum_values<::android::hardware::graphics::common::V1_1::RenderIntent> = { + ::android::hardware::graphics::common::V1_1::RenderIntent::COLORIMETRIC, + ::android::hardware::graphics::common::V1_1::RenderIntent::ENHANCE, + ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_COLORIMETRIC, + ::android::hardware::graphics::common::V1_1::RenderIntent::TONE_MAP_ENHANCE, +}; +} // namespace details +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_1_TYPES_H diff --git a/tools/qtimapper-shim/ext/types/mapper.h b/tools/qtimapper-shim/ext/types/mapper.h new file mode 100644 index 0000000..ce12642 --- /dev/null +++ b/tools/qtimapper-shim/ext/types/mapper.h @@ -0,0 +1,250 @@ +#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H +#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H + +#include +#include +#include +#include + +namespace android { +namespace hardware { +namespace graphics { +namespace mapper { +namespace V2_0 { + +// Forward declaration for forward reference support: +enum class Error : int32_t; +struct YCbCrLayout; + +enum class Error : int32_t { + NONE = 0, + BAD_DESCRIPTOR = 1, + BAD_BUFFER = 2, + BAD_VALUE = 3, + NO_RESOURCES = 5, + UNSUPPORTED = 7, +}; + +/** + * A buffer descriptor is an implementation-defined opaque data returned by + * createDescriptor. It describes the properties of a buffer and is consumed + * by the allocator. + */ +typedef ::android::hardware::hidl_vec BufferDescriptor; + +/** + * Structure for describing YCbCr formats for consumption by applications. + * This is used with PixelFormat::YCBCR_*_888. + * + * Buffer chroma subsampling is defined in the format. + * e.g. PixelFormat::YCBCR_420_888 has subsampling 4:2:0. + * + * Buffers must have a 8 bit depth. + * + * y, cb, and cr point to the first byte of their respective planes. + * + * Stride describes the distance in bytes from the first value of one row of + * the image to the first value of the next row. It includes the width of the + * image plus padding. + * yStride is the stride of the luma plane. + * cStride is the stride of the chroma planes. + * + * chromaStep is the distance in bytes from one chroma pixel value to the + * next. This is 2 bytes for semiplanar (because chroma values are interleaved + * and each chroma value is one byte) and 1 for planar. + */ +struct YCbCrLayout final { + void* y; + void* cb; + void* cr; + uint32_t yStride; + uint32_t cStride; + uint32_t chromaStep; +}; + +// +// type declarations for package +// + +template +static inline std::string toString(int32_t o); +static inline std::string toString(::android::hardware::graphics::mapper::V2_0::Error o); + +constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, + const ::android::hardware::graphics::mapper::V2_0::Error rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|(const int32_t lhs, + const ::android::hardware::graphics::mapper::V2_0::Error rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, + const ::android::hardware::graphics::mapper::V2_0::Error rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&(const int32_t lhs, + const ::android::hardware::graphics::mapper::V2_0::Error rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, + const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=(int32_t& v, + const ::android::hardware::graphics::mapper::V2_0::Error e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=(int32_t& v, + const ::android::hardware::graphics::mapper::V2_0::Error e) { + v &= static_cast(e); + return v; +} + +static inline std::string toString( + const ::android::hardware::graphics::mapper::V2_0::YCbCrLayout& o); +// operator== and operator!= are not generated for YCbCrLayout + +// +// type header definitions for package +// + +template <> +inline std::string toString<::android::hardware::graphics::mapper::V2_0::Error>(int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield<::android::hardware::graphics::mapper::V2_0::Error> flipped = + 0; + bool first = true; + if ((o & ::android::hardware::graphics::mapper::V2_0::Error::NONE) == + static_cast(::android::hardware::graphics::mapper::V2_0::Error::NONE)) { + os += (first ? "" : " | "); + os += "NONE"; + first = false; + flipped |= ::android::hardware::graphics::mapper::V2_0::Error::NONE; + } + if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR) == + static_cast(::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR)) { + os += (first ? "" : " | "); + os += "BAD_DESCRIPTOR"; + first = false; + flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR; + } + if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER) == + static_cast(::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER)) { + os += (first ? "" : " | "); + os += "BAD_BUFFER"; + first = false; + flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER; + } + if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE) == + static_cast(::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE)) { + os += (first ? "" : " | "); + os += "BAD_VALUE"; + first = false; + flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE; + } + if ((o & ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES) == + static_cast(::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES)) { + os += (first ? "" : " | "); + os += "NO_RESOURCES"; + first = false; + flipped |= ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES; + } + if ((o & ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED) == + static_cast(::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED)) { + os += (first ? "" : " | "); + os += "UNSUPPORTED"; + first = false; + flipped |= ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString(::android::hardware::graphics::mapper::V2_0::Error o) { + using ::android::hardware::details::toHexString; + if (o == ::android::hardware::graphics::mapper::V2_0::Error::NONE) { + return "NONE"; + } + if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR) { + return "BAD_DESCRIPTOR"; + } + if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER) { + return "BAD_BUFFER"; + } + if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE) { + return "BAD_VALUE"; + } + if (o == ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES) { + return "NO_RESOURCES"; + } + if (o == ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED) { + return "UNSUPPORTED"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +static inline std::string toString( + const ::android::hardware::graphics::mapper::V2_0::YCbCrLayout& o) { + using ::android::hardware::toString; + std::string os; + os += "{"; + os += ".y = "; + os += ::android::hardware::toString(o.y); + os += ", .cb = "; + os += ::android::hardware::toString(o.cb); + os += ", .cr = "; + os += ::android::hardware::toString(o.cr); + os += ", .yStride = "; + os += ::android::hardware::toString(o.yStride); + os += ", .cStride = "; + os += ::android::hardware::toString(o.cStride); + os += ", .chromaStep = "; + os += ::android::hardware::toString(o.chromaStep); + os += "}"; + return os; +} + +// operator== and operator!= are not generated for YCbCrLayout + +} // namespace V2_0 +} // namespace mapper +} // namespace graphics +} // namespace hardware +} // namespace android + +// +// global type declarations for package +// + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::android::hardware::graphics::mapper::V2_0::Error, 6> + hidl_enum_values<::android::hardware::graphics::mapper::V2_0::Error> = { + ::android::hardware::graphics::mapper::V2_0::Error::NONE, + ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR, + ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER, + ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE, + ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES, + ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED, +}; +} // namespace details +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H diff --git a/tools/qtimapper-shim/ext/types/mapperextensions.h b/tools/qtimapper-shim/ext/types/mapperextensions.h new file mode 100644 index 0000000..79fddd1 --- /dev/null +++ b/tools/qtimapper-shim/ext/types/mapperextensions.h @@ -0,0 +1,707 @@ +#ifndef HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H +#define HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H + +#include +#include +#include +#include + +namespace vendor { +namespace qti { +namespace hardware { +namespace display { +namespace mapperextensions { +namespace V1_0 { + +// Forward declaration for forward reference support: +enum class Error : int32_t; +struct YCbCrLayout; +enum class PlaneComponent : uint32_t; +enum class Flags : int32_t; +struct PlaneLayout; + +enum class Error : int32_t { + NONE = 0, + BAD_BUFFER = 2, + NO_RESOURCES = 5, + UNSUPPORTED = 7, +}; + +struct YCbCrLayout final { + void* y; + void* cb; + void* cr; + uint32_t yStride; + uint32_t cStride; + uint32_t chromaStep; +}; + +/** + * Plane Component type definitions. + */ +enum class PlaneComponent : uint32_t { + PLANE_COMPONENT_Y = 1u /* (1 << 0) */, + PLANE_COMPONENT_Cb = 2u /* (1 << 1) */, + PLANE_COMPONENT_Cr = 4u /* (1 << 2) */, + PLANE_COMPONENT_R = 1024u /* (1 << 10) */, + PLANE_COMPONENT_G = 2048u /* (1 << 11) */, + PLANE_COMPONENT_B = 4096u /* (1 << 12) */, + PLANE_COMPONENT_A = 1048576u /* (1 << 20) */, + PLANE_COMPONENT_RAW = 1073741824u /* (1 << 30) */, + PLANE_COMPONENT_META = 2147483648u /* (1 << 31) */, +}; + +/** + * Flags to send with getFormatLayout for extra information for e.g. interlaced, + * otherwise send 0. + */ +enum class Flags : int32_t { + LAYOUT_INTERLACED_FLAG = 1 /* (1 << 0) */, +}; + +/** + * Structure for describing plane layout information for YUVA/RGBA/RAW formats + * YUV formats can be planar or semi-planar. + * + * This layout structure is used with any pixel format that can be + * represented by it, such as: + * - HAL_PIXEL_FORMAT_YCbCr_* + * - HAL_PIXEL_FORMAT_RGB*_* + * - even implementation defined formats that can be represented by + * the structures + * + * Each plane can be made up of one or more PlaneComponents depending on + * the format. + * + * Each plane can be subsampled either vertically or horizontally by + * a power-of-two factor. + * + * Pixel increment describes the distance in bytes from one pixel to the + * next pixel (to the right) on the same row for the component plane. + * This can be negative. + * + * Stride is provided in both pixels and bytes. + * Stride_bytes describes the distance in bytes from the first pixel of + * one row to the first pixel of the next row (below) for the component plane. + * This can be negative. + * + * Scanlines describes the height of the plane in terms of number of rows. + * + * Size of plane is stride_bytes * scanlines + any padding required for + * alignment as per format specification. + * + */ +struct PlaneLayout final { + ::android::hardware::hidl_bitfield< + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> + component __attribute__((aligned(4))); + uint32_t h_subsampling __attribute__((aligned(4))); + uint32_t v_subsampling __attribute__((aligned(4))); + uint32_t offset __attribute__((aligned(4))); + int32_t pixel_increment __attribute__((aligned(4))); + int32_t stride __attribute__((aligned(4))); + int32_t stride_bytes __attribute__((aligned(4))); + int32_t scanlines __attribute__((aligned(4))); + uint32_t size __attribute__((aligned(4))); +}; + +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + component) == 0, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + h_subsampling) == 4, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + v_subsampling) == 8, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + offset) == 12, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + pixel_increment) == 16, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + stride) == 20, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + stride_bytes) == 24, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + scanlines) == 28, + "wrong offset"); +static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, + size) == 32, + "wrong offset"); +static_assert(sizeof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout) == 36, + "wrong size"); +static_assert(__alignof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout) == 4, + "wrong alignment"); + +// +// type declarations for package +// + +template +static inline std::string toString(int32_t o); +static inline std::string toString( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error o); + +constexpr int32_t operator|( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|( + const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&( + const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=( + int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=( + int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) { + v &= static_cast(e); + return v; +} + +static inline std::string toString( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout& o); +// operator== and operator!= are not generated for YCbCrLayout + +template +static inline std::string toString(uint32_t o); +static inline std::string toString( + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent o); + +constexpr uint32_t operator|( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr uint32_t operator|( + const uint32_t lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr uint32_t operator|( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, + const uint32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr uint32_t operator&( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr uint32_t operator&( + const uint32_t lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr uint32_t operator&( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, + const uint32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr uint32_t& operator|=( + uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) { + v |= static_cast(e); + return v; +} +constexpr uint32_t& operator&=( + uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) { + v &= static_cast(e); + return v; +} + +template +static inline std::string toString(int32_t o); +static inline std::string toString( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags o); + +constexpr int32_t operator|( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { + return static_cast(static_cast(lhs) | static_cast(rhs)); +} +constexpr int32_t operator|( + const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { + return static_cast(lhs | static_cast(rhs)); +} +constexpr int32_t operator|( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) { + return static_cast(static_cast(lhs) | rhs); +} +constexpr int32_t operator&( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { + return static_cast(static_cast(lhs) & static_cast(rhs)); +} +constexpr int32_t operator&( + const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { + return static_cast(lhs & static_cast(rhs)); +} +constexpr int32_t operator&( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) { + return static_cast(static_cast(lhs) & rhs); +} +constexpr int32_t& operator|=( + int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) { + v |= static_cast(e); + return v; +} +constexpr int32_t& operator&=( + int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) { + v &= static_cast(e); + return v; +} + +static inline std::string toString( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& o); +static inline bool operator==( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs); +static inline bool operator!=( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs); + +// +// type header definitions for package +// + +template <> +inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::Error>( + int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield< + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error> + flipped = 0; + bool first = true; + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE)) { + os += (first ? "" : " | "); + os += "NONE"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER) == + static_cast( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER)) { + os += (first ? "" : " | "); + os += "BAD_BUFFER"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES) == + static_cast( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES)) { + os += (first ? "" : " | "); + os += "NO_RESOURCES"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED) == + static_cast( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED)) { + os += (first ? "" : " | "); + os += "UNSUPPORTED"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error o) { + using ::android::hardware::details::toHexString; + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE) { + return "NONE"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER) { + return "BAD_BUFFER"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES) { + return "NO_RESOURCES"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED) { + return "UNSUPPORTED"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +static inline std::string toString( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout& o) { + using ::android::hardware::toString; + std::string os; + os += "{"; + os += ".y = "; + os += ::android::hardware::toString(o.y); + os += ", .cb = "; + os += ::android::hardware::toString(o.cb); + os += ", .cr = "; + os += ::android::hardware::toString(o.cr); + os += ", .yStride = "; + os += ::android::hardware::toString(o.yStride); + os += ", .cStride = "; + os += ::android::hardware::toString(o.cStride); + os += ", .chromaStep = "; + os += ::android::hardware::toString(o.chromaStep); + os += "}"; + return os; +} + +// operator== and operator!= are not generated for YCbCrLayout + +template <> +inline std::string +toString<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent>(uint32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield< + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> + flipped = 0; + bool first = true; + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Y) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_Y)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_Y"; + first = false; + flipped |= + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cb) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_Cb)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_Cb"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cb; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cr) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_Cr)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_Cr"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cr; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_R) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_R)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_R"; + first = false; + flipped |= + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_G) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_G)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_G"; + first = false; + flipped |= + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_B) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_B)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_B"; + first = false; + flipped |= + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_A) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_A)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_A"; + first = false; + flipped |= + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_RAW) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_RAW)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_RAW"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_RAW; + } + if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_META) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0:: + PlaneComponent::PLANE_COMPONENT_META)) { + os += (first ? "" : " | "); + os += "PLANE_COMPONENT_META"; + first = false; + flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_META; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString( + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent o) { + using ::android::hardware::details::toHexString; + if (o == + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y) { + return "PLANE_COMPONENT_Y"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cb) { + return "PLANE_COMPONENT_Cb"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cr) { + return "PLANE_COMPONENT_Cr"; + } + if (o == + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R) { + return "PLANE_COMPONENT_R"; + } + if (o == + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G) { + return "PLANE_COMPONENT_G"; + } + if (o == + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B) { + return "PLANE_COMPONENT_B"; + } + if (o == + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A) { + return "PLANE_COMPONENT_A"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_RAW) { + return "PLANE_COMPONENT_RAW"; + } + if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_META) { + return "PLANE_COMPONENT_META"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +template <> +inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags>( + int32_t o) { + using ::android::hardware::details::toHexString; + std::string os; + ::android::hardware::hidl_bitfield< + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags> + flipped = 0; + bool first = true; + if ((o & + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG) == + static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags:: + LAYOUT_INTERLACED_FLAG)) { + os += (first ? "" : " | "); + os += "LAYOUT_INTERLACED_FLAG"; + first = false; + flipped |= + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG; + } + if (o != flipped) { + os += (first ? "" : " | "); + os += toHexString(o & (~flipped)); + } + os += " ("; + os += toHexString(o); + os += ")"; + return os; +} + +static inline std::string toString( + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags o) { + using ::android::hardware::details::toHexString; + if (o == + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG) { + return "LAYOUT_INTERLACED_FLAG"; + } + std::string os; + os += toHexString(static_cast(o)); + return os; +} + +static inline std::string toString( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& o) { + using ::android::hardware::toString; + std::string os; + os += "{"; + os += ".component = "; + os += ::vendor::qti::hardware::display::mapperextensions::V1_0::toString< + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent>(o.component); + os += ", .h_subsampling = "; + os += ::android::hardware::toString(o.h_subsampling); + os += ", .v_subsampling = "; + os += ::android::hardware::toString(o.v_subsampling); + os += ", .offset = "; + os += ::android::hardware::toString(o.offset); + os += ", .pixel_increment = "; + os += ::android::hardware::toString(o.pixel_increment); + os += ", .stride = "; + os += ::android::hardware::toString(o.stride); + os += ", .stride_bytes = "; + os += ::android::hardware::toString(o.stride_bytes); + os += ", .scanlines = "; + os += ::android::hardware::toString(o.scanlines); + os += ", .size = "; + os += ::android::hardware::toString(o.size); + os += "}"; + return os; +} + +static inline bool operator==( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs) { + if (lhs.component != rhs.component) { + return false; + } + if (lhs.h_subsampling != rhs.h_subsampling) { + return false; + } + if (lhs.v_subsampling != rhs.v_subsampling) { + return false; + } + if (lhs.offset != rhs.offset) { + return false; + } + if (lhs.pixel_increment != rhs.pixel_increment) { + return false; + } + if (lhs.stride != rhs.stride) { + return false; + } + if (lhs.stride_bytes != rhs.stride_bytes) { + return false; + } + if (lhs.scanlines != rhs.scanlines) { + return false; + } + if (lhs.size != rhs.size) { + return false; + } + return true; +} + +static inline bool operator!=( + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, + const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs) { + return !(lhs == rhs); +} + +} // namespace V1_0 +} // namespace mapperextensions +} // namespace display +} // namespace hardware +} // namespace qti +} // namespace vendor + +// +// global type declarations for package +// + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::Error, 4> + hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> = { + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE, + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER, + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES, + ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent, 9> + hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> = { + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cb, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_Cr, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_RAW, + ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent:: + PLANE_COMPONENT_META, +}; +} // namespace details +} // namespace hardware +} // namespace android + +namespace android { +namespace hardware { +namespace details { +template <> +constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags, 1> + hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags> = { + ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG, +}; +} // namespace details +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H diff --git a/tools/qtimapper-shim/ext_headers/common.h b/tools/qtimapper-shim/ext_headers/common.h deleted file mode 100644 index 09aa181..0000000 --- a/tools/qtimapper-shim/ext_headers/common.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2022 The Android Open Source Project - * - * 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. - */ - -#pragma once - -#include -#include -#include -#include -#include "types/common.h" - -using namespace android::hardware; -using namespace android; - -/* Simplified version of hidl::base::V1_0::IBase */ -struct IBase : virtual public RefBase { - virtual bool isRemote() const; - - using interfaceChain_cb = std::function &descriptors)>; - virtual Return interfaceChain(interfaceChain_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return debug(const hidl_handle &fd, const hidl_vec &options) { - ALOGE("%s", __func__); - std::terminate(); - } - - using interfaceDescriptor_cb = std::function; - virtual Return interfaceDescriptor(interfaceDescriptor_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using getHashChain_cb = std::function> &hashchain)>; - virtual Return getHashChain(getHashChain_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return setHALInstrumentation() { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return linkToDeath(const sp &recipient, uint64_t cookie) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return ping() { - ALOGE("%s", __func__); - std::terminate(); - } - - using getDebugInfo_cb = std::function; - virtual Return getDebugInfo(getDebugInfo_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return notifySyspropsChanged() { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return unlinkToDeath(const sp &recipient) { - ALOGE("%s", __func__); - std::terminate(); - } -}; diff --git a/tools/qtimapper-shim/ext_headers/mapper.h b/tools/qtimapper-shim/ext_headers/mapper.h deleted file mode 100644 index a6b8f62..0000000 --- a/tools/qtimapper-shim/ext_headers/mapper.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2016-2022, The Linux Foundation. All rights reserved. - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include "types/mapper.h" - -namespace vendor::qti::hardware::display::mapperextensions::V1_0 { - struct IQtiMapperExtensions; -} - -namespace android::hardware::graphics::mapper { -namespace V2_0 { - -struct IMapper : public IBase { - struct BufferDescriptorInfo final { - uint32_t width __attribute__ ((aligned(4))); - uint32_t height __attribute__ ((aligned(4))); - uint32_t layerCount __attribute__ ((aligned(4))); - graphics::common::V1_0::PixelFormat format __attribute__ ((aligned(4))); - hidl_bitfield usage __attribute__ ((aligned(8))); - }; - - struct Rect final { - int32_t left __attribute__ ((aligned(4))); - int32_t top __attribute__ ((aligned(4))); - int32_t width __attribute__ ((aligned(4))); - int32_t height __attribute__ ((aligned(4))); - }; - - - static sp getService(const std::string &/* serviceName */, const bool /* getStub */); -}; - -} -namespace V3_0 { - -struct IMapper : public IBase { - static sp getService(const std::string &/* serviceName */, const bool /* getStub */); -}; - -} -namespace V4_0 { - -struct IMapper : public IBase { - static sp getService(const std::string &/* serviceName */, const bool /* getStub */); -}; - -} -} - -namespace vendor::qti::hardware::display::mapper { -namespace V4_0 { - -struct IQtiMapper : public IBase { - static Return> castFrom(const sp &/* parent */, bool /* emitError */); -}; - -} -namespace V3_0 { - -struct IQtiMapper : public IBase { - static Return> castFrom(const sp &/* parent */, bool /* emitError */); -}; - -} -namespace V2_0 { - -struct IQtiMapper : public IBase { - using createDescriptor_cb = std::function &descriptor)>; - virtual Return createDescriptor(const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo &descriptorInfo, createDescriptor_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using importBuffer_cb = std::function; - virtual Return importBuffer(const hidl_handle &rawHandle, importBuffer_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return freeBuffer(void *buffer) { - ALOGE("%s", __func__); - std::terminate(); - } - - using lock_cb = std::function; - virtual Return lock(void *buffer, hidl_bitfield cpuUsage, const graphics::mapper::V2_0::IMapper::Rect &accessRegion, const hidl_handle &acquireFence, lock_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using lockYCbCr_cb = std::function; - virtual Return lockYCbCr(void *buffer, hidl_bitfield cpuUsage, const graphics::mapper::V2_0::IMapper::Rect &accessRegion, const hidl_handle &acquireFence, lockYCbCr_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using unlock_cb = std::function; - virtual Return unlock(void *buffer, unlock_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual Return validateBufferSize(void *buffer, const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo &descriptorInfo, uint32_t stride) { - ALOGE("%s", __func__); - std::terminate(); - } - - using getTransportSize_cb = std::function; - virtual Return getTransportSize(void *buffer, getTransportSize_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using createDescriptor_2_1_cb = std::function &descriptor)>; - virtual Return createDescriptor_2_1(const graphics::mapper::V2_0::IMapper::BufferDescriptorInfo &descriptorInfo, createDescriptor_2_1_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - using getMapperExtensions_cb = std::function &extensions)>; - virtual Return getMapperExtensions(getMapperExtensions_cb _hidl_cb); - - static Return> castFrom(const sp &/* parent */, bool /* emitError */); -}; - -} -} diff --git a/tools/qtimapper-shim/ext_headers/mapperextensions.h b/tools/qtimapper-shim/ext_headers/mapperextensions.h deleted file mode 100644 index 527f5f8..0000000 --- a/tools/qtimapper-shim/ext_headers/mapperextensions.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2016-2022, The Linux Foundation. All rights reserved. - - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include "types/mapperextensions.h" -#include "gr_priv_handle.h" - -namespace vendor::qti::hardware::display::mapperextensions { -namespace V1_0 { - -struct IQtiMapperExtensions : public IBase { - IQtiMapperExtensions() {}; -}; - -} -namespace V1_1 { - -struct IQtiMapperExtensions : public IBase { - IQtiMapperExtensions(); - - gralloc1_device_t *gralloc; - GRALLOC1_PFN_PERFORM perform; - - using getMapSecureBufferFlag_cb = std::function; - virtual ::android::hardware::Return getMapSecureBufferFlag(void *buffer, getMapSecureBufferFlag_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passthrough - using getInterlacedFlag_cb = std::function; - virtual ::android::hardware::Return getInterlacedFlag(void *buffer, getInterlacedFlag_cb _hidl_cb); - - using getCustomDimensions_cb = std::function; - virtual ::android::hardware::Return getCustomDimensions(void *buffer, getCustomDimensions_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passthrough - using getRgbDataAddress_cb = std::function; - virtual ::android::hardware::Return getRgbDataAddress(void *buffer, getRgbDataAddress_cb _hidl_cb); - - using calculateBufferAttributes_cb = std::function; - virtual ::android::hardware::Return calculateBufferAttributes(int32_t width, int32_t height, int32_t format, uint64_t usage, calculateBufferAttributes_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passhthrough - using getColorSpace_cb = std::function; - virtual ::android::hardware::Return getColorSpace(void *buffer, getColorSpace_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, passthrough with hidl fixups - using getYuvPlaneInfo_cb = std::function &layout)>; - virtual ::android::hardware::Return getYuvPlaneInfo(void *buffer, getYuvPlaneInfo_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - virtual ::android::hardware::Return<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> setSingleBufferMode(void *buffer, bool enable) { - ALOGE("%s", __func__); - std::terminate(); - } - - using getCustomFormatFlags_cb = std::function; - virtual ::android::hardware::Return getCustomFormatFlags(int32_t format, uint64_t usage, getCustomFormatFlags_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, cast private data with no passthrough - using getFd_cb = std::function; - virtual ::android::hardware::Return getFd(void *buffer, getFd_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getWidth_cb = std::function; - virtual ::android::hardware::Return getWidth(void *buffer, getWidth_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getHeight_cb = std::function; - virtual ::android::hardware::Return getHeight(void *buffer, getHeight_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getOffset_cb = std::function; - virtual ::android::hardware::Return getOffset(void *buffer, getOffset_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getSize_cb = std::function; - virtual ::android::hardware::Return getSize(void *buffer, getSize_cb _hidl_cb); - - using getUnalignedWidth_cb = std::function; - virtual ::android::hardware::Return getUnalignedWidth(void *buffer, getUnalignedWidth_cb _hidl_cb); - - using getUnalignedHeight_cb = std::function; - virtual ::android::hardware::Return getUnalignedHeight(void *buffer, getUnalignedHeight_cb _hidl_cb); - - using getLayerCount_cb = std::function; - virtual ::android::hardware::Return getLayerCount(void *buffer, getLayerCount_cb _hidl_cb); - - using getId_cb = std::function; - virtual ::android::hardware::Return getId(void *buffer, getId_cb _hidl_cb); - - using getUsageFlags_cb = std::function; - virtual ::android::hardware::Return getUsageFlags(void *buffer, getUsageFlags_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getFormat_cb = std::function; - virtual ::android::hardware::Return getFormat(void *buffer, getFormat_cb _hidl_cb); - - // Used, cast private data with no passthrough - using getPrivateFlags_cb = std::function; - virtual ::android::hardware::Return getPrivateFlags(void *buffer, getPrivateFlags_cb _hidl_cb); - - using getSurfaceMetadata_cb = std::function; - virtual ::android::hardware::Return getSurfaceMetadata(void *buffer, getSurfaceMetadata_cb _hidl_cb) { - ALOGE("%s", __func__); - std::terminate(); - } - - // Used, PAIN - using getFormatLayout_cb = std::function &plane_info)>; - virtual ::android::hardware::Return getFormatLayout(int32_t format, uint64_t usage, int32_t flags, int32_t width, int32_t height, getFormatLayout_cb _hidl_cb) { - ALOGE("%s fail", __func__); - return Void(); - } - - // V1.1, Used, passthrough - virtual ::android::hardware::Return<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> getSurfaceMetadata_V1(void *buffer, void *metadata) { - ALOGE("%s", __func__); - std::terminate(); - } - - static Return> castFrom(android::sp const &/* parent */, bool /* emitError */); -}; - -} -} diff --git a/tools/qtimapper-shim/ext_headers/types/common.h b/tools/qtimapper-shim/ext_headers/types/common.h deleted file mode 100644 index 79b3b69..0000000 --- a/tools/qtimapper-shim/ext_headers/types/common.h +++ /dev/null @@ -1,3121 +0,0 @@ -#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H -#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace graphics { -namespace common { -namespace V1_0 { - -// Forward declaration for forward reference support: -enum class PixelFormat : int32_t; -enum class BufferUsage : uint64_t; -enum class Transform : int32_t; -enum class Dataspace : int32_t; -enum class ColorMode : int32_t; -enum class ColorTransform : int32_t; -enum class Hdr : int32_t; - -/** - * Common enumeration and structure definitions for all graphics HALs. - * - * - * Pixel formats for graphics buffers. - */ -enum class PixelFormat : int32_t { - /** - * 32-bit format that has 8-bit R, G, B, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBA_8888 = 1 /* 0x1 */, - /** - * 32-bit format that has 8-bit R, G, B, and unused components, in that - * order, from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBX_8888 = 2 /* 0x2 */, - /** - * 24-bit format that has 8-bit R, G, and B components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGB_888 = 3 /* 0x3 */, - /** - * 16-bit packed format that has 5-bit R, 6-bit G, and 5-bit B components, - * in that order, from the most-sigfinicant bits to the least-significant - * bits. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGB_565 = 4 /* 0x4 */, - /** - * 32-bit format that has 8-bit B, G, R, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - BGRA_8888 = 5 /* 0x5 */, - /** - * Legacy formats deprecated in favor of YCBCR_420_888. - */ - YCBCR_422_SP = 16 /* 0x10 */, - YCRCB_420_SP = 17 /* 0x11 */, - YCBCR_422_I = 20 /* 0x14 */, - /** - * 64-bit format that has 16-bit R, G, B, and A components, in that order, - * from the lowest memory address to the highest memory address. - * - * The component values are signed floats, whose interpretation is defined - * by the dataspace. - */ - RGBA_FP16 = 22 /* 0x16 */, - /** - * RAW16 is a single-channel, 16-bit, little endian format, typically - * representing raw Bayer-pattern images from an image sensor, with minimal - * processing. - * - * The exact pixel layout of the data in the buffer is sensor-dependent, and - * needs to be queried from the camera device. - * - * Generally, not all 16 bits are used; more common values are 10 or 12 - * bits. If not all bits are used, the lower-order bits are filled first. - * All parameters to interpret the raw data (black and white points, - * color space, etc) must be queried from the camera device. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW16 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data, layout is as - * | defined above. - * Dataspace::DEPTH | Unprocessed implementation-dependent raw - * | depth measurements, opaque with 16 bit - * | samples. - * Other | Unsupported - */ - RAW16 = 32 /* 0x20 */, - /** - * BLOB is used to carry task-specific data which does not have a standard - * image structure. The details of the format are left to the two - * endpoints. - * - * A typical use case is for transporting JPEG-compressed images from the - * Camera HAL to the framework or to applications. - * - * Buffers of this format must have a height of 1, and width equal to their - * size in bytes. - * - * The mapping of the dataspace to buffer contents for BLOB is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::JFIF | An encoded JPEG image - * Dataspace::DEPTH | An android_depth_points buffer - * Dataspace::SENSOR | Sensor event data. - * Other | Unsupported - */ - BLOB = 33 /* 0x21 */, - /** - * A format indicating that the choice of format is entirely up to the - * allocator. - * - * The allocator should examine the usage bits passed in when allocating a - * buffer with this format, and it should derive the pixel format from - * those usage flags. This format must never be used with any of the - * BufferUsage::CPU_* usage flags. - * - * Even when the internally chosen format has an alpha component, the - * clients must assume the alpha vlaue to be 1.0. - * - * The interpretation of the component values is defined by the dataspace. - */ - IMPLEMENTATION_DEFINED = 34 /* 0x22 */, - /** - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be used to - * describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format must be accepted by the allocator when BufferUsage::CPU_* - * are set. - * - * Buffers with this format must be locked with IMapper::lockYCbCr. - * Locking with IMapper::lock must return an error. - * - * The interpretation of the component values is defined by the dataspace. - */ - YCBCR_420_888 = 35 /* 0x23 */, - /** - * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an - * image sensor. The actual structure of buffers of this format is - * implementation-dependent. - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW_OPAQUE is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW_OPAQUE = 36 /* 0x24 */, - /** - * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one - * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte - * contains the 2 least significant bits of the 4 pixels, the exact layout data - * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth - * bit of the ith pixel): - * - * bit 7 bit 0 - * =====|=====|=====|=====|=====|=====|=====|=====| - * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| - * =============================================== - * - * This format assumes - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (10 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (10 / 8), padding bytes will be present at the end of each - * row (including the last row). - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW10 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW10 = 37 /* 0x25 */, - /** - * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first - * and second byte contains the top 8 bits of first and second pixel. The third - * byte contains the 4 least significant bits of the two pixels, the exact layout - * data for each two consecutive pixels is illustrated below (Pi[j] stands for - * the jth bit of the ith pixel): - * - * bit 7 bit 0 - * ======|======|======|======|======|======|======|======| - * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| - * ======================================================= - * - * This format assumes: - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (12 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (12 / 8), padding bytes will be present at the end of - * each row (including the last row). - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::RENDERSCRIPT - * - * The mapping of the dataspace to buffer contents for RAW12 is as - * follows: - * - * Dataspace value | Buffer contents - * -------------------------------+----------------------------------------- - * Dataspace::ARBITRARY | Raw image sensor data. - * Other | Unsupported - */ - RAW12 = 38 /* 0x26 */, - /** - * 0x27 to 0x2A are reserved for flexible formats - * - * - * 32-bit packed format that has 2-bit A, 10-bit B, G, and R components, - * in that order, from the most-sigfinicant bits to the least-significant - * bits. - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - RGBA_1010102 = 43 /* 0x2B */, - /** - * 0x100 - 0x1FF - * - * This range is reserved for vendor extensions. Formats in this range - * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not - * have an alpha component. - * - * - * Y8 is a YUV planar format comprised of a WxH Y plane, with each pixel - * being represented by 8 bits. It is equivalent to just the Y plane from - * YV12. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * size = stride * height - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - Y8 = 538982489 /* 0x20203859 */, - /** - * Y16 is a YUV planar format comprised of a WxH Y plane, with each pixel - * being represented by 16 bits. It is just like Y8, but has double the - * bits per pixel (little endian). - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. When the dataspace is - * Dataspace::DEPTH, each pixel is a distance value measured by a depth - * camera, plus an associated confidence value. - */ - Y16 = 540422489 /* 0x20363159 */, - /** - * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed - * by (W/2) x (H/2) Cr and Cb planes. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * y_size = stride * height - * c_stride = ALIGN(stride/2, 16) - * c_size = c_stride * height/2 - * size = y_size + c_size * 2 - * cr_offset = y_size - * cb_offset = y_size + c_size - * - * This range is reserved for vendor extensions. Formats in this range - * must support BufferUsage::GPU_TEXTURE. Clients must assume they do not - * have an alpha component. - * - * This format must be accepted by the allocator when used with the - * following usage flags: - * - * - BufferUsage::CAMERA_* - * - BufferUsage::CPU_* - * - BufferUsage::GPU_TEXTURE - * - * The component values are unsigned normalized to the range [0, 1], whose - * interpretation is defined by the dataspace. - */ - YV12 = 842094169 /* 0x32315659 */, -}; - -/** - * Buffer usage definitions. - */ -enum class BufferUsage : uint64_t { - /** - * bit 0-3 is an enum - */ - CPU_READ_MASK = 15ull /* 0xfULL */, - /** - * buffer is never read by CPU - */ - CPU_READ_NEVER = 0ull, - /** - * buffer is rarely read by CPU - */ - CPU_READ_RARELY = 2ull, - /** - * buffer is often read by CPU - */ - CPU_READ_OFTEN = 3ull, - /** - * bit 4-7 is an enum - */ - CPU_WRITE_MASK = 240ull /* (0xfULL << 4) */, - /** - * buffer is never written by CPU - */ - CPU_WRITE_NEVER = 0ull /* (0 << 4) */, - /** - * buffer is rarely written by CPU - */ - CPU_WRITE_RARELY = 32ull /* (2 << 4) */, - /** - * buffer is often written by CPU - */ - CPU_WRITE_OFTEN = 48ull /* (3 << 4) */, - /** - * buffer is used as a GPU texture - */ - GPU_TEXTURE = 256ull /* (1ULL << 8) */, - /** - * buffer is used as a GPU render target - */ - GPU_RENDER_TARGET = 512ull /* (1ULL << 9) */, - /** - * bit 10 must be zero - * - * - * buffer is used as a composer HAL overlay layer - */ - COMPOSER_OVERLAY = 2048ull /* (1ULL << 11) */, - /** - * buffer is used as a composer HAL client target - */ - COMPOSER_CLIENT_TARGET = 4096ull /* (1ULL << 12) */, - /** - * bit 13 must be zero - * - * - * Buffer is allocated with hardware-level protection against copying the - * contents (or information derived from the contents) into unprotected - * memory. - */ - PROTECTED = 16384ull /* (1ULL << 14) */, - /** - * buffer is used as a hwcomposer HAL cursor layer - */ - COMPOSER_CURSOR = 32768ull /* (1ULL << 15) */, - /** - * buffer is used as a video encoder input - */ - VIDEO_ENCODER = 65536ull /* (1ULL << 16) */, - /** - * buffer is used as a camera HAL output - */ - CAMERA_OUTPUT = 131072ull /* (1ULL << 17) */, - /** - * buffer is used as a camera HAL input - */ - CAMERA_INPUT = 262144ull /* (1ULL << 18) */, - /** - * bit 19 must be zero - * - * - * buffer is used as a renderscript allocation - */ - RENDERSCRIPT = 1048576ull /* (1ULL << 20) */, - /** - * bit 21 must be zero - * - * - * buffer is used as a video decoder output - */ - VIDEO_DECODER = 4194304ull /* (1ULL << 22) */, - /** - * buffer is used as a sensor direct report output - */ - SENSOR_DIRECT_DATA = 8388608ull /* (1ULL << 23) */, - /** - * buffer is used as as an OpenGL shader storage or uniform - * buffer object - */ - GPU_DATA_BUFFER = 16777216ull /* (1ULL << 24) */, - /** - * bits 25-27 must be zero and are reserved for future versions - * - * - * bits 28-31 are reserved for vendor extensions - */ - VENDOR_MASK = 4026531840ull /* (0xfULL << 28) */, - /** - * bits 32-47 must be zero and are reserved for future versions - * - * - * bits 48-63 are reserved for vendor extensions - */ - VENDOR_MASK_HI = 18446462598732840960ull /* (0xffffULL << 48) */, -}; - -/** - * Transformation definitions - */ -enum class Transform : int32_t { - /** - * Horizontal flip. FLIP_H/FLIP_V is applied before ROT_90. - */ - FLIP_H = 1 /* (1 << 0) */, - /** - * Vertical flip. FLIP_H/FLIP_V is applied before ROT_90. - */ - FLIP_V = 2 /* (1 << 1) */, - /** - * 90 degree clockwise rotation. FLIP_H/FLIP_V is applied before ROT_90. - */ - ROT_90 = 4 /* (1 << 2) */, - /** - * Commonly used combinations. - */ - ROT_180 = 3 /* (FLIP_H | FLIP_V) */, - ROT_270 = 7 /* ((FLIP_H | FLIP_V) | ROT_90) */, -}; - -/** - * Dataspace Definitions - * ====================== - * - * Dataspace is the definition of how pixel values should be interpreted. - * - * For many formats, this is the colorspace of the image data, which includes - * primaries (including white point) and the transfer characteristic function, - * which describes both gamma curve and numeric range (within the bit depth). - * - * Other dataspaces include depth measurement data from a depth camera. - * - * A dataspace is comprised of a number of fields. - * - * Version - * -------- - * The top 2 bits represent the revision of the field specification. This is - * currently always 0. - * - * - * bits 31-30 29 - 0 - * +-----+----------------------------------------------------+ - * fields | Rev | Revision specific fields | - * +-----+----------------------------------------------------+ - * - * Field layout for version = 0: - * ---------------------------- - * - * A dataspace is comprised of the following fields: - * Standard - * Transfer function - * Range - * - * bits 31-30 29-27 26 - 22 21 - 16 15 - 0 - * +-----+-----+--------+--------+----------------------------+ - * fields | 0 |Range|Transfer|Standard| Legacy and custom | - * +-----+-----+--------+--------+----------------------------+ - * VV RRR TTTTT SSSSSS LLLLLLLL LLLLLLLL - * - * If range, transfer and standard fields are all 0 (e.g. top 16 bits are - * all zeroes), the bottom 16 bits contain either a legacy dataspace value, - * or a custom value. - */ -enum class Dataspace : int32_t { - /** - * Default-assumption data space, when not explicitly specified. - * - * It is safest to assume the buffer is an image with sRGB primaries and - * encoding ranges, but the consumer and/or the producer of the data may - * simply be using defaults. No automatic gamma transform should be - * expected, except for a possible display gamma transform when drawn to a - * screen. - */ - UNKNOWN = 0 /* 0x0 */, - /** - * Arbitrary dataspace with manually defined characteristics. Definition - * for colorspaces or other meaning must be communicated separately. - * - * This is used when specifying primaries, transfer characteristics, - * etc. separately. - * - * A typical use case is in video encoding parameters (e.g. for H.264), - * where a colorspace can have separately defined primaries, transfer - * characteristics, etc. - */ - ARBITRARY = 1 /* 0x1 */, - /** - * Color-description aspects - * - * The following aspects define various characteristics of the color - * specification. These represent bitfields, so that a data space value - * can specify each of them independently. - */ - STANDARD_SHIFT = 16, - /** - * Standard aspect - * - * Defines the chromaticity coordinates of the source primaries in terms of - * the CIE 1931 definition of x and y specified in ISO 11664-1. - */ - STANDARD_MASK = 4128768 /* (63 << STANDARD_SHIFT) */, - /** - * Chromacity coordinates are unknown or are determined by the application. - * Implementations shall use the following suggested standards: - * - * All YCbCr formats: BT709 if size is 720p or larger (since most video - * content is letterboxed this corresponds to width is - * 1280 or greater, or height is 720 or greater). - * BT601_625 if size is smaller than 720p or is JPEG. - * All RGB formats: BT709. - * - * For all other formats standard is undefined, and implementations should use - * an appropriate standard for the data represented. - */ - STANDARD_UNSPECIFIED = 0 /* (0 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT709 = 65536 /* (1 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - STANDARD_BT601_625 = 131072 /* (2 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT601_625_UNADJUSTED = 196608 /* (3 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - */ - STANDARD_BT601_525 = 262144 /* (4 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - */ - STANDARD_BT601_525_UNADJUSTED = 327680 /* (5 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT2020 = 393216 /* (6 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.170 0.797 - * blue 0.131 0.046 - * red 0.708 0.292 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation - * for RGB conversion using the linear domain. - */ - STANDARD_BT2020_CONSTANT_LUMINANCE = 458752 /* (7 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.21 0.71 - * blue 0.14 0.08 - * red 0.67 0.33 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation - * for RGB conversion. - */ - STANDARD_BT470M = 524288 /* (8 << STANDARD_SHIFT) */, - /** - * Primaries: x y - * green 0.243 0.692 - * blue 0.145 0.049 - * red 0.681 0.319 - * white (C) 0.310 0.316 - * - * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation - * for RGB conversion. - */ - STANDARD_FILM = 589824 /* (9 << STANDARD_SHIFT) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3) - * Primaries: x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - */ - STANDARD_DCI_P3 = 655360 /* (10 << STANDARD_SHIFT) */, - /** - * Adobe RGB - * Primaries: x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - STANDARD_ADOBE_RGB = 720896 /* (11 << STANDARD_SHIFT) */, - TRANSFER_SHIFT = 22, - /** - * Transfer aspect - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * For digital signals, E corresponds to the recorded value. Normally, the - * transfer function is applied in RGB space to each of the R, G and B - * components independently. This may result in color shift that can be - * minized by applying the transfer function in Lab space only for the L - * component. Implementation may apply the transfer function in RGB space - * for all pixel formats if desired. - */ - TRANSFER_MASK = 130023424 /* (31 << TRANSFER_SHIFT) */, - /** - * Transfer characteristics are unknown or are determined by the - * application. - * - * Implementations should use the following transfer functions: - * - * For YCbCr formats: use TRANSFER_SMPTE_170M - * For RGB formats: use TRANSFER_SRGB - * - * For all other formats transfer function is undefined, and implementations - * should use an appropriate standard for the data represented. - */ - TRANSFER_UNSPECIFIED = 0 /* (0 << TRANSFER_SHIFT) */, - /** - * Transfer characteristic curve: - * E = L - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_LINEAR = 4194304 /* (1 << TRANSFER_SHIFT) */, - /** - * Transfer characteristic curve: - * - * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1 - * = 12.92 * L for 0 <= L < 0.0031308 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_SRGB = 8388608 /* (2 << TRANSFER_SHIFT) */, - /** - * BT.601 525, BT.601 625, BT.709, BT.2020 - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1 - * = 4.500 * L for 0 <= L < 0.018 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_SMPTE_170M = 12582912 /* (3 << TRANSFER_SHIFT) */, - /** - * Assumed display gamma 2.2. - * - * Transfer characteristic curve: - * E = L ^ (1/2.2) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_2 = 16777216 /* (4 << TRANSFER_SHIFT) */, - /** - * display gamma 2.6. - * - * Transfer characteristic curve: - * E = L ^ (1/2.6) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_6 = 20971520 /* (5 << TRANSFER_SHIFT) */, - /** - * display gamma 2.8. - * - * Transfer characteristic curve: - * E = L ^ (1/2.8) - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - */ - TRANSFER_GAMMA2_8 = 25165824 /* (6 << TRANSFER_SHIFT) */, - /** - * SMPTE ST 2084 (Dolby Perceptual Quantizer) - * - * Transfer characteristic curve: - * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m - * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375 - * c2 = 32 * 2413 / 4096 = 18.8515625 - * c3 = 32 * 2392 / 4096 = 18.6875 - * m = 128 * 2523 / 4096 = 78.84375 - * n = 0.25 * 2610 / 4096 = 0.1593017578125 - * L - luminance of image 0 <= L <= 1 for HDR colorimetry. - * L = 1 corresponds to 10000 cd/m2 - * E - corresponding electrical signal - */ - TRANSFER_ST2084 = 29360128 /* (7 << TRANSFER_SHIFT) */, - /** - * ARIB STD-B67 Hybrid Log Gamma - * - * Transfer characteristic curve: - * E = r * L^0.5 for 0 <= L <= 1 - * = a * ln(L - b) + c for 1 < L - * a = 0.17883277 - * b = 0.28466892 - * c = 0.55991073 - * r = 0.5 - * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds - * to reference white level of 100 cd/m2 - * E - corresponding electrical signal - */ - TRANSFER_HLG = 33554432 /* (8 << TRANSFER_SHIFT) */, - RANGE_SHIFT = 27, - /** - * Range aspect - * - * Defines the range of values corresponding to the unit range of 0-1. - * This is defined for YCbCr only, but can be expanded to RGB space. - */ - RANGE_MASK = 939524096 /* (7 << RANGE_SHIFT) */, - /** - * Range is unknown or are determined by the application. Implementations - * shall use the following suggested ranges: - * - * All YCbCr formats: limited range. - * All RGB or RGBA formats (including RAW and Bayer): full range. - * All Y formats: full range - * - * For all other formats range is undefined, and implementations should use - * an appropriate range for the data represented. - */ - RANGE_UNSPECIFIED = 0 /* (0 << RANGE_SHIFT) */, - /** - * Full range uses all values for Y, Cb and Cr from - * 0 to 2^b-1, where b is the bit depth of the color format. - */ - RANGE_FULL = 134217728 /* (1 << RANGE_SHIFT) */, - /** - * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and - * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of - * the color format. - * - * E.g. For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - */ - RANGE_LIMITED = 268435456 /* (2 << RANGE_SHIFT) */, - /** - * Extended range is used for scRGB. Intended for use with - * floating point pixel formats. [0.0 - 1.0] is the standard - * sRGB space. Values outside the range 0.0 - 1.0 can encode - * color outside the sRGB gamut. - * Used to blend / merge multiple dataspaces on a single display. - */ - RANGE_EXTENDED = 402653184 /* (3 << RANGE_SHIFT) */, - /** - * Legacy dataspaces - * - * - * sRGB linear encoding: - * - * The red, green, and blue components are stored in sRGB space, but - * are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - */ - SRGB_LINEAR = 512 /* 0x200 */, - V0_SRGB_LINEAR = 138477568 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * scRGB linear encoding: - * - * The red, green, and blue components are stored in extended sRGB space, - * but are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are floating point. - * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. - * Values beyond the range [0.0 - 1.0] would correspond to other colors - * spaces and/or HDR content. - */ - V0_SCRGB_LINEAR = 406913024 /* ((STANDARD_BT709 | TRANSFER_LINEAR) | RANGE_EXTENDED) */, - /** - * sRGB gamma encoding: - * - * The red, green and blue components are stored in sRGB space, and - * converted to linear space when read, using the SRGB transfer function - * for each of the R, G and B components. When written, the inverse - * transformation is performed. - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - * Use full range and BT.709 standard. - */ - SRGB = 513 /* 0x201 */, - V0_SRGB = 142671872 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_FULL) */, - /** - * scRGB: - * - * The red, green, and blue components are stored in extended sRGB space, - * but are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are floating point. - * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits. - * Values beyond the range [0.0 - 1.0] would correspond to other colors - * spaces and/or HDR content. - */ - V0_SCRGB = 411107328 /* ((STANDARD_BT709 | TRANSFER_SRGB) | RANGE_EXTENDED) */, - /** - * YCbCr Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - * - * - * JPEG File Interchange Format (JFIF) - * - * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 - * - * Use full range, BT.601 transfer and BT.601_625 standard. - */ - JFIF = 257 /* 0x101 */, - V0_JFIF = 146931712 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, - /** - * ITU-R Recommendation 601 (BT.601) - 625-line - * - * Standard-definition television, 625 Lines (PAL) - * - * Use limited range, BT.601 transfer and BT.601_625 standard. - */ - BT601_625 = 258 /* 0x102 */, - V0_BT601_625 = 281149440 /* ((STANDARD_BT601_625 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 601 (BT.601) - 525-line - * - * Standard-definition television, 525 Lines (NTSC) - * - * Use limited range, BT.601 transfer and BT.601_525 standard. - */ - BT601_525 = 259 /* 0x103 */, - V0_BT601_525 = 281280512 /* ((STANDARD_BT601_525 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * ITU-R Recommendation 709 (BT.709) - * - * High-definition television - * - * Use limited range, BT.709 transfer and BT.709 standard. - */ - BT709 = 260 /* 0x104 */, - V0_BT709 = 281083904 /* ((STANDARD_BT709 | TRANSFER_SMPTE_170M) | RANGE_LIMITED) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. - * - * Digital Cinema DCI-P3 - * - * Use full range, linear transfer and D65 DCI-P3 standard - */ - DCI_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * SMPTE EG 432-1 and SMPTE RP 431-2. - * - * Digital Cinema DCI-P3 - * - * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard - * Note: Application is responsible for gamma encoding the data as - * a 2.6 gamma encoding is not supported in HW. - */ - DCI_P3 = 155844608 /* ((STANDARD_DCI_P3 | TRANSFER_GAMMA2_6) | RANGE_FULL) */, - /** - * Display P3 - * - * Display P3 uses same primaries and white-point as DCI-P3 - * linear transfer function makes this the same as DCI_P3_LINEAR. - */ - DISPLAY_P3_LINEAR = 139067392 /* ((STANDARD_DCI_P3 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * Display P3 - * - * Use same primaries and white-point as DCI-P3 - * but sRGB transfer function. - */ - DISPLAY_P3 = 143261696 /* ((STANDARD_DCI_P3 | TRANSFER_SRGB) | RANGE_FULL) */, - /** - * Adobe RGB - * - * Use full range, gamma 2.2 transfer and Adobe RGB primaries - * Note: Application is responsible for gamma encoding the data as - * a 2.2 gamma encoding is not supported in HW. - */ - ADOBE_RGB = 151715840 /* ((STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, linear transfer and BT2020 standard - */ - BT2020_LINEAR = 138805248 /* ((STANDARD_BT2020 | TRANSFER_LINEAR) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, BT.709 transfer and BT2020 standard - */ - BT2020 = 147193856 /* ((STANDARD_BT2020 | TRANSFER_SMPTE_170M) | RANGE_FULL) */, - /** - * ITU-R Recommendation 2020 (BT.2020) - * - * Ultra High-definition television - * - * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard - */ - BT2020_PQ = 163971072 /* ((STANDARD_BT2020 | TRANSFER_ST2084) | RANGE_FULL) */, - /** - * Data spaces for non-color formats - * - * - * The buffer contains depth ranging measurements from a depth camera. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement - * and an associated confidence value. The 3 MSBs of the sample make - * up the confidence value, and the low 13 LSBs of the sample make up - * the depth measurement. - * For the confidence section, 0 means 100% confidence, 1 means 0% - * confidence. The mapping to a linear float confidence value between - * 0.f and 1.f can be obtained with - * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; - * The depth measurement can be extracted simply with - * uint16_t range = (depthSample & 0x1FFF); - * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as - * a variable-length float (x,y,z, confidence) coordinate point list. - * The point cloud will be represented with the android_depth_points - * structure. - */ - DEPTH = 4096 /* 0x1000 */, - /** - * The buffer contains sensor events from sensor direct report. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_BLOB: an array of sensor event structure that forms - * a lock free queue. Format of sensor event structure is specified - * in Sensors HAL. - */ - SENSOR = 4097 /* 0x1001 */, -}; - -/** - * Color modes that may be supported by a display. - * - * Definitions: - * Rendering intent generally defines the goal in mapping a source (input) - * color to a destination device color for a given color mode. - * - * It is important to keep in mind three cases where mapping may be applied: - * 1. The source gamut is much smaller than the destination (display) gamut - * 2. The source gamut is much larger than the destination gamut (this will - * ordinarily be handled using colorimetric rendering, below) - * 3. The source and destination gamuts are roughly equal, although not - * completely overlapping - * Also, a common requirement for mappings is that skin tones should be - * preserved, or at least remain natural in appearance. - * - * Colorimetric Rendering Intent (All cases): - * Colorimetric indicates that colors should be preserved. In the case - * that the source gamut lies wholly within the destination gamut or is - * about the same (#1, #3), this will simply mean that no manipulations - * (no saturation boost, for example) are applied. In the case where some - * source colors lie outside the destination gamut (#2, #3), those will - * need to be mapped to colors that are within the destination gamut, - * while the already in-gamut colors remain unchanged. - * - * Non-colorimetric transforms can take many forms. There are no hard - * rules and it's left to the implementation to define. - * Two common intents are described below. - * - * Stretched-Gamut Enhancement Intent (Source < Destination): - * When the destination gamut is much larger than the source gamut (#1), the - * source primaries may be redefined to reflect the full extent of the - * destination space, or to reflect an intermediate gamut. - * Skin-tone preservation would likely be applied. An example might be sRGB - * input displayed on a DCI-P3 capable device, with skin-tone preservation. - * - * Within-Gamut Enhancement Intent (Source >= Destination): - * When the device (destination) gamut is not larger than the source gamut - * (#2 or #3), but the appearance of a larger gamut is desired, techniques - * such as saturation boost may be applied to the source colors. Skin-tone - * preservation may be applied. There is no unique method for within-gamut - * enhancement; it would be defined within a flexible color mode. - * - */ -enum class ColorMode : int32_t { - /** - * DEFAULT is the "native" gamut of the display. - * White Point: Vendor/OEM defined - * Panel Gamma: Vendor/OEM defined (typically 2.2) - * Rendering Intent: Vendor/OEM defined (typically 'enhanced') - */ - NATIVE = 0, - /** - * STANDARD_BT601_625 corresponds with display - * settings that implement the ITU-R Recommendation BT.601 - * or Rec 601. Using 625 line version - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_625 = 1, - /** - * Primaries: - * x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation - * for RGB conversion. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_625_UNADJUSTED = 2, - /** - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation - * for RGB conversion from the one purely determined by the primaries - * to minimize the color shift into RGB space that uses BT.709 - * primaries. - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_525 = 3, - /** - * Primaries: - * x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - * - * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation - * for RGB conversion (as in SMPTE 240M). - * - * Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.500 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear)^(0.45) – 0.099 - */ - STANDARD_BT601_525_UNADJUSTED = 4, - /** - * REC709 corresponds with display settings that implement - * the ITU-R Recommendation BT.709 / Rec. 709 for high-definition television. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * HDTV REC709 Inverse Gamma Correction (IGC): V represents normalized - * (with [0 to 1] range) value of R, G, or B. - * - * if Vnonlinear < 0.081 - * Vlinear = Vnonlinear / 4.5 - * else - * Vlinear = ((Vnonlinear + 0.099) / 1.099) ^ (1/0.45) - * - * HDTV REC709 Gamma Correction (GC): - * - * if Vlinear < 0.018 - * Vnonlinear = 4.5 * Vlinear - * else - * Vnonlinear = 1.099 * (Vlinear) ^ 0.45 – 0.099 - */ - STANDARD_BT709 = 5, - /** - * DCI_P3 corresponds with display settings that implement - * SMPTE EG 432-1 and SMPTE RP 431-2 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.6 - */ - DCI_P3 = 6, - /** - * SRGB corresponds with display settings that implement - * the sRGB color space. Uses the same primaries as ITU-R Recommendation - * BT.709 - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Inverse Gamma Correction (IGC): - * - * if Vnonlinear ≤ 0.03928 - * Vlinear = Vnonlinear / 12.92 - * else - * Vlinear = ((Vnonlinear + 0.055)/1.055) ^ 2.4 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0031308 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - */ - SRGB = 7, - /** - * ADOBE_RGB corresponds with the RGB color space developed - * by Adobe Systems, Inc. in 1998. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.210 0.710 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - * - * Gamma: 2.2 - */ - ADOBE_RGB = 8, - /** - * DISPLAY_P3 is a color space that uses the DCI_P3 primaries, - * the D65 white point and the SRGB transfer functions. - * Rendering Intent: Colorimetric - * Primaries: - * x y - * green 0.265 0.690 - * blue 0.150 0.060 - * red 0.680 0.320 - * white (D65) 0.3127 0.3290 - * - * PC/Internet (sRGB) Gamma Correction (GC): - * - * if Vlinear ≤ 0.0030186 - * Vnonlinear = 12.92 * Vlinear - * else - * Vnonlinear = 1.055 * (Vlinear)^(1/2.4) – 0.055 - * - * Note: In most cases sRGB transfer function will be fine. - */ - DISPLAY_P3 = 9, -}; - -/** - * Color transforms that may be applied by hardware composer to the whole - * display. - */ -enum class ColorTransform : int32_t { - /** - * Applies no transform to the output color - */ - IDENTITY = 0, - /** - * Applies an arbitrary transform defined by a 4x4 affine matrix - */ - ARBITRARY_MATRIX = 1, - /** - * Applies a transform that inverts the value or luminance of the color, but - * does not modify hue or saturation - */ - VALUE_INVERSE = 2, - /** - * Applies a transform that maps all colors to shades of gray - */ - GRAYSCALE = 3, - /** - * Applies a transform which corrects for protanopic color blindness - */ - CORRECT_PROTANOPIA = 4, - /** - * Applies a transform which corrects for deuteranopic color blindness - */ - CORRECT_DEUTERANOPIA = 5, - /** - * Applies a transform which corrects for tritanopic color blindness - */ - CORRECT_TRITANOPIA = 6, -}; - -/** - * Supported HDR formats. Must be kept in sync with equivalents in Display.java. - */ -enum class Hdr : int32_t { - /** - * Device supports Dolby Vision HDR - */ - DOLBY_VISION = 1, - /** - * Device supports HDR10 - */ - HDR10 = 2, - /** - * Device supports hybrid log-gamma HDR - */ - HLG = 3, -}; - -// -// type declarations for package -// - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::PixelFormat o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::PixelFormat rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::PixelFormat lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::common::V1_0::PixelFormat e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::common::V1_0::PixelFormat e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(uint64_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::BufferUsage o); - -constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr uint64_t operator|(const uint64_t lhs, const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr uint64_t operator|(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, const uint64_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr uint64_t operator&(const uint64_t lhs, const ::android::hardware::graphics::common::V1_0::BufferUsage rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr uint64_t operator&(const ::android::hardware::graphics::common::V1_0::BufferUsage lhs, const uint64_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr uint64_t &operator|=(uint64_t& v, const ::android::hardware::graphics::common::V1_0::BufferUsage e) { - v |= static_cast(e); - return v; -} -constexpr uint64_t &operator&=(uint64_t& v, const ::android::hardware::graphics::common::V1_0::BufferUsage e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::Transform o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Transform lhs, const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Transform lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Transform lhs, const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::Transform rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Transform lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::common::V1_0::Transform e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::common::V1_0::Transform e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::Dataspace o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::Dataspace rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Dataspace lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::common::V1_0::Dataspace e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::common::V1_0::Dataspace e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorMode o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::ColorMode rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorMode lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::common::V1_0::ColorMode e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::common::V1_0::ColorMode e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorTransform o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::ColorTransform rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::ColorTransform lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::common::V1_0::ColorTransform e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::common::V1_0::ColorTransform e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::common::V1_0::Hdr o); - -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Hdr lhs, const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::common::V1_0::Hdr lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Hdr lhs, const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::common::V1_0::Hdr rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::common::V1_0::Hdr lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::common::V1_0::Hdr e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::common::V1_0::Hdr e) { - v &= static_cast(e); - return v; -} - -// -// type header definitions for package -// - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::PixelFormat>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::PixelFormat> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888)) { - os += (first ? "" : " | "); - os += "RGBA_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888)) { - os += (first ? "" : " | "); - os += "RGBX_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888)) { - os += (first ? "" : " | "); - os += "RGB_888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565)) { - os += (first ? "" : " | "); - os += "RGB_565"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888)) { - os += (first ? "" : " | "); - os += "BGRA_8888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP)) { - os += (first ? "" : " | "); - os += "YCBCR_422_SP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP)) { - os += (first ? "" : " | "); - os += "YCRCB_420_SP"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I)) { - os += (first ? "" : " | "); - os += "YCBCR_422_I"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16)) { - os += (first ? "" : " | "); - os += "RGBA_FP16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW16)) { - os += (first ? "" : " | "); - os += "RAW16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::BLOB)) { - os += (first ? "" : " | "); - os += "BLOB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED)) { - os += (first ? "" : " | "); - os += "IMPLEMENTATION_DEFINED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888)) { - os += (first ? "" : " | "); - os += "YCBCR_420_888"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE)) { - os += (first ? "" : " | "); - os += "RAW_OPAQUE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW10)) { - os += (first ? "" : " | "); - os += "RAW10"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RAW12)) { - os += (first ? "" : " | "); - os += "RAW12"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102)) { - os += (first ? "" : " | "); - os += "RGBA_1010102"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::Y8) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::Y8)) { - os += (first ? "" : " | "); - os += "Y8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::Y8; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::Y16) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::Y16)) { - os += (first ? "" : " | "); - os += "Y16"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::Y16; - } - if ((o & ::android::hardware::graphics::common::V1_0::PixelFormat::YV12) == static_cast(::android::hardware::graphics::common::V1_0::PixelFormat::YV12)) { - os += (first ? "" : " | "); - os += "YV12"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::PixelFormat::YV12; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::PixelFormat o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888) { - return "RGBA_8888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888) { - return "RGBX_8888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888) { - return "RGB_888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565) { - return "RGB_565"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888) { - return "BGRA_8888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP) { - return "YCBCR_422_SP"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP) { - return "YCRCB_420_SP"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I) { - return "YCBCR_422_I"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16) { - return "RGBA_FP16"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16) { - return "RAW16"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB) { - return "BLOB"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED) { - return "IMPLEMENTATION_DEFINED"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888) { - return "YCBCR_420_888"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE) { - return "RAW_OPAQUE"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10) { - return "RAW10"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12) { - return "RAW12"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102) { - return "RGBA_1010102"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::Y8) { - return "Y8"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::Y16) { - return "Y16"; - } - if (o == ::android::hardware::graphics::common::V1_0::PixelFormat::YV12) { - return "YV12"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::BufferUsage>(uint64_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::BufferUsage> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK)) { - os += (first ? "" : " | "); - os += "CPU_READ_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER)) { - os += (first ? "" : " | "); - os += "CPU_READ_NEVER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY)) { - os += (first ? "" : " | "); - os += "CPU_READ_RARELY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN)) { - os += (first ? "" : " | "); - os += "CPU_READ_OFTEN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_NEVER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_RARELY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN)) { - os += (first ? "" : " | "); - os += "CPU_WRITE_OFTEN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE)) { - os += (first ? "" : " | "); - os += "GPU_TEXTURE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET)) { - os += (first ? "" : " | "); - os += "GPU_RENDER_TARGET"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY)) { - os += (first ? "" : " | "); - os += "COMPOSER_OVERLAY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET)) { - os += (first ? "" : " | "); - os += "COMPOSER_CLIENT_TARGET"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED)) { - os += (first ? "" : " | "); - os += "PROTECTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR)) { - os += (first ? "" : " | "); - os += "COMPOSER_CURSOR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER)) { - os += (first ? "" : " | "); - os += "VIDEO_ENCODER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT)) { - os += (first ? "" : " | "); - os += "CAMERA_OUTPUT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT)) { - os += (first ? "" : " | "); - os += "CAMERA_INPUT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT)) { - os += (first ? "" : " | "); - os += "RENDERSCRIPT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER)) { - os += (first ? "" : " | "); - os += "VIDEO_DECODER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA)) { - os += (first ? "" : " | "); - os += "SENSOR_DIRECT_DATA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER)) { - os += (first ? "" : " | "); - os += "GPU_DATA_BUFFER"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK)) { - os += (first ? "" : " | "); - os += "VENDOR_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI) == static_cast(::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI)) { - os += (first ? "" : " | "); - os += "VENDOR_MASK_HI"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::BufferUsage o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK) { - return "CPU_READ_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER) { - return "CPU_READ_NEVER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY) { - return "CPU_READ_RARELY"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN) { - return "CPU_READ_OFTEN"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK) { - return "CPU_WRITE_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER) { - return "CPU_WRITE_NEVER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY) { - return "CPU_WRITE_RARELY"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN) { - return "CPU_WRITE_OFTEN"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE) { - return "GPU_TEXTURE"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET) { - return "GPU_RENDER_TARGET"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY) { - return "COMPOSER_OVERLAY"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET) { - return "COMPOSER_CLIENT_TARGET"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED) { - return "PROTECTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR) { - return "COMPOSER_CURSOR"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) { - return "VIDEO_ENCODER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT) { - return "CAMERA_OUTPUT"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT) { - return "CAMERA_INPUT"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT) { - return "RENDERSCRIPT"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER) { - return "VIDEO_DECODER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA) { - return "SENSOR_DIRECT_DATA"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER) { - return "GPU_DATA_BUFFER"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK) { - return "VENDOR_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI) { - return "VENDOR_MASK_HI"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::Transform>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Transform> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::Transform::FLIP_H) == static_cast(::android::hardware::graphics::common::V1_0::Transform::FLIP_H)) { - os += (first ? "" : " | "); - os += "FLIP_H"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::FLIP_H; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::FLIP_V) == static_cast(::android::hardware::graphics::common::V1_0::Transform::FLIP_V)) { - os += (first ? "" : " | "); - os += "FLIP_V"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::FLIP_V; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_90) == static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_90)) { - os += (first ? "" : " | "); - os += "ROT_90"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_90; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_180) == static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_180)) { - os += (first ? "" : " | "); - os += "ROT_180"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_180; - } - if ((o & ::android::hardware::graphics::common::V1_0::Transform::ROT_270) == static_cast(::android::hardware::graphics::common::V1_0::Transform::ROT_270)) { - os += (first ? "" : " | "); - os += "ROT_270"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Transform::ROT_270; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::Transform o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::Transform::FLIP_H) { - return "FLIP_H"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::FLIP_V) { - return "FLIP_V"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_90) { - return "ROT_90"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_180) { - return "ROT_180"; - } - if (o == ::android::hardware::graphics::common::V1_0::Transform::ROT_270) { - return "ROT_270"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::Dataspace>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Dataspace> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN)) { - os += (first ? "" : " | "); - os += "UNKNOWN"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY)) { - os += (first ? "" : " | "); - os += "ARBITRARY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT)) { - os += (first ? "" : " | "); - os += "STANDARD_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK)) { - os += (first ? "" : " | "); - os += "STANDARD_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "STANDARD_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709)) { - os += (first ? "" : " | "); - os += "STANDARD_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625_UNADJUSTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525_UNADJUSTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020)) { - os += (first ? "" : " | "); - os += "STANDARD_BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE)) { - os += (first ? "" : " | "); - os += "STANDARD_BT2020_CONSTANT_LUMINANCE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M)) { - os += (first ? "" : " | "); - os += "STANDARD_BT470M"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM)) { - os += (first ? "" : " | "); - os += "STANDARD_FILM"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3)) { - os += (first ? "" : " | "); - os += "STANDARD_DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "STANDARD_ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT)) { - os += (first ? "" : " | "); - os += "TRANSFER_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK)) { - os += (first ? "" : " | "); - os += "TRANSFER_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "TRANSFER_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR)) { - os += (first ? "" : " | "); - os += "TRANSFER_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB)) { - os += (first ? "" : " | "); - os += "TRANSFER_SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M)) { - os += (first ? "" : " | "); - os += "TRANSFER_SMPTE_170M"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_2"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_6"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8)) { - os += (first ? "" : " | "); - os += "TRANSFER_GAMMA2_8"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084)) { - os += (first ? "" : " | "); - os += "TRANSFER_ST2084"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG)) { - os += (first ? "" : " | "); - os += "TRANSFER_HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT)) { - os += (first ? "" : " | "); - os += "RANGE_SHIFT"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK)) { - os += (first ? "" : " | "); - os += "RANGE_MASK"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED)) { - os += (first ? "" : " | "); - os += "RANGE_UNSPECIFIED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL)) { - os += (first ? "" : " | "); - os += "RANGE_FULL"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED)) { - os += (first ? "" : " | "); - os += "RANGE_LIMITED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED)) { - os += (first ? "" : " | "); - os += "RANGE_EXTENDED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "SRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "V0_SRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR)) { - os += (first ? "" : " | "); - os += "V0_SCRGB_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SRGB) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SRGB)) { - os += (first ? "" : " | "); - os += "SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB)) { - os += (first ? "" : " | "); - os += "V0_SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB)) { - os += (first ? "" : " | "); - os += "V0_SCRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::JFIF) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::JFIF)) { - os += (first ? "" : " | "); - os += "JFIF"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::JFIF; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF)) { - os += (first ? "" : " | "); - os += "V0_JFIF"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT601_625)) { - os += (first ? "" : " | "); - os += "BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625)) { - os += (first ? "" : " | "); - os += "V0_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT601_525)) { - os += (first ? "" : " | "); - os += "BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525)) { - os += (first ? "" : " | "); - os += "V0_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT709) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT709)) { - os += (first ? "" : " | "); - os += "BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709)) { - os += (first ? "" : " | "); - os += "V0_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR)) { - os += (first ? "" : " | "); - os += "DCI_P3_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3)) { - os += (first ? "" : " | "); - os += "DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR)) { - os += (first ? "" : " | "); - os += "BT2020_LINEAR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020)) { - os += (first ? "" : " | "); - os += "BT2020"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ)) { - os += (first ? "" : " | "); - os += "BT2020_PQ"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::DEPTH)) { - os += (first ? "" : " | "); - os += "DEPTH"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH; - } - if ((o & ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR) == static_cast(::android::hardware::graphics::common::V1_0::Dataspace::SENSOR)) { - os += (first ? "" : " | "); - os += "SENSOR"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::Dataspace o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN) { - return "UNKNOWN"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY) { - return "ARBITRARY"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT) { - return "STANDARD_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK) { - return "STANDARD_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED) { - return "STANDARD_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709) { - return "STANDARD_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625) { - return "STANDARD_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED) { - return "STANDARD_BT601_625_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525) { - return "STANDARD_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED) { - return "STANDARD_BT601_525_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020) { - return "STANDARD_BT2020"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE) { - return "STANDARD_BT2020_CONSTANT_LUMINANCE"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M) { - return "STANDARD_BT470M"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM) { - return "STANDARD_FILM"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3) { - return "STANDARD_DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB) { - return "STANDARD_ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT) { - return "TRANSFER_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK) { - return "TRANSFER_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED) { - return "TRANSFER_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR) { - return "TRANSFER_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB) { - return "TRANSFER_SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M) { - return "TRANSFER_SMPTE_170M"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2) { - return "TRANSFER_GAMMA2_2"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6) { - return "TRANSFER_GAMMA2_6"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8) { - return "TRANSFER_GAMMA2_8"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084) { - return "TRANSFER_ST2084"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG) { - return "TRANSFER_HLG"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT) { - return "RANGE_SHIFT"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK) { - return "RANGE_MASK"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED) { - return "RANGE_UNSPECIFIED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL) { - return "RANGE_FULL"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED) { - return "RANGE_LIMITED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED) { - return "RANGE_EXTENDED"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR) { - return "SRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR) { - return "V0_SRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR) { - return "V0_SCRGB_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SRGB) { - return "SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB) { - return "V0_SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB) { - return "V0_SCRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::JFIF) { - return "JFIF"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF) { - return "V0_JFIF"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625) { - return "BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625) { - return "V0_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525) { - return "BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525) { - return "V0_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT709) { - return "BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709) { - return "V0_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR) { - return "DCI_P3_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3) { - return "DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR) { - return "DISPLAY_P3_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3) { - return "DISPLAY_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB) { - return "ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR) { - return "BT2020_LINEAR"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020) { - return "BT2020"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ) { - return "BT2020_PQ"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH) { - return "DEPTH"; - } - if (o == ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR) { - return "SENSOR"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::ColorMode>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::ColorMode> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::NATIVE)) { - os += (first ? "" : " | "); - os += "NATIVE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_625_UNADJUSTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED)) { - os += (first ? "" : " | "); - os += "STANDARD_BT601_525_UNADJUSTED"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709)) { - os += (first ? "" : " | "); - os += "STANDARD_BT709"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3)) { - os += (first ? "" : " | "); - os += "DCI_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::SRGB) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::SRGB)) { - os += (first ? "" : " | "); - os += "SRGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::SRGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB)) { - os += (first ? "" : " | "); - os += "ADOBE_RGB"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3) == static_cast(::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3)) { - os += (first ? "" : " | "); - os += "DISPLAY_P3"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorMode o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE) { - return "NATIVE"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625) { - return "STANDARD_BT601_625"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED) { - return "STANDARD_BT601_625_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525) { - return "STANDARD_BT601_525"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED) { - return "STANDARD_BT601_525_UNADJUSTED"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709) { - return "STANDARD_BT709"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3) { - return "DCI_P3"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::SRGB) { - return "SRGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB) { - return "ADOBE_RGB"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3) { - return "DISPLAY_P3"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::ColorTransform>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::ColorTransform> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY)) { - os += (first ? "" : " | "); - os += "IDENTITY"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX)) { - os += (first ? "" : " | "); - os += "ARBITRARY_MATRIX"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE)) { - os += (first ? "" : " | "); - os += "VALUE_INVERSE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE)) { - os += (first ? "" : " | "); - os += "GRAYSCALE"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA)) { - os += (first ? "" : " | "); - os += "CORRECT_PROTANOPIA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA)) { - os += (first ? "" : " | "); - os += "CORRECT_DEUTERANOPIA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA; - } - if ((o & ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA) == static_cast(::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA)) { - os += (first ? "" : " | "); - os += "CORRECT_TRITANOPIA"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::ColorTransform o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY) { - return "IDENTITY"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX) { - return "ARBITRARY_MATRIX"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE) { - return "VALUE_INVERSE"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE) { - return "GRAYSCALE"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA) { - return "CORRECT_PROTANOPIA"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA) { - return "CORRECT_DEUTERANOPIA"; - } - if (o == ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA) { - return "CORRECT_TRITANOPIA"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::android::hardware::graphics::common::V1_0::Hdr>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::common::V1_0::Hdr> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION) == static_cast(::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION)) { - os += (first ? "" : " | "); - os += "DOLBY_VISION"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION; - } - if ((o & ::android::hardware::graphics::common::V1_0::Hdr::HDR10) == static_cast(::android::hardware::graphics::common::V1_0::Hdr::HDR10)) { - os += (first ? "" : " | "); - os += "HDR10"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Hdr::HDR10; - } - if ((o & ::android::hardware::graphics::common::V1_0::Hdr::HLG) == static_cast(::android::hardware::graphics::common::V1_0::Hdr::HLG)) { - os += (first ? "" : " | "); - os += "HLG"; - first = false; - flipped |= ::android::hardware::graphics::common::V1_0::Hdr::HLG; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::common::V1_0::Hdr o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION) { - return "DOLBY_VISION"; - } - if (o == ::android::hardware::graphics::common::V1_0::Hdr::HDR10) { - return "HDR10"; - } - if (o == ::android::hardware::graphics::common::V1_0::Hdr::HLG) { - return "HLG"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - - -} // namespace V1_0 -} // namespace common -} // namespace graphics -} // namespace hardware -} // namespace android - -// -// global type declarations for package -// - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::PixelFormat, 20> hidl_enum_values<::android::hardware::graphics::common::V1_0::PixelFormat> = { - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_8888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBX_8888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGB_565, - ::android::hardware::graphics::common::V1_0::PixelFormat::BGRA_8888, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_SP, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCRCB_420_SP, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_422_I, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_FP16, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW16, - ::android::hardware::graphics::common::V1_0::PixelFormat::BLOB, - ::android::hardware::graphics::common::V1_0::PixelFormat::IMPLEMENTATION_DEFINED, - ::android::hardware::graphics::common::V1_0::PixelFormat::YCBCR_420_888, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW_OPAQUE, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW10, - ::android::hardware::graphics::common::V1_0::PixelFormat::RAW12, - ::android::hardware::graphics::common::V1_0::PixelFormat::RGBA_1010102, - ::android::hardware::graphics::common::V1_0::PixelFormat::Y8, - ::android::hardware::graphics::common::V1_0::PixelFormat::Y16, - ::android::hardware::graphics::common::V1_0::PixelFormat::YV12, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::BufferUsage, 23> hidl_enum_values<::android::hardware::graphics::common::V1_0::BufferUsage> = { - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_MASK, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_NEVER, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_RARELY, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_READ_OFTEN, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_MASK, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_NEVER, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_RARELY, - ::android::hardware::graphics::common::V1_0::BufferUsage::CPU_WRITE_OFTEN, - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_TEXTURE, - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_RENDER_TARGET, - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_OVERLAY, - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CLIENT_TARGET, - ::android::hardware::graphics::common::V1_0::BufferUsage::PROTECTED, - ::android::hardware::graphics::common::V1_0::BufferUsage::COMPOSER_CURSOR, - ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_ENCODER, - ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_OUTPUT, - ::android::hardware::graphics::common::V1_0::BufferUsage::CAMERA_INPUT, - ::android::hardware::graphics::common::V1_0::BufferUsage::RENDERSCRIPT, - ::android::hardware::graphics::common::V1_0::BufferUsage::VIDEO_DECODER, - ::android::hardware::graphics::common::V1_0::BufferUsage::SENSOR_DIRECT_DATA, - ::android::hardware::graphics::common::V1_0::BufferUsage::GPU_DATA_BUFFER, - ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK, - ::android::hardware::graphics::common::V1_0::BufferUsage::VENDOR_MASK_HI, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::Transform, 5> hidl_enum_values<::android::hardware::graphics::common::V1_0::Transform> = { - ::android::hardware::graphics::common::V1_0::Transform::FLIP_H, - ::android::hardware::graphics::common::V1_0::Transform::FLIP_V, - ::android::hardware::graphics::common::V1_0::Transform::ROT_90, - ::android::hardware::graphics::common::V1_0::Transform::ROT_180, - ::android::hardware::graphics::common::V1_0::Transform::ROT_270, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::Dataspace, 57> hidl_enum_values<::android::hardware::graphics::common::V1_0::Dataspace> = { - ::android::hardware::graphics::common::V1_0::Dataspace::UNKNOWN, - ::android::hardware::graphics::common::V1_0::Dataspace::ARBITRARY, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_SHIFT, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_MASK, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_UNSPECIFIED, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT709, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_625_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT601_525_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT2020_CONSTANT_LUMINANCE, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_BT470M, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_FILM, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_DCI_P3, - ::android::hardware::graphics::common::V1_0::Dataspace::STANDARD_ADOBE_RGB, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SHIFT, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_MASK, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_UNSPECIFIED, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_SMPTE_170M, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_2, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_6, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_GAMMA2_8, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_ST2084, - ::android::hardware::graphics::common::V1_0::Dataspace::TRANSFER_HLG, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_SHIFT, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_MASK, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_UNSPECIFIED, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_FULL, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_LIMITED, - ::android::hardware::graphics::common::V1_0::Dataspace::RANGE_EXTENDED, - ::android::hardware::graphics::common::V1_0::Dataspace::SRGB_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::SRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_SCRGB, - ::android::hardware::graphics::common::V1_0::Dataspace::JFIF, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_JFIF, - ::android::hardware::graphics::common::V1_0::Dataspace::BT601_625, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_625, - ::android::hardware::graphics::common::V1_0::Dataspace::BT601_525, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT601_525, - ::android::hardware::graphics::common::V1_0::Dataspace::BT709, - ::android::hardware::graphics::common::V1_0::Dataspace::V0_BT709, - ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::DCI_P3, - ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::DISPLAY_P3, - ::android::hardware::graphics::common::V1_0::Dataspace::ADOBE_RGB, - ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_LINEAR, - ::android::hardware::graphics::common::V1_0::Dataspace::BT2020, - ::android::hardware::graphics::common::V1_0::Dataspace::BT2020_PQ, - ::android::hardware::graphics::common::V1_0::Dataspace::DEPTH, - ::android::hardware::graphics::common::V1_0::Dataspace::SENSOR, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::ColorMode, 10> hidl_enum_values<::android::hardware::graphics::common::V1_0::ColorMode> = { - ::android::hardware::graphics::common::V1_0::ColorMode::NATIVE, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_625_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT601_525_UNADJUSTED, - ::android::hardware::graphics::common::V1_0::ColorMode::STANDARD_BT709, - ::android::hardware::graphics::common::V1_0::ColorMode::DCI_P3, - ::android::hardware::graphics::common::V1_0::ColorMode::SRGB, - ::android::hardware::graphics::common::V1_0::ColorMode::ADOBE_RGB, - ::android::hardware::graphics::common::V1_0::ColorMode::DISPLAY_P3, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::ColorTransform, 7> hidl_enum_values<::android::hardware::graphics::common::V1_0::ColorTransform> = { - ::android::hardware::graphics::common::V1_0::ColorTransform::IDENTITY, - ::android::hardware::graphics::common::V1_0::ColorTransform::ARBITRARY_MATRIX, - ::android::hardware::graphics::common::V1_0::ColorTransform::VALUE_INVERSE, - ::android::hardware::graphics::common::V1_0::ColorTransform::GRAYSCALE, - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_PROTANOPIA, - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_DEUTERANOPIA, - ::android::hardware::graphics::common::V1_0::ColorTransform::CORRECT_TRITANOPIA, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::common::V1_0::Hdr, 3> hidl_enum_values<::android::hardware::graphics::common::V1_0::Hdr> = { - ::android::hardware::graphics::common::V1_0::Hdr::DOLBY_VISION, - ::android::hardware::graphics::common::V1_0::Hdr::HDR10, - ::android::hardware::graphics::common::V1_0::Hdr::HLG, -}; -} // namespace details -} // namespace hardware -} // namespace android - - -#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_COMMON_V1_0_TYPES_H diff --git a/tools/qtimapper-shim/ext_headers/types/mapper.h b/tools/qtimapper-shim/ext_headers/types/mapper.h deleted file mode 100644 index 93c82e2..0000000 --- a/tools/qtimapper-shim/ext_headers/types/mapper.h +++ /dev/null @@ -1,231 +0,0 @@ -#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H -#define HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace graphics { -namespace mapper { -namespace V2_0 { - -// Forward declaration for forward reference support: -enum class Error : int32_t; -struct YCbCrLayout; - -enum class Error : int32_t { - NONE = 0, - BAD_DESCRIPTOR = 1, - BAD_BUFFER = 2, - BAD_VALUE = 3, - NO_RESOURCES = 5, - UNSUPPORTED = 7, -}; - -/** - * A buffer descriptor is an implementation-defined opaque data returned by - * createDescriptor. It describes the properties of a buffer and is consumed - * by the allocator. - */ -typedef ::android::hardware::hidl_vec BufferDescriptor; - -/** - * Structure for describing YCbCr formats for consumption by applications. - * This is used with PixelFormat::YCBCR_*_888. - * - * Buffer chroma subsampling is defined in the format. - * e.g. PixelFormat::YCBCR_420_888 has subsampling 4:2:0. - * - * Buffers must have a 8 bit depth. - * - * y, cb, and cr point to the first byte of their respective planes. - * - * Stride describes the distance in bytes from the first value of one row of - * the image to the first value of the next row. It includes the width of the - * image plus padding. - * yStride is the stride of the luma plane. - * cStride is the stride of the chroma planes. - * - * chromaStep is the distance in bytes from one chroma pixel value to the - * next. This is 2 bytes for semiplanar (because chroma values are interleaved - * and each chroma value is one byte) and 1 for planar. - */ -struct YCbCrLayout final { - void* y; - void* cb; - void* cr; - uint32_t yStride; - uint32_t cStride; - uint32_t chromaStep; -}; - -// -// type declarations for package -// - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::android::hardware::graphics::mapper::V2_0::Error o); - -constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::android::hardware::graphics::mapper::V2_0::Error rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::android::hardware::graphics::mapper::V2_0::Error lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::android::hardware::graphics::mapper::V2_0::Error e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::android::hardware::graphics::mapper::V2_0::Error e) { - v &= static_cast(e); - return v; -} - -static inline std::string toString(const ::android::hardware::graphics::mapper::V2_0::YCbCrLayout& o); -// operator== and operator!= are not generated for YCbCrLayout - -// -// type header definitions for package -// - -template<> -inline std::string toString<::android::hardware::graphics::mapper::V2_0::Error>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::android::hardware::graphics::mapper::V2_0::Error> flipped = 0; - bool first = true; - if ((o & ::android::hardware::graphics::mapper::V2_0::Error::NONE) == static_cast(::android::hardware::graphics::mapper::V2_0::Error::NONE)) { - os += (first ? "" : " | "); - os += "NONE"; - first = false; - flipped |= ::android::hardware::graphics::mapper::V2_0::Error::NONE; - } - if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR) == static_cast(::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR)) { - os += (first ? "" : " | "); - os += "BAD_DESCRIPTOR"; - first = false; - flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR; - } - if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER) == static_cast(::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER)) { - os += (first ? "" : " | "); - os += "BAD_BUFFER"; - first = false; - flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER; - } - if ((o & ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE) == static_cast(::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE)) { - os += (first ? "" : " | "); - os += "BAD_VALUE"; - first = false; - flipped |= ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE; - } - if ((o & ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES) == static_cast(::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES)) { - os += (first ? "" : " | "); - os += "NO_RESOURCES"; - first = false; - flipped |= ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES; - } - if ((o & ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED) == static_cast(::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED)) { - os += (first ? "" : " | "); - os += "UNSUPPORTED"; - first = false; - flipped |= ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::android::hardware::graphics::mapper::V2_0::Error o) { - using ::android::hardware::details::toHexString; - if (o == ::android::hardware::graphics::mapper::V2_0::Error::NONE) { - return "NONE"; - } - if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR) { - return "BAD_DESCRIPTOR"; - } - if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER) { - return "BAD_BUFFER"; - } - if (o == ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE) { - return "BAD_VALUE"; - } - if (o == ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES) { - return "NO_RESOURCES"; - } - if (o == ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED) { - return "UNSUPPORTED"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -static inline std::string toString(const ::android::hardware::graphics::mapper::V2_0::YCbCrLayout& o) { - using ::android::hardware::toString; - std::string os; - os += "{"; - os += ".y = "; - os += ::android::hardware::toString(o.y); - os += ", .cb = "; - os += ::android::hardware::toString(o.cb); - os += ", .cr = "; - os += ::android::hardware::toString(o.cr); - os += ", .yStride = "; - os += ::android::hardware::toString(o.yStride); - os += ", .cStride = "; - os += ::android::hardware::toString(o.cStride); - os += ", .chromaStep = "; - os += ::android::hardware::toString(o.chromaStep); - os += "}"; return os; -} - -// operator== and operator!= are not generated for YCbCrLayout - - -} // namespace V2_0 -} // namespace mapper -} // namespace graphics -} // namespace hardware -} // namespace android - -// -// global type declarations for package -// - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::android::hardware::graphics::mapper::V2_0::Error, 6> hidl_enum_values<::android::hardware::graphics::mapper::V2_0::Error> = { - ::android::hardware::graphics::mapper::V2_0::Error::NONE, - ::android::hardware::graphics::mapper::V2_0::Error::BAD_DESCRIPTOR, - ::android::hardware::graphics::mapper::V2_0::Error::BAD_BUFFER, - ::android::hardware::graphics::mapper::V2_0::Error::BAD_VALUE, - ::android::hardware::graphics::mapper::V2_0::Error::NO_RESOURCES, - ::android::hardware::graphics::mapper::V2_0::Error::UNSUPPORTED, -}; -} // namespace details -} // namespace hardware -} // namespace android - - -#endif // HIDL_GENERATED_ANDROID_HARDWARE_GRAPHICS_MAPPER_V2_0_TYPES_H diff --git a/tools/qtimapper-shim/ext_headers/types/mapperextensions.h b/tools/qtimapper-shim/ext_headers/types/mapperextensions.h deleted file mode 100644 index 1f18308..0000000 --- a/tools/qtimapper-shim/ext_headers/types/mapperextensions.h +++ /dev/null @@ -1,553 +0,0 @@ -#ifndef HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H -#define HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H - -#include -#include -#include -#include - -namespace vendor { -namespace qti { -namespace hardware { -namespace display { -namespace mapperextensions { -namespace V1_0 { - -// Forward declaration for forward reference support: -enum class Error : int32_t; -struct YCbCrLayout; -enum class PlaneComponent : uint32_t; -enum class Flags : int32_t; -struct PlaneLayout; - -enum class Error : int32_t { - NONE = 0, - BAD_BUFFER = 2, - NO_RESOURCES = 5, - UNSUPPORTED = 7, -}; - -struct YCbCrLayout final { - void* y; - void* cb; - void* cr; - uint32_t yStride; - uint32_t cStride; - uint32_t chromaStep; -}; - -/** - * Plane Component type definitions. - */ -enum class PlaneComponent : uint32_t { - PLANE_COMPONENT_Y = 1u /* (1 << 0) */, - PLANE_COMPONENT_Cb = 2u /* (1 << 1) */, - PLANE_COMPONENT_Cr = 4u /* (1 << 2) */, - PLANE_COMPONENT_R = 1024u /* (1 << 10) */, - PLANE_COMPONENT_G = 2048u /* (1 << 11) */, - PLANE_COMPONENT_B = 4096u /* (1 << 12) */, - PLANE_COMPONENT_A = 1048576u /* (1 << 20) */, - PLANE_COMPONENT_RAW = 1073741824u /* (1 << 30) */, - PLANE_COMPONENT_META = 2147483648u /* (1 << 31) */, -}; - -/** - * Flags to send with getFormatLayout for extra information for e.g. interlaced, - * otherwise send 0. - */ -enum class Flags : int32_t { - LAYOUT_INTERLACED_FLAG = 1 /* (1 << 0) */, -}; - -/** - * Structure for describing plane layout information for YUVA/RGBA/RAW formats - * YUV formats can be planar or semi-planar. - * - * This layout structure is used with any pixel format that can be - * represented by it, such as: - * - HAL_PIXEL_FORMAT_YCbCr_* - * - HAL_PIXEL_FORMAT_RGB*_* - * - even implementation defined formats that can be represented by - * the structures - * - * Each plane can be made up of one or more PlaneComponents depending on - * the format. - * - * Each plane can be subsampled either vertically or horizontally by - * a power-of-two factor. - * - * Pixel increment describes the distance in bytes from one pixel to the - * next pixel (to the right) on the same row for the component plane. - * This can be negative. - * - * Stride is provided in both pixels and bytes. - * Stride_bytes describes the distance in bytes from the first pixel of - * one row to the first pixel of the next row (below) for the component plane. - * This can be negative. - * - * Scanlines describes the height of the plane in terms of number of rows. - * - * Size of plane is stride_bytes * scanlines + any padding required for - * alignment as per format specification. - * - */ -struct PlaneLayout final { - ::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> component __attribute__ ((aligned(4))); - uint32_t h_subsampling __attribute__ ((aligned(4))); - uint32_t v_subsampling __attribute__ ((aligned(4))); - uint32_t offset __attribute__ ((aligned(4))); - int32_t pixel_increment __attribute__ ((aligned(4))); - int32_t stride __attribute__ ((aligned(4))); - int32_t stride_bytes __attribute__ ((aligned(4))); - int32_t scanlines __attribute__ ((aligned(4))); - uint32_t size __attribute__ ((aligned(4))); -}; - -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, component) == 0, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, h_subsampling) == 4, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, v_subsampling) == 8, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, offset) == 12, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, pixel_increment) == 16, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, stride) == 20, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, stride_bytes) == 24, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, scanlines) == 28, "wrong offset"); -static_assert(offsetof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout, size) == 32, "wrong offset"); -static_assert(sizeof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout) == 36, "wrong size"); -static_assert(__alignof(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout) == 4, "wrong alignment"); - -// -// type declarations for package -// - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Error o); - -constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Error e) { - v &= static_cast(e); - return v; -} - -static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout& o); -// operator== and operator!= are not generated for YCbCrLayout - -template -static inline std::string toString(uint32_t o); -static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent o); - -constexpr uint32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr uint32_t operator|(const uint32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr uint32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const uint32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr uint32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr uint32_t operator&(const uint32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr uint32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent lhs, const uint32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr uint32_t &operator|=(uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) { - v |= static_cast(e); - return v; -} -constexpr uint32_t &operator&=(uint32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent e) { - v &= static_cast(e); - return v; -} - -template -static inline std::string toString(int32_t o); -static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags o); - -constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { - return static_cast(static_cast(lhs) | static_cast(rhs)); -} -constexpr int32_t operator|(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { - return static_cast(lhs | static_cast(rhs)); -} -constexpr int32_t operator|(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) | rhs); -} -constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { - return static_cast(static_cast(lhs) & static_cast(rhs)); -} -constexpr int32_t operator&(const int32_t lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags rhs) { - return static_cast(lhs & static_cast(rhs)); -} -constexpr int32_t operator&(const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags lhs, const int32_t rhs) { - return static_cast(static_cast(lhs) & rhs); -} -constexpr int32_t &operator|=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) { - v |= static_cast(e); - return v; -} -constexpr int32_t &operator&=(int32_t& v, const ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags e) { - v &= static_cast(e); - return v; -} - -static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& o); -static inline bool operator==(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs); -static inline bool operator!=(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs); - -// -// type header definitions for package -// - -template<> -inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::Error>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> flipped = 0; - bool first = true; - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE)) { - os += (first ? "" : " | "); - os += "NONE"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER)) { - os += (first ? "" : " | "); - os += "BAD_BUFFER"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES)) { - os += (first ? "" : " | "); - os += "NO_RESOURCES"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED)) { - os += (first ? "" : " | "); - os += "UNSUPPORTED"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Error o) { - using ::android::hardware::details::toHexString; - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE) { - return "NONE"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER) { - return "BAD_BUFFER"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES) { - return "NO_RESOURCES"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED) { - return "UNSUPPORTED"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::YCbCrLayout& o) { - using ::android::hardware::toString; - std::string os; - os += "{"; - os += ".y = "; - os += ::android::hardware::toString(o.y); - os += ", .cb = "; - os += ::android::hardware::toString(o.cb); - os += ", .cr = "; - os += ::android::hardware::toString(o.cr); - os += ", .yStride = "; - os += ::android::hardware::toString(o.yStride); - os += ", .cStride = "; - os += ::android::hardware::toString(o.cStride); - os += ", .chromaStep = "; - os += ::android::hardware::toString(o.chromaStep); - os += "}"; return os; -} - -// operator== and operator!= are not generated for YCbCrLayout - -template<> -inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent>(uint32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> flipped = 0; - bool first = true; - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_Y"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_Cb"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_Cr"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_R"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_G"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_B"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_A"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_RAW"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW; - } - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META)) { - os += (first ? "" : " | "); - os += "PLANE_COMPONENT_META"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent o) { - using ::android::hardware::details::toHexString; - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y) { - return "PLANE_COMPONENT_Y"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb) { - return "PLANE_COMPONENT_Cb"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr) { - return "PLANE_COMPONENT_Cr"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R) { - return "PLANE_COMPONENT_R"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G) { - return "PLANE_COMPONENT_G"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B) { - return "PLANE_COMPONENT_B"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A) { - return "PLANE_COMPONENT_A"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW) { - return "PLANE_COMPONENT_RAW"; - } - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META) { - return "PLANE_COMPONENT_META"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -template<> -inline std::string toString<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags>(int32_t o) { - using ::android::hardware::details::toHexString; - std::string os; - ::android::hardware::hidl_bitfield<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags> flipped = 0; - bool first = true; - if ((o & ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG) == static_cast(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG)) { - os += (first ? "" : " | "); - os += "LAYOUT_INTERLACED_FLAG"; - first = false; - flipped |= ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG; - } - if (o != flipped) { - os += (first ? "" : " | "); - os += toHexString(o & (~flipped)); - }os += " ("; - os += toHexString(o); - os += ")"; - return os; -} - -static inline std::string toString(::vendor::qti::hardware::display::mapperextensions::V1_0::Flags o) { - using ::android::hardware::details::toHexString; - if (o == ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG) { - return "LAYOUT_INTERLACED_FLAG"; - } - std::string os; - os += toHexString(static_cast(o)); - return os; -} - -static inline std::string toString(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& o) { - using ::android::hardware::toString; - std::string os; - os += "{"; - os += ".component = "; - os += ::vendor::qti::hardware::display::mapperextensions::V1_0::toString<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent>(o.component); - os += ", .h_subsampling = "; - os += ::android::hardware::toString(o.h_subsampling); - os += ", .v_subsampling = "; - os += ::android::hardware::toString(o.v_subsampling); - os += ", .offset = "; - os += ::android::hardware::toString(o.offset); - os += ", .pixel_increment = "; - os += ::android::hardware::toString(o.pixel_increment); - os += ", .stride = "; - os += ::android::hardware::toString(o.stride); - os += ", .stride_bytes = "; - os += ::android::hardware::toString(o.stride_bytes); - os += ", .scanlines = "; - os += ::android::hardware::toString(o.scanlines); - os += ", .size = "; - os += ::android::hardware::toString(o.size); - os += "}"; return os; -} - -static inline bool operator==(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs) { - if (lhs.component != rhs.component) { - return false; - } - if (lhs.h_subsampling != rhs.h_subsampling) { - return false; - } - if (lhs.v_subsampling != rhs.v_subsampling) { - return false; - } - if (lhs.offset != rhs.offset) { - return false; - } - if (lhs.pixel_increment != rhs.pixel_increment) { - return false; - } - if (lhs.stride != rhs.stride) { - return false; - } - if (lhs.stride_bytes != rhs.stride_bytes) { - return false; - } - if (lhs.scanlines != rhs.scanlines) { - return false; - } - if (lhs.size != rhs.size) { - return false; - } - return true; -} - -static inline bool operator!=(const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& lhs, const ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneLayout& rhs){ - return !(lhs == rhs); -} - - -} // namespace V1_0 -} // namespace mapperextensions -} // namespace display -} // namespace hardware -} // namespace qti -} // namespace vendor - -// -// global type declarations for package -// - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::Error, 4> hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::Error> = { - ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NONE, - ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::BAD_BUFFER, - ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::NO_RESOURCES, - ::vendor::qti::hardware::display::mapperextensions::V1_0::Error::UNSUPPORTED, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent, 9> hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent> = { - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Y, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cb, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_Cr, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_R, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_G, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_B, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_A, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_RAW, - ::vendor::qti::hardware::display::mapperextensions::V1_0::PlaneComponent::PLANE_COMPONENT_META, -}; -} // namespace details -} // namespace hardware -} // namespace android - -namespace android { -namespace hardware { -namespace details { -template<> constexpr std::array<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags, 1> hidl_enum_values<::vendor::qti::hardware::display::mapperextensions::V1_0::Flags> = { - ::vendor::qti::hardware::display::mapperextensions::V1_0::Flags::LAYOUT_INTERLACED_FLAG, -}; -} // namespace details -} // namespace hardware -} // namespace android - - -#endif // HIDL_GENERATED_VENDOR_QTI_HARDWARE_DISPLAY_MAPPEREXTENSIONS_V1_0_TYPES_H diff --git a/tools/qtimapper-shim/shim.cpp b/tools/qtimapper-shim/shim.cpp index 8130e6c..d9dc943 100644 --- a/tools/qtimapper-shim/shim.cpp +++ b/tools/qtimapper-shim/shim.cpp @@ -29,265 +29,348 @@ #define LOG_TAG "qtimapper-shim" +#include #include #include #include +#include #include #include -#include -#include -#include "ext_headers/common.h" -#include "ext_headers/mapper.h" -#include "ext_headers/mapperextensions.h" + +#define SHIM_MODE 1 + +#include "ext/common.h" +#include "ext/gr_utils.h" +#include "ext/mapper.h" +#include "ext/mapperextensions.h" using namespace android::hardware; using namespace android; bool IBase::isRemote() const { - return false; + return false; } namespace android::hardware::graphics::mapper { namespace V2_0 { -sp IMapper::getService(const std::string &/* serviceName */, const bool /* getStub */) { - return nullptr; +sp IMapper::getService(const std::string& /* serviceName */, const bool /* getStub */) { + return nullptr; } -} +} // namespace V2_0 namespace V3_0 { -sp IMapper::getService(const std::string &/* serviceName */, const bool /* getStub */) { - return nullptr; +sp IMapper::getService(const std::string& /* serviceName */, const bool /* getStub */) { + return nullptr; } -} +} // namespace V3_0 namespace V4_0 { -sp IMapper::getService(const std::string &/* serviceName */, const bool /* getStub */) { - return nullptr; +sp IMapper::getService(const std::string& /* serviceName */, const bool /* getStub */) { + return nullptr; } -} -} +} // namespace V4_0 +} // namespace android::hardware::graphics::mapper namespace vendor::qti::hardware::display { namespace mapper { namespace V4_0 { -Return> IQtiMapper::castFrom(const sp &/* parent */, bool /* emitV1_0::Error */) { - return nullptr; +Return> IQtiMapper::castFrom(const sp& /* parent */, + bool /* emitError */) { + return nullptr; } -} +} // namespace V4_0 namespace V3_0 { -Return> IQtiMapper::castFrom(const sp &/* parent */, bool /* emitV1_0::Error */) { - return nullptr; +Return> IQtiMapper::castFrom(const sp& /* parent */, + bool /* emitError */) { + return nullptr; } -} +} // namespace V3_0 namespace V2_0 { -Return> IQtiMapper::castFrom(const sp &/* parent */, bool /* emitV1_0::Error */) { - return new IQtiMapper(); +Return> IQtiMapper::castFrom(const sp& /* parent */, + bool /* emitError */) { + return new IQtiMapper(); } Return IQtiMapper::getMapperExtensions(getMapperExtensions_cb _hidl_cb) { - sp ext{new mapperextensions::V1_0::IQtiMapperExtensions()}; - _hidl_cb(graphics::mapper::V2_0::Error::NONE, ext); - ALOGD("IQtiMapperExtensions shim active"); - return Void(); + sp ext{ + new mapperextensions::V1_0::IQtiMapperExtensions()}; + _hidl_cb(graphics::mapper::V2_0::Error::NONE, ext); + ALOGD("IQtiMapperExtensions shim active"); + return Void(); } -} -} +} // namespace V2_0 +} // namespace mapper namespace mapperextensions { namespace V1_1 { IQtiMapperExtensions::IQtiMapperExtensions() { - hw_module_t const *module; - if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module)) { - ALOGE("Failed to open gralloc module!"); - std::terminate(); - } + hw_module_t const* module; + if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module)) { + ALOGE("Failed to open gralloc module!"); + std::terminate(); + } - if (gralloc1_open(module, &gralloc)) { - ALOGE("Failed to open gralloc HAL!"); - std::terminate(); - } + if (gralloc1_open(module, &gralloc)) { + ALOGE("Failed to open gralloc HAL!"); + std::terminate(); + } - perform = reinterpret_cast(gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM)); - if (!perform) { - ALOGE("Failed to get gralloc perform helper!"); - std::terminate(); - } + perform = reinterpret_cast( + gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM)); + if (!perform) { + ALOGE("Failed to get gralloc perform helper!"); + std::terminate(); + } - ALOGD("Opened gralloc1 HAL"); + ALOGD("Opened gralloc1 HAL"); } - -Return> IQtiMapperExtensions::castFrom(android::sp const& /* parent */, bool /* emitV1_0::Error */) { - return new IQtiMapperExtensions(); +Return> IQtiMapperExtensions::castFrom( + android::sp const& /* parent */, bool /* emitError */) { + return new IQtiMapperExtensions(); } -Return IQtiMapperExtensions::getRgbDataAddress(void *buffer, getRgbDataAddress_cb _hidl_cb) { - void *rgb_data = nullptr; - auto err = perform(gralloc, GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS, buffer, &rgb_data) ? V1_0::Error::NONE : V1_0::Error::BAD_BUFFER; - _hidl_cb(err, rgb_data); - return Void(); +Return IQtiMapperExtensions::getRgbDataAddress(void* buffer, getRgbDataAddress_cb _hidl_cb) { + void* rgb_data = nullptr; + + auto err = perform(gralloc, GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS, buffer, &rgb_data) + ? Error::BAD_BUFFER + : Error::NONE; + _hidl_cb(err, rgb_data); + + ALOGE("%s: err: %d rgb_data: %p", __func__, err, rgb_data); + return Void(); } Return IQtiMapperExtensions::getInterlacedFlag(void* buffer, getInterlacedFlag_cb _hidl_cb) { - int flag = 0; - auto perform = reinterpret_cast(gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM)); - auto err = perform(gralloc, GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG, buffer, &flag) ? V1_0::Error::NONE : V1_0::Error::BAD_BUFFER; - _hidl_cb(err, flag); - return Void(); + int flag = 0; + auto perform = reinterpret_cast( + gralloc->getFunction(gralloc, GRALLOC1_FUNCTION_PERFORM)); + auto err = perform(gralloc, GRALLOC1_MODULE_PERFORM_GET_INTERLACE_FLAG, buffer, &flag) + ? Error::BAD_BUFFER + : Error::NONE; + _hidl_cb(err, flag); + ALOGE("%s: err: %d flag: %d", __func__, err, flag); + return Void(); } -Return IQtiMapperExtensions::getFd(void *buffer, getFd_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getFd(void* buffer, getFd_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int fd = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; fd = hnd->fd; } hidl_cb(err, fd); + ALOGE("%s: fd: %d", __func__, fd); return Void(); } -Return IQtiMapperExtensions::getWidth(void *buffer, getWidth_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getWidth(void* buffer, getWidth_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int width = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; width = hnd->width; } hidl_cb(err, width); + ALOGE("%s: width: %d", __func__, width); return Void(); } -Return IQtiMapperExtensions::getHeight(void *buffer, getHeight_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getHeight(void* buffer, getHeight_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int height = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; height = hnd->height; } hidl_cb(err, height); + ALOGE("%s: height: %d", __func__, height); return Void(); } -Return IQtiMapperExtensions::getFormat(void *buffer, getFormat_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getFormat(void* buffer, getFormat_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int format = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; format = hnd->format; } hidl_cb(err, format); + + ALOGE("%s: format: %d", __func__, format); return Void(); } -Return IQtiMapperExtensions::getPrivateFlags(void *buffer, getPrivateFlags_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getPrivateFlags(void* buffer, getPrivateFlags_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int flags = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; flags = hnd->flags; } hidl_cb(err, flags); + ALOGE("%s: flags: %d", __func__, flags); return Void(); } -Return IQtiMapperExtensions::getUnalignedWidth(void *buffer, getUnalignedWidth_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getUnalignedWidth(void* buffer, getUnalignedWidth_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int unaligned_width = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; unaligned_width = hnd->unaligned_width; } hidl_cb(err, unaligned_width); + + ALOGE("%s: unaligned_width: %u", __func__, unaligned_width); return Void(); } -Return IQtiMapperExtensions::getUnalignedHeight(void *buffer, getUnalignedHeight_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getUnalignedHeight(void* buffer, getUnalignedHeight_cb hidl_cb) { + auto err = Error::BAD_BUFFER; int unaligned_height = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; unaligned_height = hnd->unaligned_height; } hidl_cb(err, unaligned_height); + ALOGE("%s: unaligned_height: %u", __func__, unaligned_height); return Void(); } -Return IQtiMapperExtensions::getLayerCount(void *buffer, getLayerCount_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getLayerCount(void* buffer, getLayerCount_cb hidl_cb) { + auto err = Error::BAD_BUFFER; unsigned int layer_count = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; layer_count = hnd->layer_count; } hidl_cb(err, layer_count); + ALOGE("%s: layer_count: %u", __func__, layer_count); return Void(); } -Return IQtiMapperExtensions::getId(void *buffer, getId_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getId(void* buffer, getId_cb hidl_cb) { + auto err = Error::BAD_BUFFER; uint64_t id = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; id = hnd->id; } hidl_cb(err, id); + ALOGE("%s: id: %" PRIu64, __func__, id); return Void(); } -Return IQtiMapperExtensions::getUsageFlags(void *buffer, getUsageFlags_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getUsageFlags(void* buffer, getUsageFlags_cb hidl_cb) { + auto err = Error::BAD_BUFFER; uint64_t usage = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; usage = hnd->usage; } hidl_cb(err, usage); + ALOGE("%s: usage: %" PRIu64, __func__, usage); + return Void(); } -Return IQtiMapperExtensions::getSize(void *buffer, getSize_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getSize(void* buffer, getSize_cb hidl_cb) { + auto err = Error::BAD_BUFFER; unsigned int size = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; size = hnd->size; } hidl_cb(err, size); + ALOGE("%s: size: %u", __func__, size); return Void(); } -Return IQtiMapperExtensions::getOffset(void *buffer, getOffset_cb hidl_cb) { - auto err = V1_0::Error::BAD_BUFFER; +Return IQtiMapperExtensions::getOffset(void* buffer, getOffset_cb hidl_cb) { + auto err = Error::BAD_BUFFER; unsigned int offset = 0; - auto hnd = static_cast(buffer); + auto hnd = static_cast(buffer); if (buffer != nullptr && private_handle_t::validate(hnd) == 0) { - err = V1_0::Error::NONE; + err = Error::NONE; offset = hnd->offset; } hidl_cb(err, offset); + ALOGE("%s: offset: %u", __func__, offset); return Void(); } +Return IQtiMapperExtensions::getFormatLayout(int32_t format, uint64_t usage, int32_t flags, + int32_t width, int32_t height, + getFormatLayout_cb _hidl_cb) { + hidl_vec plane_info; + unsigned int alignedw = 0, alignedh = 0, tile_enabled = 0; + int plane_count = 0; + uint64_t size = 0; + int custom_format = gralloc::GetImplDefinedFormat(usage, format); + gralloc::BufferInfo info(width, height, custom_format, usage); + + auto err = perform(gralloc, GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES, width, height, custom_format, + usage, usage, &alignedw, &alignedh, &tile_enabled) + ? Error::BAD_BUFFER + : Error::NONE; + if (err != Error::NONE) { + _hidl_cb(err, 0, plane_info); + return Void(); + } + + size = gralloc::GetSize(info, alignedw, alignedh); + gralloc::PlaneLayoutInfo plane_layout[8] = {}; + + if (gralloc::IsUncompressedRGBFormat(custom_format) || + gralloc::IsCompressedRGBFormat(custom_format)) { + gralloc::GetRGBPlaneInfo(info, custom_format, alignedw, alignedh, flags, &plane_count, + plane_layout); + } else { + ALOGE("%s: unsupported format %d", __func__, format); + err = Error::BAD_BUFFER; + _hidl_cb(err, size, plane_info); + return Void(); + } + + plane_info.resize(plane_count); + for (int i = 0; i < plane_count; i++) { + plane_info[i].component = plane_layout[i].component; + plane_info[i].h_subsampling = plane_layout[i].h_subsampling; + plane_info[i].v_subsampling = plane_layout[i].v_subsampling; + plane_info[i].offset = plane_layout[i].offset; + plane_info[i].pixel_increment = plane_layout[i].step; + plane_info[i].stride = plane_layout[i].stride; + plane_info[i].stride_bytes = plane_layout[i].stride_bytes; + plane_info[i].scanlines = plane_layout[i].scanlines; + plane_info[i].size = plane_layout[i].size; + } + + _hidl_cb(err, size, plane_info); + return Void(); } -} -} + +} // namespace V1_1 +} // namespace mapperextensions +} // namespace vendor::qti::hardware::display