diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2015-02-26 10:57:55 -0800 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2015-03-09 16:42:25 -0700 |
commit | 805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9 (patch) | |
tree | 52be74b470b30f90b5ff9a2b820a541d515f728e /core | |
parent | a72d6401346ba01027f5fe2f59f9c018e8a6a84a (diff) | |
download | frameworks_base-805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9.zip frameworks_base-805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9.tar.gz frameworks_base-805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9.tar.bz2 |
Add DEPTH image formats, support in ImageReader
- Add an explicit mapping between public ImageFormat/
PixelFormat enums and internal HAL format/dataspace.
- Add DEPTH16 and DEPTH_POINT_CLOUD formats
- Wire up mapping layer to ImageReader to support depth
formats
Change-Id: I8197eccef900cc91baddcfcb934ccd4d8c972eff
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/android_view_Surface.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp index bfa0534..39064ed 100644 --- a/core/jni/android_view_Surface.cpp +++ b/core/jni/android_view_Surface.cpp @@ -130,6 +130,100 @@ jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, return surfaceObj; } +int android_view_Surface_mapPublicFormatToHalFormat(PublicFormat f) { + + switch(f) { + case PublicFormat::JPEG: + case PublicFormat::DEPTH_POINT_CLOUD: + return HAL_PIXEL_FORMAT_BLOB; + case PublicFormat::DEPTH16: + return HAL_PIXEL_FORMAT_Y16; + case PublicFormat::RAW_SENSOR: + return HAL_PIXEL_FORMAT_RAW16; + default: + // Most formats map 1:1 + return static_cast<int>(f); + } +} + +android_dataspace android_view_Surface_mapPublicFormatToHalDataspace( + PublicFormat f) { + switch(f) { + case PublicFormat::JPEG: + return HAL_DATASPACE_JFIF; + case PublicFormat::DEPTH_POINT_CLOUD: + case PublicFormat::DEPTH16: + return HAL_DATASPACE_DEPTH; + case PublicFormat::RAW_SENSOR: + case PublicFormat::RAW10: + return HAL_DATASPACE_ARBITRARY; + case PublicFormat::YUV_420_888: + case PublicFormat::NV21: + case PublicFormat::YV12: + return HAL_DATASPACE_JFIF; + default: + // Most formats map to UNKNOWN + return HAL_DATASPACE_UNKNOWN; + } +} + +PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat( + int format, android_dataspace dataSpace) { + switch(format) { + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGB_888: + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_Y8: + case HAL_PIXEL_FORMAT_RAW10: + case HAL_PIXEL_FORMAT_YCbCr_420_888: + case HAL_PIXEL_FORMAT_YV12: + // Enums overlap in both name and value + return static_cast<PublicFormat>(format); + case HAL_PIXEL_FORMAT_RAW16: + // Name differs, though value is the same + return PublicFormat::RAW_SENSOR; + case HAL_PIXEL_FORMAT_YCbCr_422_SP: + // Name differs, though the value is the same + return PublicFormat::NV16; + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + // Name differs, though the value is the same + return PublicFormat::NV21; + case HAL_PIXEL_FORMAT_YCbCr_422_I: + // Name differs, though the value is the same + return PublicFormat::YUY2; + case HAL_PIXEL_FORMAT_Y16: + // Dataspace-dependent + switch (dataSpace) { + case HAL_DATASPACE_DEPTH: + return PublicFormat::DEPTH16; + default: + // Assume non-depth Y16 is just Y16. + return PublicFormat::Y16; + } + break; + case HAL_PIXEL_FORMAT_BLOB: + // Dataspace-dependent + switch (dataSpace) { + case HAL_DATASPACE_DEPTH: + return PublicFormat::DEPTH_POINT_CLOUD; + case HAL_DATASPACE_JFIF: + return PublicFormat::JPEG; + default: + // Assume otherwise-marked blobs are also JPEG + return PublicFormat::JPEG; + } + break; + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_RAW_OPAQUE: + case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: + // Not defined in public API + return PublicFormat::UNKNOWN; + + default: + return PublicFormat::UNKNOWN; + } +} // ---------------------------------------------------------------------------- static inline bool isSurfaceValid(const sp<Surface>& sur) { |