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 YV12 = 0x32315659, 54 Y8 = 0x20203859, 55 Y16 = 0x20363159, // @hide 56 DEPTH16 = 0x44363159, 57 DEPTH_JPEG = 0x69656963, 58 HEIC = 0x48454946, 59 }; 60 61 /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 62 * format */ 63 extern int mapPublicFormatToHalFormat(PublicFormat f); 64 65 /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 66 * dataspace */ 67 extern android_dataspace mapPublicFormatToHalDataspace(PublicFormat f); 68 69 /* Convert from HAL format, dataspace pair to 70 * android.graphics.ImageFormat/PixelFormat. 71 * For unknown/unspecified pairs, returns PublicFormat::UNKNOWN */ 72 extern PublicFormat mapHalFormatDataspaceToPublicFormat(int format, android_dataspace dataSpace); 73 74 }; // namespace android 75 76 #endif // UI_PUBLICFORMAT_H 77