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 25namespace android { 26 27class Surface; 28class 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 */ 37enum 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 YV12 = 0x32315659, 57 Y8 = 0x20203859, // @hide 58 Y16 = 0x20363159, // @hide 59 DEPTH16 = 0x44363159 60}; 61 62/* Gets the underlying ANativeWindow for a Surface. */ 63extern sp<ANativeWindow> android_view_Surface_getNativeWindow( 64 JNIEnv* env, jobject surfaceObj); 65 66/* Returns true if the object is an instance of Surface. */ 67extern bool android_view_Surface_isInstanceOf(JNIEnv* env, jobject obj); 68 69/* Gets the underlying Surface from a Surface Java object. */ 70extern sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceObj); 71 72/* Creates a Surface from an android::Surface. */ 73extern jobject android_view_Surface_createFromSurface(JNIEnv* env, 74 const sp<Surface>& surface); 75 76/* Creates a Surface from an IGraphicBufferProducer. */ 77extern jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, 78 const sp<IGraphicBufferProducer>& bufferProducer); 79 80/* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 81 * format */ 82extern int android_view_Surface_mapPublicFormatToHalFormat(PublicFormat f); 83 84/* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL 85 * dataspace */ 86extern android_dataspace android_view_Surface_mapPublicFormatToHalDataspace( 87 PublicFormat f); 88 89/* Convert from HAL format, dataspace pair to 90 * android.graphics.ImageFormat/PixelFormat. 91 * For unknown/unspecified pairs, returns PublicFormat::UNKNOWN */ 92extern PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat( 93 int format, android_dataspace dataSpace); 94 95} // namespace android 96 97#endif // _ANDROID_VIEW_SURFACE_H 98