From f73f5f2b3b9da9e09cc76cf72323aaf2926a5b04 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Mon, 12 Aug 2019 13:43:55 -0400 Subject: Add RGBA_F16 to the AndroidBitmapFormat (NDK) Bug: 135133301 Test: Id904c8cb4b22505635744ab271a639ace24ddbab Update AndroidBitmapFormat to keep up with Bitmap.Config. Change-Id: I3c17faf174b109b7c31c2eb5d1249bc881923b10 --- include/android/bitmap.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 2def64dc90..6fba0ac9ca 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -60,6 +60,8 @@ enum AndroidBitmapFormat { ANDROID_BITMAP_FORMAT_RGBA_4444 = 7, /** Alpha: 8 bits. */ ANDROID_BITMAP_FORMAT_A_8 = 8, + /** Each component is stored as a half float. **/ + ANDROID_BITMAP_FORMAT_RGBA_F16 = 9, }; /** Bitmap info, see AndroidBitmap_getInfo(). */ -- cgit v1.2.3-59-g8ed1b From 0dd622ef5da2207ae4af7819ba2d20151e49e9e9 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Fri, 23 Aug 2019 15:44:21 -0400 Subject: Add alpha to AndroidBitmapInfo Bug: 135133301 Test: If8859321c1b7e5149029f931e4d11ec6eeeb260a Change-Id: I3577602444837b703fcbf6498bd00e1ee1c97e09 --- include/android/bitmap.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 6fba0ac9ca..01cf2f88ea 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -64,6 +64,20 @@ enum AndroidBitmapFormat { ANDROID_BITMAP_FORMAT_RGBA_F16 = 9, }; +/** Bitmap alpha format */ +enum { + /** Pixel components are premultiplied by alpha. */ + ANDROID_BITMAP_FLAGS_ALPHA_PREMUL = 0, + /** Pixels are opaque. */ + ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE = 1, + /** Pixel components are independent of alpha. */ + ANDROID_BITMAP_FLAGS_ALPHA_UNPREMUL = 2, + /** Bit mask for AndroidBitmapFormat.flags to isolate the alpha. */ + ANDROID_BITMAP_FLAGS_ALPHA_MASK = 0x3, + /** Shift for AndroidBitmapFormat.flags to isolate the alpha. */ + ANDROID_BITMAP_FLAGS_ALPHA_SHIFT = 0, +}; + /** Bitmap info, see AndroidBitmap_getInfo(). */ typedef struct { /** The bitmap width in pixels. */ @@ -74,8 +88,9 @@ typedef struct { uint32_t stride; /** The bitmap pixel format. See {@link AndroidBitmapFormat} */ int32_t format; - /** Unused. */ - uint32_t flags; // 0 for now + /** Two bits are used to encode alpha. Use ANDROID_BITMAP_FLAGS_ALPHA_MASK + * and ANDROID_BITMAP_FLAGS_ALPHA_SHIFT to retrieve them. */ + uint32_t flags; } AndroidBitmapInfo; /** -- cgit v1.2.3-59-g8ed1b From 06c97753112bb7a03d6e58c3774b2e44d19d7681 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Tue, 3 Sep 2019 09:52:43 -0400 Subject: Add AndroidBitmap_getDataSpace Bug:135133301 Test: I7a5fcb726fba0c832bbb86a424d7534a7cfa35b6 This supplements AndroidBitmap_getInfo, allowing NDK clients to know how to interpret the colors in an android.graphics.Bitmap. Change-Id: Ia46dfb39d0f2708ce873343ec74bcc52e7bccd3a --- include/android/bitmap.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 01cf2f88ea..41718b2904 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -100,6 +100,19 @@ typedef struct { int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info); +#if __ANDROID_API__ >= 30 + +/** + * Given a java bitmap object, return its ADataSpace. + * + * Note that ADataSpace only exposes a few values. This may return + * ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no + * corresponding ADataSpace. + */ +int32_t AndroidBitmap_getDataSpace(JNIEnv* env, jobject jbitmap) __INTRODUCED_IN(30); + +#endif // __ANDROID_API__ >= 30 + /** * Given a java bitmap object, attempt to lock the pixel address. * Locking will ensure that the memory for the pixels will not move -- cgit v1.2.3-59-g8ed1b From a2a087942db377c3d643ed2949c5bf9668460a26 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Fri, 10 Jan 2020 17:25:25 +0000 Subject: Revert "Add AndroidBitmap_getDataSpace" Revert "Test AndroidBitmap_getDataSpace" Revert submission 9940762-_getDataSpace Reason for revert: Breaks build: http://screen/kBMYHusKiOV.png Reverted Changes: Ie05a45da3: Implement AndroidBitmap_getDataSpace I7a5fcb726: Test AndroidBitmap_getDataSpace Ia46dfb39d: Add AndroidBitmap_getDataSpace Change-Id: Ie6c9065f515442f3ea59d3930208deffb9a3bd2a --- include/android/bitmap.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 41718b2904..01cf2f88ea 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -100,19 +100,6 @@ typedef struct { int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info); -#if __ANDROID_API__ >= 30 - -/** - * Given a java bitmap object, return its ADataSpace. - * - * Note that ADataSpace only exposes a few values. This may return - * ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no - * corresponding ADataSpace. - */ -int32_t AndroidBitmap_getDataSpace(JNIEnv* env, jobject jbitmap) __INTRODUCED_IN(30); - -#endif // __ANDROID_API__ >= 30 - /** * Given a java bitmap object, attempt to lock the pixel address. * Locking will ensure that the memory for the pixels will not move -- cgit v1.2.3-59-g8ed1b From 3dd6455a54bb94c4059519fe9370ec3ecf33dc92 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Fri, 10 Jan 2020 13:41:44 -0500 Subject: Reland "Add AndroidBitmap_getDataSpace" Originally reviewed in Ia46dfb39d0f2708ce873343ec74bcc52e7bccd3a (and reverted in Ie6c9065f515442f3ea59d3930208deffb9a3bd2a) Bug:135133301 Test: I7a5fcb726fba0c832bbb86a424d7534a7cfa35b6 This supplements AndroidBitmap_getInfo, allowing NDK clients to know how to interpret the colors in an android.graphics.Bitmap. Change-Id: If822af556ac5ee6d412bf31afb9d07de6dd777eb --- include/android/bitmap.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 01cf2f88ea..41718b2904 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -100,6 +100,19 @@ typedef struct { int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, AndroidBitmapInfo* info); +#if __ANDROID_API__ >= 30 + +/** + * Given a java bitmap object, return its ADataSpace. + * + * Note that ADataSpace only exposes a few values. This may return + * ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no + * corresponding ADataSpace. + */ +int32_t AndroidBitmap_getDataSpace(JNIEnv* env, jobject jbitmap) __INTRODUCED_IN(30); + +#endif // __ANDROID_API__ >= 30 + /** * Given a java bitmap object, attempt to lock the pixel address. * Locking will ensure that the memory for the pixels will not move -- cgit v1.2.3-59-g8ed1b From 7f2d5b668c1bd20688cd6f394045a88c403c02c4 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Fri, 13 Dec 2019 14:57:07 -0500 Subject: Add NDK Bitmap compression Bug: 135133301 Test: Ifbcb41388a48afc64bb22623bb7e981b288b2457 Add an enum and a method for compression. Change-Id: I81954dba9045f59e3e12012e7df4a14ef20c55ed --- include/android/bitmap.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 41718b2904..d920a90846 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -26,6 +26,7 @@ #ifndef ANDROID_BITMAP_H #define ANDROID_BITMAP_H +#include #include #include @@ -133,6 +134,84 @@ int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr); */ int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap); +#if __ANDROID_API__ >= 30 + +// Note: these values match android.graphics.Bitmap#compressFormat. + +/** + * Specifies the formats that can be compressed to with + * {@link AndroidBitmap_compress}. + */ +enum AndroidBitmapCompressFormat { + /** + * Compress to the JPEG format. quality of 0 means + * compress for the smallest size. 100 means compress for max + * visual quality. + */ + ANDROID_BITMAP_COMPRESS_FORMAT_JPEG = 0, + /** + * Compress to the PNG format. PNG is lossless, so quality is + * ignored. + */ + ANDROID_BITMAP_COMPRESS_FORMAT_PNG = 1, + /** + * Compress to the WEBP lossy format. quality of 0 means + * compress for the smallest size. 100 means compress for max + * visual quality. + */ + ANDROID_BITMAP_COMPRESS_FORMAT_WEBP_LOSSY = 3, + /** + * Compress to the WEBP lossless format. quality refers to how + * much effort to put into compression. A value of 0 means to + * compress quickly, resulting in a relatively large file size. + * 100 means to spend more time compressing, resulting in a + * smaller file. + */ + ANDROID_BITMAP_COMPRESS_FORMAT_WEBP_LOSSLESS = 4, +}; + +/** + * User-defined function for writing the output of compression. + * + * @param userContext Pointer to user-defined data passed to + * {@link AndroidBitmap_compress}. + * @param data Compressed data of |size| bytes to write. + * @param size Length in bytes of data to write. + * @return Whether the operation succeeded. + */ +typedef bool (*AndroidBitmap_compress_write_fn)(void* userContext, + const void* data, + size_t size) __INTRODUCED_IN(30); + +/** + * Compress |pixels| as described by |info|. + * + * @param info Description of the pixels to compress. + * @param dataspace {@link ADataSpace} describing the color space of the + * pixels. + * @param pixels Pointer to pixels to compress. + * @param format (@link AndroidBitmapCompressFormat} to compress to. + * @param quality Hint to the compressor, 0-100. The value is interpreted + * differently depending on the + * {@link AndroidBitmapCompressFormat}. + * @param userContext User-defined data which will be passed to the supplied + * {@link AndroidBitmap_compress_write_fn} each time it is + * called. May be null. + * @parm fn Function that writes the compressed data. Will be called each time + * the compressor has compressed more data that is ready to be + * written. May be called more than once for each call to this method. + * May not be null. + * @return AndroidBitmap functions result code. + */ +int AndroidBitmap_compress(const AndroidBitmapInfo* info, + int32_t dataspace, + const void* pixels, + int32_t format, int32_t quality, + void* userContext, + AndroidBitmap_compress_write_fn fn) __INTRODUCED_IN(30); + +#endif // __ANDROID_API__ >= 30 + #ifdef __cplusplus } #endif -- cgit v1.2.3-59-g8ed1b From d4672a8091fcf52175c8307caea60366ed784650 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Sun, 19 Jan 2020 19:25:41 -0500 Subject: 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 --- include/android/bitmap.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'include/android/bitmap.h') 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 -- cgit v1.2.3-59-g8ed1b From c04a63ec68d8bb0491b291b6402206c137479d5c Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Wed, 22 Jan 2020 11:52:48 -0500 Subject: Rename callback for AndroidBitmap_compress Bug: 135133301 Test: No change in behavior, no new tests Rename from AndroidBitmap_compress_write_fn to AndroidBitmap_CompressWriteFunc to better fit in with media callbacks, as suggested in feedback. Change-Id: Id5d039761054cf8e7fb906624a277714c21156de --- include/android/bitmap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index d920a90846..f169d811ec 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -179,7 +179,7 @@ enum AndroidBitmapCompressFormat { * @param size Length in bytes of data to write. * @return Whether the operation succeeded. */ -typedef bool (*AndroidBitmap_compress_write_fn)(void* userContext, +typedef bool (*AndroidBitmap_CompressWriteFunc)(void* userContext, const void* data, size_t size) __INTRODUCED_IN(30); @@ -195,7 +195,7 @@ typedef bool (*AndroidBitmap_compress_write_fn)(void* userContext, * differently depending on the * {@link AndroidBitmapCompressFormat}. * @param userContext User-defined data which will be passed to the supplied - * {@link AndroidBitmap_compress_write_fn} each time it is + * {@link AndroidBitmap_CompressWriteFunc} each time it is * called. May be null. * @parm fn Function that writes the compressed data. Will be called each time * the compressor has compressed more data that is ready to be @@ -208,7 +208,7 @@ int AndroidBitmap_compress(const AndroidBitmapInfo* info, const void* pixels, int32_t format, int32_t quality, void* userContext, - AndroidBitmap_compress_write_fn fn) __INTRODUCED_IN(30); + AndroidBitmap_CompressWriteFunc fn) __INTRODUCED_IN(30); #endif // __ANDROID_API__ >= 30 -- cgit v1.2.3-59-g8ed1b From 9cb2ffdb01895391be745e45b8b7078677099d35 Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Thu, 6 Feb 2020 11:16:54 -0500 Subject: Specify when AndroidBitmapInfo.flags were introduced Bug: 148954909 Test: Generate docs Change-Id: Ie9d65ed4ab108a9f756ee4e5ae431696be6500cc --- include/android/bitmap.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 571a5ca1ef..412fc6b53f 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -97,15 +97,21 @@ typedef struct { uint32_t stride; /** 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. One bit is used - * to encode whether the Bitmap uses the HARDWARE Config. Use - * ANDROID_BITMAP_FLAGS_IS_HARDWARE to know.*/ + /** Bitfield containing information about the bitmap. + * + *

Two bits are used to encode alpha. Use {@link ANDROID_BITMAP_FLAGS_ALPHA_MASK} + * and {@link ANDROID_BITMAP_FLAGS_ALPHA_SHIFT} to retrieve them.

+ * + *

One bit is used to encode whether the Bitmap uses the HARDWARE Config. Use + * {@link ANDROID_BITMAP_FLAGS_IS_HARDWARE} to know.

+ * + *

These flags were introduced in API level 30.

+ */ uint32_t flags; } AndroidBitmapInfo; /** - * Given a java bitmap object, fill out the AndroidBitmapInfo struct for it. + * Given a java bitmap object, fill out the {@link AndroidBitmapInfo} struct for it. * If the call fails, the info parameter will be ignored. */ int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, -- cgit v1.2.3-59-g8ed1b From 4883c52b940bbfa4f396c8432a25bed5e5e6d51b Mon Sep 17 00:00:00 2001 From: Leon Scroggins III Date: Thu, 30 Jan 2020 15:10:11 -0500 Subject: Fix docs for bitmap.h Bug: 135133301 Test: Generate docs - Fix errors in bitmap documentation. - Add links where relevant. - Move comment in sensor.h so it will apply to the module, and not AHardwareBuffer. Change-Id: Iec00725522e74eccab9346665562081211a870eb --- include/android/bitmap.h | 26 +++++++++++++------------- include/android/sensor.h | 9 +++------ 2 files changed, 16 insertions(+), 19 deletions(-) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 412fc6b53f..727a4af2f9 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -81,8 +81,8 @@ enum { enum { /** If this bit is set in AndroidBitmapInfo.flags, the Bitmap uses the - * HARDWARE Config, and its AHardwareBuffer can be retrieved via - * AndroidBitmap_getHardwareBuffer. + * HARDWARE Config, and its {@link AHardwareBuffer} can be retrieved via + * {@link AndroidBitmap_getHardwareBuffer}. */ ANDROID_BITMAP_FLAGS_IS_HARDWARE = 1 << 31, }; @@ -120,10 +120,10 @@ int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, #if __ANDROID_API__ >= 30 /** - * Given a java bitmap object, return its ADataSpace. + * Given a java bitmap object, return its {@link ADataSpace}. * - * Note that ADataSpace only exposes a few values. This may return - * ADATASPACE_UNKNOWN, even for Named ColorSpaces, if they have no + * Note that {@link ADataSpace} only exposes a few values. This may return + * {@link ADATASPACE_UNKNOWN}, even for Named ColorSpaces, if they have no * corresponding ADataSpace. */ int32_t AndroidBitmap_getDataSpace(JNIEnv* env, jobject jbitmap) __INTRODUCED_IN(30); @@ -206,17 +206,17 @@ typedef bool (*AndroidBitmap_CompressWriteFunc)(void* userContext, * @param dataspace {@link ADataSpace} describing the color space of the * pixels. * @param pixels Pointer to pixels to compress. - * @param format (@link AndroidBitmapCompressFormat} to compress to. + * @param format {@link AndroidBitmapCompressFormat} to compress to. * @param quality Hint to the compressor, 0-100. The value is interpreted * differently depending on the * {@link AndroidBitmapCompressFormat}. * @param userContext User-defined data which will be passed to the supplied * {@link AndroidBitmap_CompressWriteFunc} each time it is * called. May be null. - * @parm fn Function that writes the compressed data. Will be called each time - * the compressor has compressed more data that is ready to be - * written. May be called more than once for each call to this method. - * May not be null. + * @param fn Function that writes the compressed data. Will be called each time + * the compressor has compressed more data that is ready to be + * written. May be called more than once for each call to this method. + * May not be null. * @return AndroidBitmap functions result code. */ int AndroidBitmap_compress(const AndroidBitmapInfo* info, @@ -235,11 +235,11 @@ struct AHardwareBuffer; * * @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 + * {@link AHardwareBuffer} associated with bitmap. This acquires * a reference on the buffer, and the client must call - * AHardwareBuffer_release when finished with it. + * {@link AHardwareBuffer_release} when finished with it. * @return AndroidBitmap functions result code. - * ANDROID_BITMAP_RESULT_BAD_PARAMETER if bitmap is not a + * {@link ANDROID_BITMAP_RESULT_BAD_PARAMETER} if bitmap is not a * HARDWARE Bitmap. */ int AndroidBitmap_getHardwareBuffer(JNIEnv* env, jobject bitmap, diff --git a/include/android/sensor.h b/include/android/sensor.h index 12c00ad8a2..e63ac4b407 100644 --- a/include/android/sensor.h +++ b/include/android/sensor.h @@ -15,6 +15,9 @@ */ /** + * Structures and functions to receive and process sensor events in + * native code. + * * @addtogroup Sensor * @{ */ @@ -42,12 +45,6 @@ * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES */ -/** - * Structures and functions to receive and process sensor events in - * native code. - * - */ - #include #include -- cgit v1.2.3-59-g8ed1b From fbcf9d77fe6321ba7e03d50f965e8c16ea4290c3 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 24 Feb 2020 15:26:37 -0800 Subject: Make bitmap.h C-compatible when __ANDROID_API__ >= 30 C requires a typedef for AHardwareBuffer. Fixes: frameworks/native/include/android/bitmap.h:246:9: error: must use 'struct' tag to refer to type 'AHardwareBuffer' Fixes: 150165785 Test: m checkbuild Change-Id: I6d475e91317ff7a9264144d4cd6c6c9b46d10196 --- include/android/bitmap.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 727a4af2f9..2631b144af 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -227,6 +227,7 @@ int AndroidBitmap_compress(const AndroidBitmapInfo* info, AndroidBitmap_CompressWriteFunc fn) __INTRODUCED_IN(30); struct AHardwareBuffer; +typedef struct AHardwareBuffer AHardwareBuffer; /** * Retrieve the native object associated with a HARDWARE Bitmap. -- cgit v1.2.3-59-g8ed1b From 7be0e2def2d9cff2436511696838fcf0734b4da1 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 2 Jun 2020 13:05:04 -0700 Subject: API level 30 cleanup. Make sure that we have the __INTRODUCED_IN()s and -- more importantly -- the API levels recorded in the documentation. Bug: https://github.com/android/ndk/issues/1271 Test: treehugger Change-Id: I74752f19f165fd5c56b2dfd783298c2da1a926d6 --- include/android/bitmap.h | 8 ++++++++ include/android/choreographer.h | 10 ++++++++-- include/android/imagedecoder.h | 38 ++++++++++++++++++++++++++++++++++++++ include/android/thermal.h | 30 +++++++++++++++++++----------- 4 files changed, 73 insertions(+), 13 deletions(-) (limited to 'include/android/bitmap.h') diff --git a/include/android/bitmap.h b/include/android/bitmap.h index 2631b144af..f19539913e 100644 --- a/include/android/bitmap.h +++ b/include/android/bitmap.h @@ -125,6 +125,8 @@ int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap, * Note that {@link ADataSpace} only exposes a few values. This may return * {@link ADATASPACE_UNKNOWN}, even for Named ColorSpaces, if they have no * corresponding ADataSpace. + * + * Available since API level 30. */ int32_t AndroidBitmap_getDataSpace(JNIEnv* env, jobject jbitmap) __INTRODUCED_IN(30); @@ -189,6 +191,8 @@ enum AndroidBitmapCompressFormat { /** * User-defined function for writing the output of compression. * + * Available since API level 30. + * * @param userContext Pointer to user-defined data passed to * {@link AndroidBitmap_compress}. * @param data Compressed data of |size| bytes to write. @@ -202,6 +206,8 @@ typedef bool (*AndroidBitmap_CompressWriteFunc)(void* userContext, /** * Compress |pixels| as described by |info|. * + * Available since API level 30. + * * @param info Description of the pixels to compress. * @param dataspace {@link ADataSpace} describing the color space of the * pixels. @@ -234,6 +240,8 @@ typedef struct AHardwareBuffer AHardwareBuffer; * * Client must not modify it while a Bitmap is wrapping it. * + * Available since API level 30. + * * @param bitmap Handle to an android.graphics.Bitmap. * @param outBuffer On success, is set to a pointer to the * {@link AHardwareBuffer} associated with bitmap. This acquires diff --git a/include/android/choreographer.h b/include/android/choreographer.h index c1c4a72cd3..bdf11e42ca 100644 --- a/include/android/choreographer.h +++ b/include/android/choreographer.h @@ -129,9 +129,12 @@ void AChoreographer_postFrameCallbackDelayed64(AChoreographer* choreographer, * * This api is thread-safe. Any thread is allowed to register a new refresh * rate callback for the choreographer instance. + * + * Available since API level 30. */ void AChoreographer_registerRefreshRateCallback(AChoreographer* choreographer, - AChoreographer_refreshRateCallback, void* data); + AChoreographer_refreshRateCallback, void* data) + __INTRODUCED_IN(30); /** * Unregisters a callback to be run when the display refresh rate changes, along @@ -144,9 +147,12 @@ void AChoreographer_registerRefreshRateCallback(AChoreographer* choreographer, * callback and associated data pointer are unregistered, then there is a * guarantee that when the unregistration completes that that callback will not * be run with the data pointer passed. + * + * Available since API level 30. */ void AChoreographer_unregisterRefreshRateCallback(AChoreographer* choreographer, - AChoreographer_refreshRateCallback, void* data); + AChoreographer_refreshRateCallback, void* data) + __INTRODUCED_IN(30); #endif /* __ANDROID_API__ >= 30 */ __END_DECLS diff --git a/include/android/imagedecoder.h b/include/android/imagedecoder.h index 3a87da0fee..d7e6e4118f 100644 --- a/include/android/imagedecoder.h +++ b/include/android/imagedecoder.h @@ -133,6 +133,8 @@ typedef struct AImageDecoder AImageDecoder; /** * Create a new {@link AImageDecoder} from an {@link AAsset}. * + * Available since API level 30. + * * @param asset {@link AAsset} containing encoded image data. Client is still * responsible for calling {@link AAsset_close} on it, which may be * done after deleting the returned {@link AImageDecoder}. @@ -162,6 +164,8 @@ int AImageDecoder_createFromAAsset(struct AAsset* asset, AImageDecoder** outDeco /** * Create a new {@link AImageDecoder} from a file descriptor. * + * Available since API level 30. + * * @param fd Seekable, readable, open file descriptor for encoded data. * Client is still responsible for closing it, which may be done * after deleting the returned {@link AImageDecoder}. @@ -190,6 +194,8 @@ int AImageDecoder_createFromFd(int fd, AImageDecoder** outDecoder) __INTRODUCED_ /** * Create a new AImageDecoder from a buffer. * + * Available since API level 30. + * * @param buffer Pointer to encoded data. Must be valid for the entire time * the {@link AImageDecoder} is used. * @param length Byte length of buffer. @@ -217,12 +223,16 @@ int AImageDecoder_createFromBuffer(const void* buffer, size_t length, /** * Delete the AImageDecoder. + * + * Available since API level 30. */ void AImageDecoder_delete(AImageDecoder* decoder) __INTRODUCED_IN(30); /** * Choose the desired output format. * + * Available since API level 30. + * * @param format {@link AndroidBitmapFormat} to use for the output. * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value * indicating the reason for the failure. On failure, the @@ -247,6 +257,8 @@ int AImageDecoder_setAndroidBitmapFormat(AImageDecoder*, * Pass true to this method to leave them unpremultiplied. This has no effect on an * opaque image. * + * Available since API level 30. + * * @param unpremultipliedRequired Pass true to leave the pixels unpremultiplied. * @return {@link ANDROID_IMAGE_DECODER_SUCCESS} on success or a value * indicating the reason for the failure. @@ -267,6 +279,8 @@ int AImageDecoder_setUnpremultipliedRequired(AImageDecoder*, * Ignored by {@link ANDROID_BITMAP_FORMAT_A_8}, which does not support * an {@link ADataSpace}. * + * Available since API level 30. + * * @param dataspace The {@link ADataSpace} to decode into. An ADataSpace * specifies how to interpret the colors. By default, * AImageDecoder will decode into the ADataSpace specified by @@ -292,6 +306,8 @@ int AImageDecoder_setDataSpace(AImageDecoder*, int32_t dataspace) __INTRODUCED_I * specified by width and height, and the output image will be the size of the * crop rect. * + * Available since API level 30. + * * @param width Width of the output (prior to cropping). * This will affect future calls to * {@link AImageDecoder_getMinimumStride}, which will now return @@ -319,6 +335,8 @@ int AImageDecoder_setTargetSize(AImageDecoder*, int32_t width, int32_t height) _ * others. This computes the most efficient target size to use to reach a * particular sampleSize. * + * Available since API level 30. + * * @param sampleSize A subsampling rate of the original image. Must be greater * than or equal to 1. A sampleSize of 2 means to skip every * other pixel/line, resulting in a width and height that are @@ -344,6 +362,8 @@ int AImageDecoder_computeSampledSize(const AImageDecoder*, int sampleSize, * the specified {@link ARect}. Clients will only need to allocate enough memory * for the cropped ARect. * + * Available since API level 30. + * * @param crop Rectangle describing a crop of the decode. It must be contained inside of * the (possibly scaled, by {@link AImageDecoder_setTargetSize}) * image dimensions. This will affect future calls to @@ -376,6 +396,8 @@ typedef struct AImageDecoderHeaderInfo AImageDecoderHeaderInfo; * * This is owned by the {@link AImageDecoder} and will be destroyed when the * AImageDecoder is destroyed via {@link AImageDecoder_delete}. + * + * Available since API level 30. */ const AImageDecoderHeaderInfo* AImageDecoder_getHeaderInfo( const AImageDecoder*) __INTRODUCED_IN(30); @@ -385,6 +407,8 @@ const AImageDecoderHeaderInfo* AImageDecoder_getHeaderInfo( * pixel width of the output, unless {@link AImageDecoder_setTargetSize} is * used to choose a different size or {@link AImageDecoder_setCrop} is used to * set a crop rect. + * + * Available since API level 30. */ int32_t AImageDecoderHeaderInfo_getWidth(const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30); @@ -393,12 +417,16 @@ int32_t AImageDecoderHeaderInfo_getWidth(const AImageDecoderHeaderInfo*) __INTRO * pixel height of the output, unless {@link AImageDecoder_setTargetSize} is * used to choose a different size or {@link AImageDecoder_setCrop} is used to * set a crop rect. + * + * Available since API level 30. */ int32_t AImageDecoderHeaderInfo_getHeight(const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30); /** * Report the mimeType of the encoded image. * + * Available since API level 30. + * * @return a string literal describing the mime type. */ const char* AImageDecoderHeaderInfo_getMimeType( @@ -409,6 +437,8 @@ const char* AImageDecoderHeaderInfo_getMimeType( * by default. {@link AImageDecoder} will try to choose one that is sensible * for the image and the system. Note that this does not indicate the * encoded format of the image. + * + * Available since API level 30. */ int32_t AImageDecoderHeaderInfo_getAndroidBitmapFormat( const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30); @@ -419,6 +449,8 @@ int32_t AImageDecoderHeaderInfo_getAndroidBitmapFormat( * {@link ANDROID_BITMAP_FLAGS_ALPHA_OPAQUE}. If the image may contain alpha, * this returns {@link ANDROID_BITMAP_FLAGS_ALPHA_PREMUL}, because * {@link AImageDecoder_decodeImage} will premultiply pixels by default. + * + * Available since API level 30. */ int AImageDecoderHeaderInfo_getAlphaFlags( const AImageDecoderHeaderInfo*) __INTRODUCED_IN(30); @@ -429,6 +461,8 @@ int AImageDecoderHeaderInfo_getAlphaFlags( * By default, {@link AImageDecoder_decodeImage} will not do any color * conversion. * + * Available since API level 30. + * * @return The {@link ADataSpace} representing the way the colors * are encoded (or {@link ADATASPACE_UNKNOWN} if there is not a * corresponding ADataSpace). This specifies how to interpret the colors @@ -452,12 +486,16 @@ int32_t AImageDecoderHeaderInfo_getDataSpace( * * If the output is scaled (via {@link AImageDecoder_setTargetSize}) and/or * cropped (via {@link AImageDecoder_setCrop}), this takes those into account. + * + * Available since API level 30. */ size_t AImageDecoder_getMinimumStride(AImageDecoder*) __INTRODUCED_IN(30); /** * Decode the image into pixels, using the settings of the {@link AImageDecoder}. * + * Available since API level 30. + * * @param decoder Opaque object representing the decoder. * @param pixels On success, will be filled with the result * of the decode. Must be large enough to hold |size| bytes. diff --git a/include/android/thermal.h b/include/android/thermal.h index 3247fa167b..83582d6791 100644 --- a/include/android/thermal.h +++ b/include/android/thermal.h @@ -60,8 +60,6 @@ extern "C" { #endif -#if __ANDROID_API__ >= 30 - enum AThermalStatus { /** Error in thermal status. */ ATHERMAL_STATUS_ERROR = -1, @@ -111,36 +109,45 @@ typedef struct AThermalManager AThermalManager; */ typedef void (*AThermal_StatusCallback)(void *data, AThermalStatus status); +#if __ANDROID_API__ >= 30 + /** * Acquire an instance of the thermal manager. This must be freed using * {@link AThermal_releaseManager}. * + * Available since API level 30. + * * @return manager instance on success, nullptr on failure. - */ -AThermalManager* AThermal_acquireManager(); + */ +AThermalManager* AThermal_acquireManager() __INTRODUCED_IN(30); /** * Release the thermal manager pointer acquired via * {@link AThermal_acquireManager}. * - * @param manager The manager to be released. + * Available since API level 30. * + * @param manager The manager to be released. */ -void AThermal_releaseManager(AThermalManager *manager); +void AThermal_releaseManager(AThermalManager *manager) __INTRODUCED_IN(30); /** * Gets the current thermal status. * + * Available since API level 30. + * * @param manager The manager instance to use to query the thermal status. * Acquired via {@link AThermal_acquireManager}. * * @return current thermal status, ATHERMAL_STATUS_ERROR on failure. -*/ -AThermalStatus AThermal_getCurrentThermalStatus(AThermalManager *manager); + */ +AThermalStatus AThermal_getCurrentThermalStatus(AThermalManager *manager) __INTRODUCED_IN(30); /** * Register the thermal status listener for thermal status change. * + * Available since API level 30. + * * @param manager The manager instance to use to register. * Acquired via {@link AThermal_acquireManager}. * @param callback The callback function to be called when thermal status updated. @@ -152,11 +159,13 @@ AThermalStatus AThermal_getCurrentThermalStatus(AThermalManager *manager); * EPIPE if communication with the system service has failed. */ int AThermal_registerThermalStatusListener(AThermalManager *manager, - AThermal_StatusCallback callback, void *data); + AThermal_StatusCallback callback, void *data) __INTRODUCED_IN(30); /** * Unregister the thermal status listener previously resgistered. * + * Available since API level 30. + * * @param manager The manager instance to use to unregister. * Acquired via {@link AThermal_acquireManager}. * @param callback The callback function to be called when thermal status updated. @@ -168,8 +177,7 @@ int AThermal_registerThermalStatusListener(AThermalManager *manager, * EPIPE if communication with the system service has failed. */ int AThermal_unregisterThermalStatusListener(AThermalManager *manager, - AThermal_StatusCallback callback, void *data); - + AThermal_StatusCallback callback, void *data) __INTRODUCED_IN(30); #endif // __ANDROID_API__ >= 30 -- cgit v1.2.3-59-g8ed1b