diff options
| author | 2020-01-19 19:25:41 -0500 | |
|---|---|---|
| committer | 2020-01-21 11:52:04 -0500 | |
| commit | d4672a8091fcf52175c8307caea60366ed784650 (patch) | |
| tree | 2cc4646d004b43ae7921c8767a74f486090dfb25 /include/android | |
| parent | 46bb0aec07de33d13c545c39f5e2720450a50731 (diff) | |
Add NDK methods for HARDWARE Bitmaps
Bug: 135133301
Test: I2c1e58c41e49c72fb4bdbc64989da103885d34bf
Add a flag for AndroidBitmapInfo.flags that represents whether the
Bitmap has Config.HARDWARE.
Add a method for retrieving the AHardwareBuffer if it is a HARDWARE
Bitmap.
Change-Id: I69b78491bc29e770d863aa01752e8c923298afb3
Diffstat (limited to 'include/android')
| -rw-r--r-- | include/android/bitmap.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/include/android/bitmap.h b/include/android/bitmap.h index d920a90846..5e03c6c5aa 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -79,6 +79,14 @@ enum { ANDROID_BITMAP_FLAGS_ALPHA_SHIFT = 0, }; +enum { + /** If this bit is set in AndroidBitmapInfo.flags, the Bitmap uses the + * HARDWARE Config, and its AHardwareBuffer can be retrieved via + * AndroidBitmap_getHardwareBuffer. + */ + ANDROID_BITMAP_FLAGS_IS_HARDWARE = 1 << 31, +}; + /** Bitmap info, see AndroidBitmap_getInfo(). */ typedef struct { /** The bitmap width in pixels. */ @@ -90,7 +98,9 @@ typedef struct { /** The bitmap pixel format. See {@link AndroidBitmapFormat} */ int32_t format; /** Two bits are used to encode alpha. Use ANDROID_BITMAP_FLAGS_ALPHA_MASK - * and ANDROID_BITMAP_FLAGS_ALPHA_SHIFT to retrieve them. */ + * and ANDROID_BITMAP_FLAGS_ALPHA_SHIFT to retrieve them. One bit is used + * to encode whether the Bitmap uses the HARDWARE Config. Use + * ANDROID_BITMAP_FLAGS_IS_HARDWARE to know.*/ uint32_t flags; } AndroidBitmapInfo; @@ -210,6 +220,25 @@ int AndroidBitmap_compress(const AndroidBitmapInfo* info, void* userContext, AndroidBitmap_compress_write_fn fn) __INTRODUCED_IN(30); +struct AHardwareBuffer; + +/** + * Retrieve the native object associated with a HARDWARE Bitmap. + * + * Client must not modify it while a Bitmap is wrapping it. + * + * @param bitmap Handle to an android.graphics.Bitmap. + * @param outBuffer On success, is set to a pointer to the + * AHardwareBuffer associated with bitmap. This acquires + * a reference on the buffer, and the client must call + * AHardwareBuffer_release when finished with it. + * @return AndroidBitmap functions result code. + * ANDROID_BITMAP_RESULT_BAD_PARAMETER if bitmap is not a + * HARDWARE Bitmap. + */ +int AndroidBitmap_getHardwareBuffer(JNIEnv* env, jobject bitmap, + AHardwareBuffer** outBuffer) __INTRODUCED_IN(30); + #endif // __ANDROID_API__ >= 30 #ifdef __cplusplus |