1 /* 2 * Copyright (C) 2010 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 _ANDROID_VIEW_SURFACE_H 18 #define _ANDROID_VIEW_SURFACE_H 19 20 #include <android/native_window.h> 21 #include <system/graphics.h> 22 23 #include "jni.h" 24 25 namespace android { 26 27 class Surface; 28 class IGraphicBufferProducer; 29 30 /** 31 * Enum mirroring the public API definitions for image and pixel formats. 32 * Some of these are hidden in the public API 33 * 34 * Keep up to date with android.graphics.ImageFormat and 35 * android.graphics.PixelFormat 36 */ 37 enum class PublicFormat { 38 UNKNOWN = 0x0, 39 RGBA_8888 = 0x1, 40 RGBX_8888 = 0x2, 41 RGB_888 = 0x3, 42 RGB_565 = 0x4, 43 NV16 = 0x10, 44 NV21 = 0x11, 45 YUY2 = 0x14, 46 RGBA_FP16 = 0x16, 47 RAW_SENSOR = 0x20, 48 PRIVATE = 0x22, 49 YUV_420_888 = 0x23, 50 RAW_PRIVATE = 0x24, 51 RAW10 = 0x25, 52 RAW12 = 0x26, 53 RGBA_1010102 = 0x2b, 54 JPEG = 0x100, 55 DEPTH_POINT_CLOUD = 0x101, 56 RAW_DEPTH = 0x1002, // @hide 57 YV12 = 0x32315659, 58 Y8 = 0x20203859, // @hide 59 Y16 = 0x20363159, // @hide 60 DEPTH16 = 0x44363159 61 }; 62 63 /* Gets the underlying ANativeWindow for a Surface. */ 64 extern sp<ANativeWindow> android_view_Surface_getNativeWindow( 65 JNIEnv* env, jobject surfaceObj); 66 67 /* Returns true if the object is an instance of Surface. */ 68 extern bool android_view_Surface_isInstanceOf(JNIEnv* env, jobject obj); 69 70 /* Gets the underlying Surface from a Surface Java object. */ 71 extern sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceObj); 72 73 /* Creates a Surface from an android::Surface. */ 74 extern jobject android_view_Surface_createFromSurface(JNIEnv* env, 75 const sp<Surface>& surface); 76 77 /* Creates a Surface from an IGraphicBufferProducer. */ 78 extern jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, 79 const sp<IGraphicBufferProducer>& bufferProducer); 80 81 /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 82 * format */ 83 extern int android_view_Surface_mapPublicFormatToHalFormat(PublicFormat f); 84 85 /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 86 * dataspace */ 87 extern android_dataspace android_view_Surface_mapPublicFormatToHalDataspace( 88 PublicFormat f); 89 90 /* Convert from HAL format, dataspace pair to 91 * android.graphics.ImageFormat/PixelFormat. 92 * For unknown/unspecified pairs, returns PublicFormat::UNKNOWN */ 93 extern PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat( 94 int format, android_dataspace dataSpace); 95 96 } // namespace android 97 98 #endif // _ANDROID_VIEW_SURFACE_H 99