diff options
author | Leon Scroggins III <scroggo@google.com> | 2020-02-18 13:52:18 -0500 |
---|---|---|
committer | Leon Scroggins III <scroggo@google.com> | 2020-02-18 16:35:56 -0500 |
commit | 5a190b19bb2c51dac5c1ddfc78fc0b53a5ff121e (patch) | |
tree | b8259449692b831cd17dfe0cf066d7ade317c95d /graphics | |
parent | 898ce7516da6cfa4183349b1e467fa6b8590a6f7 (diff) |
Add Bitmap#getHardwareBuffer
Bug: 148155907
Bug: 135299581
Test: TODO
Hidden for now. We'd like to make it an SDK API eventually
(b/148155907).
Internal code is currently calling createGraphicBufferHandle. This is
not something we plan to expose from the UI rendering module, so add a
method to get a HardwareBuffer instead. This is something we were
already planning to add. It seems that clients of
createGraphicBufferHandle really wanted a Parcelable to pass the
HARDWARE Bitmap to another thread. This should satisfy that use case.
Change-Id: Id701f7c7eab37830cd7d2cdb929cbe6ba4eca119
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/Bitmap.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 9c2e95fab455..c1e7a360fcc5 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -2243,6 +2243,19 @@ public final class Bitmap implements Parcelable { return nativeCreateGraphicBufferHandle(mNativePtr); } + /** + * @return {@link HardwareBuffer} which is internally used by hardware bitmap + * + * Note: the HardwareBuffer does *not* have an associated {@link ColorSpace}. + * To render this object the same as its rendered with this Bitmap, you + * should also call {@link getColorSpace}. + * + * @hide + */ + public HardwareBuffer getHardwareBuffer() { + return nativeGetHardwareBuffer(mNativePtr); + } + //////////// native methods private static native Bitmap nativeCreate(int[] colors, int offset, @@ -2308,6 +2321,7 @@ public final class Bitmap implements Parcelable { private static native Bitmap nativeWrapHardwareBufferBitmap(HardwareBuffer buffer, long nativeColorSpace); private static native GraphicBuffer nativeCreateGraphicBufferHandle(long nativeBitmap); + private static native HardwareBuffer nativeGetHardwareBuffer(long nativeBitmap); private static native ColorSpace nativeComputeColorSpace(long nativePtr); private static native void nativeSetColorSpace(long nativePtr, long nativeColorSpace); private static native boolean nativeIsSRGB(long nativePtr); |