1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef UI_PUBLICFORMAT_H 18 #define UI_PUBLICFORMAT_H 19 20 #include <system/graphics.h> 21 22 namespace android { 23 24 /** 25 * Enum mirroring the public API definitions for image and pixel formats. 26 * Some of these are hidden in the public API 27 * 28 * Keep up to date with android.graphics.ImageFormat and 29 * android.graphics.PixelFormat 30 * 31 * TODO: PublicFormat is going to be deprecated(b/126594675) 32 */ 33 enum class PublicFormat { 34 UNKNOWN = 0x0, 35 RGBA_8888 = 0x1, 36 RGBX_8888 = 0x2, 37 RGB_888 = 0x3, 38 RGB_565 = 0x4, 39 NV16 = 0x10, 40 NV21 = 0x11, 41 YUY2 = 0x14, 42 RGBA_FP16 = 0x16, 43 RAW_SENSOR = 0x20, 44 PRIVATE = 0x22, 45 YUV_420_888 = 0x23, 46 RAW_PRIVATE = 0x24, 47 RAW10 = 0x25, 48 RAW12 = 0x26, 49 RGBA_1010102 = 0x2b, 50 JPEG = 0x100, 51 DEPTH_POINT_CLOUD = 0x101, 52 RAW_DEPTH = 0x1002, // @hide 53 RAW_DEPTH10 = 0x1003, // @hide 54 YV12 = 0x32315659, 55 Y8 = 0x20203859, 56 Y16 = 0x20363159, // @hide 57 YCBCR_P010 = 0x36, 58 DEPTH16 = 0x44363159, 59 DEPTH_JPEG = 0x69656963, 60 HEIC = 0x48454946, 61 }; 62 63 /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 64 * format */ 65 extern int mapPublicFormatToHalFormat(PublicFormat f); 66 67 /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 68 * dataspace */ 69 extern android_dataspace mapPublicFormatToHalDataspace(PublicFormat f); 70 71 /* Convert from HAL format, dataspace pair to 72 * android.graphics.ImageFormat/PixelFormat. 73 * For unknown/unspecified pairs, returns PublicFormat::UNKNOWN */ 74 extern PublicFormat mapHalFormatDataspaceToPublicFormat(int format, android_dataspace dataSpace); 75 76 }; // namespace android 77 78 #endif // UI_PUBLICFORMAT_H 79