Loading api/current.txt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -10973,6 +10973,8 @@ package android.graphics { public class ImageFormat { public class ImageFormat { ctor public ImageFormat(); ctor public ImageFormat(); method public static int getBitsPerPixel(int); method public static int getBitsPerPixel(int); field public static final int DEPTH16 = 1144402265; // 0x44363159 field public static final int DEPTH_POINT_CLOUD = 257; // 0x101 field public static final int JPEG = 256; // 0x100 field public static final int JPEG = 256; // 0x100 field public static final int NV16 = 16; // 0x10 field public static final int NV16 = 16; // 0x10 field public static final int NV21 = 17; // 0x11 field public static final int NV21 = 17; // 0x11 api/system-current.txt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -11248,6 +11248,8 @@ package android.graphics { public class ImageFormat { public class ImageFormat { ctor public ImageFormat(); ctor public ImageFormat(); method public static int getBitsPerPixel(int); method public static int getBitsPerPixel(int); field public static final int DEPTH16 = 1144402265; // 0x44363159 field public static final int DEPTH_POINT_CLOUD = 257; // 0x101 field public static final int JPEG = 256; // 0x100 field public static final int JPEG = 256; // 0x100 field public static final int NV16 = 16; // 0x10 field public static final int NV16 = 16; // 0x10 field public static final int NV21 = 17; // 0x11 field public static final int NV21 = 17; // 0x11 core/jni/android_view_Surface.cpp +94 −0 Original line number Original line Diff line number Diff line Loading @@ -130,6 +130,100 @@ jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, return surfaceObj; 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) { static inline bool isSurfaceValid(const sp<Surface>& sur) { Loading graphics/java/android/graphics/ImageFormat.java +35 −0 Original line number Original line Diff line number Diff line Loading @@ -355,6 +355,38 @@ public class ImageFormat { */ */ public static final int RAW10 = 0x25; public static final int RAW10 = 0x25; /** * Android dense depth image format. * * Each pixel is 16 bits, representing a depth ranging measurement from * a depth camera or similar sensor. * * <p>This format assumes * <ul> * <li>an even width</li> * <li>an even height</li> * <li>a horizontal stride multiple of 16 pixels</li> * </ul> * </p> * * <pre> y_size = stride * height </pre> * * When produced by a camera, the units are millimeters. */ public static final int DEPTH16 = 0x44363159; /** * Android sparse depth point cloud format. * * <p>A variable-length list of 3D points, with each point represented * by a triple of floats.</p> * * <p>The number of points is {@code (size of the buffer in bytes) / 12}. * * The coordinate system and units depend on the source of the point cloud data. */ public static final int DEPTH_POINT_CLOUD = 0x101; /** /** * Use this function to retrieve the number of bits per pixel of an * Use this function to retrieve the number of bits per pixel of an * ImageFormat. * ImageFormat. Loading @@ -376,6 +408,7 @@ public class ImageFormat { case Y8: case Y8: return 8; return 8; case Y16: case Y16: case DEPTH16: return 16; return 16; case NV21: case NV21: return 12; return 12; Loading Loading @@ -412,6 +445,8 @@ public class ImageFormat { case YUV_420_888: case YUV_420_888: case RAW_SENSOR: case RAW_SENSOR: case RAW10: case RAW10: case DEPTH16: case DEPTH_POINT_CLOUD: return true; return true; } } Loading include/android_runtime/android_view_Surface.h +42 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,33 @@ namespace android { class Surface; class Surface; class IGraphicBufferProducer; class IGraphicBufferProducer; /** * Enum mirroring the public API definitions for image and pixel formats. * Some of these are hidden in the public API * * Keep up to date with android.graphics.ImageFormat and * android.graphics.PixelFormat */ enum class PublicFormat { UNKNOWN = 0x0, RGBA_8888 = 0x1, RGBX_8888 = 0x2, RGB_888 = 0x3, RGB_565 = 0x4, NV16 = 0x10, NV21 = 0x11, YUY2 = 0x14, RAW_SENSOR = 0x20, YUV_420_888 = 0x23, RAW10 = 0x25, JPEG = 0x100, DEPTH_POINT_CLOUD = 0x101, YV12 = 0x32315659, Y8 = 0x20203859, // @hide Y16 = 0x20363159, // @hide DEPTH16 = 0x44363159 }; /* Gets the underlying ANativeWindow for a Surface. */ /* Gets the underlying ANativeWindow for a Surface. */ extern sp<ANativeWindow> android_view_Surface_getNativeWindow( extern sp<ANativeWindow> android_view_Surface_getNativeWindow( JNIEnv* env, jobject surfaceObj); JNIEnv* env, jobject surfaceObj); Loading @@ -40,6 +67,21 @@ extern sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceO extern jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, extern jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, const sp<IGraphicBufferProducer>& bufferProducer); const sp<IGraphicBufferProducer>& bufferProducer); /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL * format */ extern int android_view_Surface_mapPublicFormatToHalFormat(PublicFormat f); /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL * dataspace */ extern android_dataspace android_view_Surface_mapPublicFormatToHalDataspace( PublicFormat f); /* Convert from HAL format, dataspace pair to * android.graphics.ImageFormat/PixelFormat. * For unknown/unspecified pairs, returns PublicFormat::UNKNOWN */ extern PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat( int format, android_dataspace dataSpace); } // namespace android } // namespace android #endif // _ANDROID_VIEW_SURFACE_H #endif // _ANDROID_VIEW_SURFACE_H Loading
api/current.txt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -10973,6 +10973,8 @@ package android.graphics { public class ImageFormat { public class ImageFormat { ctor public ImageFormat(); ctor public ImageFormat(); method public static int getBitsPerPixel(int); method public static int getBitsPerPixel(int); field public static final int DEPTH16 = 1144402265; // 0x44363159 field public static final int DEPTH_POINT_CLOUD = 257; // 0x101 field public static final int JPEG = 256; // 0x100 field public static final int JPEG = 256; // 0x100 field public static final int NV16 = 16; // 0x10 field public static final int NV16 = 16; // 0x10 field public static final int NV21 = 17; // 0x11 field public static final int NV21 = 17; // 0x11
api/system-current.txt +2 −0 Original line number Original line Diff line number Diff line Loading @@ -11248,6 +11248,8 @@ package android.graphics { public class ImageFormat { public class ImageFormat { ctor public ImageFormat(); ctor public ImageFormat(); method public static int getBitsPerPixel(int); method public static int getBitsPerPixel(int); field public static final int DEPTH16 = 1144402265; // 0x44363159 field public static final int DEPTH_POINT_CLOUD = 257; // 0x101 field public static final int JPEG = 256; // 0x100 field public static final int JPEG = 256; // 0x100 field public static final int NV16 = 16; // 0x10 field public static final int NV16 = 16; // 0x10 field public static final int NV21 = 17; // 0x11 field public static final int NV21 = 17; // 0x11
core/jni/android_view_Surface.cpp +94 −0 Original line number Original line Diff line number Diff line Loading @@ -130,6 +130,100 @@ jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, return surfaceObj; 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) { static inline bool isSurfaceValid(const sp<Surface>& sur) { Loading
graphics/java/android/graphics/ImageFormat.java +35 −0 Original line number Original line Diff line number Diff line Loading @@ -355,6 +355,38 @@ public class ImageFormat { */ */ public static final int RAW10 = 0x25; public static final int RAW10 = 0x25; /** * Android dense depth image format. * * Each pixel is 16 bits, representing a depth ranging measurement from * a depth camera or similar sensor. * * <p>This format assumes * <ul> * <li>an even width</li> * <li>an even height</li> * <li>a horizontal stride multiple of 16 pixels</li> * </ul> * </p> * * <pre> y_size = stride * height </pre> * * When produced by a camera, the units are millimeters. */ public static final int DEPTH16 = 0x44363159; /** * Android sparse depth point cloud format. * * <p>A variable-length list of 3D points, with each point represented * by a triple of floats.</p> * * <p>The number of points is {@code (size of the buffer in bytes) / 12}. * * The coordinate system and units depend on the source of the point cloud data. */ public static final int DEPTH_POINT_CLOUD = 0x101; /** /** * Use this function to retrieve the number of bits per pixel of an * Use this function to retrieve the number of bits per pixel of an * ImageFormat. * ImageFormat. Loading @@ -376,6 +408,7 @@ public class ImageFormat { case Y8: case Y8: return 8; return 8; case Y16: case Y16: case DEPTH16: return 16; return 16; case NV21: case NV21: return 12; return 12; Loading Loading @@ -412,6 +445,8 @@ public class ImageFormat { case YUV_420_888: case YUV_420_888: case RAW_SENSOR: case RAW_SENSOR: case RAW10: case RAW10: case DEPTH16: case DEPTH_POINT_CLOUD: return true; return true; } } Loading
include/android_runtime/android_view_Surface.h +42 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,33 @@ namespace android { class Surface; class Surface; class IGraphicBufferProducer; class IGraphicBufferProducer; /** * Enum mirroring the public API definitions for image and pixel formats. * Some of these are hidden in the public API * * Keep up to date with android.graphics.ImageFormat and * android.graphics.PixelFormat */ enum class PublicFormat { UNKNOWN = 0x0, RGBA_8888 = 0x1, RGBX_8888 = 0x2, RGB_888 = 0x3, RGB_565 = 0x4, NV16 = 0x10, NV21 = 0x11, YUY2 = 0x14, RAW_SENSOR = 0x20, YUV_420_888 = 0x23, RAW10 = 0x25, JPEG = 0x100, DEPTH_POINT_CLOUD = 0x101, YV12 = 0x32315659, Y8 = 0x20203859, // @hide Y16 = 0x20363159, // @hide DEPTH16 = 0x44363159 }; /* Gets the underlying ANativeWindow for a Surface. */ /* Gets the underlying ANativeWindow for a Surface. */ extern sp<ANativeWindow> android_view_Surface_getNativeWindow( extern sp<ANativeWindow> android_view_Surface_getNativeWindow( JNIEnv* env, jobject surfaceObj); JNIEnv* env, jobject surfaceObj); Loading @@ -40,6 +67,21 @@ extern sp<Surface> android_view_Surface_getSurface(JNIEnv* env, jobject surfaceO extern jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, extern jobject android_view_Surface_createFromIGraphicBufferProducer(JNIEnv* env, const sp<IGraphicBufferProducer>& bufferProducer); const sp<IGraphicBufferProducer>& bufferProducer); /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL * format */ extern int android_view_Surface_mapPublicFormatToHalFormat(PublicFormat f); /* Convert from android.graphics.ImageFormat/PixelFormat enums to graphics.h HAL * dataspace */ extern android_dataspace android_view_Surface_mapPublicFormatToHalDataspace( PublicFormat f); /* Convert from HAL format, dataspace pair to * android.graphics.ImageFormat/PixelFormat. * For unknown/unspecified pairs, returns PublicFormat::UNKNOWN */ extern PublicFormat android_view_Surface_mapHalFormatDataspaceToPublicFormat( int format, android_dataspace dataSpace); } // namespace android } // namespace android #endif // _ANDROID_VIEW_SURFACE_H #endif // _ANDROID_VIEW_SURFACE_H