1 /* 2 * Copyright 2023 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 package androidx.hardware 18 19 import android.hardware.HardwareBuffer 20 import android.hardware.HardwareBuffer.BLOB 21 import android.hardware.HardwareBuffer.DS_24UI8 22 import android.hardware.HardwareBuffer.DS_FP32UI8 23 import android.hardware.HardwareBuffer.D_16 24 import android.hardware.HardwareBuffer.D_24 25 import android.hardware.HardwareBuffer.D_FP32 26 import android.hardware.HardwareBuffer.RGBA_1010102 27 import android.hardware.HardwareBuffer.RGBA_8888 28 import android.hardware.HardwareBuffer.RGBA_FP16 29 import android.hardware.HardwareBuffer.RGBX_8888 30 import android.hardware.HardwareBuffer.RGB_565 31 import android.hardware.HardwareBuffer.RGB_888 32 import android.hardware.HardwareBuffer.S_UI8 33 import android.hardware.HardwareBuffer.YCBCR_420_888 34 import android.hardware.HardwareBuffer.YCBCR_P010 35 import androidx.annotation.IntDef 36 import androidx.annotation.RestrictTo 37 38 @RestrictTo(RestrictTo.Scope.LIBRARY) 39 @Retention(AnnotationRetention.SOURCE) 40 @IntDef( 41 RGBA_8888, 42 RGBA_FP16, 43 RGBA_1010102, 44 RGBX_8888, 45 RGB_888, 46 RGB_565, 47 BLOB, 48 YCBCR_420_888, 49 D_16, 50 D_24, 51 DS_24UI8, 52 D_FP32, 53 DS_FP32UI8, 54 S_UI8, 55 YCBCR_P010 56 ) 57 annotation class HardwareBufferFormat 58 59 // Leverage the same value as HardwareBuffer.USAGE_COMPOSER_OVERLAY. 60 // While this constant was introduced in the SDK in the Android T release, it has 61 // been available within the NDK as part of 62 // AHardwareBuffer_UsageFlags#AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY for quite some time. 63 // This flag is required for usage of ASurfaceTransaction#setBuffer 64 // Use a separate constant with the same value to avoid SDK warnings of accessing the 65 // newly added constant in the SDK. 66 // See: 67 // developer.android.com/ndk/reference/group/a-hardware-buffer#ahardwarebuffer_usageflags 68 internal const val USAGE_COMPOSER_OVERLAY: Long = 2048L 69 70 internal const val DefaultFlags = 71 HardwareBuffer.USAGE_GPU_SAMPLED_IMAGE or 72 HardwareBuffer.USAGE_GPU_COLOR_OUTPUT or 73 USAGE_COMPOSER_OVERLAY 74 75 internal const val DefaultNumBuffers = 3 76