diff options
| author | Winson Chung <winsonc@google.com> | 2017-05-24 15:50:06 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2017-05-31 16:23:24 +0000 |
| commit | aa7fa0135366b80d9bfdb7dffb6795b365a40607 (patch) | |
| tree | 6e8cbcfa1dfdae75284496bb23a9fb6a944fa805 /core/java/android/app/ActivityOptions.java | |
| parent | 910927671be8a32f06b1d51466a900d27a572ead (diff) | |
DO NOT MERGE Updating AnimationSpec and related internal APIs to use GraphicBuffer.
- This reduces the copy of the hardware bitmap when it is
parceled/unparceled.
Bug: 38507414
Bug: 62021436
Test: Launch Overview to/from app, ensure that the header bar shows
Test: go/wm-smoke
Change-Id: I85a9a59a0a3699d1642158061d10fddef34393c3
Signed-off-by: Winson Chung <winsonc@google.com>
Diffstat (limited to 'core/java/android/app/ActivityOptions.java')
| -rw-r--r-- | core/java/android/app/ActivityOptions.java | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index 53608fbdd4bb..c4d51168d20c 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -25,6 +25,8 @@ import android.annotation.TestApi; import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; +import android.graphics.Bitmap.Config; +import android.graphics.GraphicBuffer; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; @@ -826,7 +828,11 @@ public class ActivityOptions { case ANIM_THUMBNAIL_SCALE_DOWN: case ANIM_THUMBNAIL_ASPECT_SCALE_UP: case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: - mThumbnail = (Bitmap) opts.getParcelable(KEY_ANIM_THUMBNAIL); + // Unpackage the GraphicBuffer from the parceled thumbnail + final GraphicBuffer buffer = opts.getParcelable(KEY_ANIM_THUMBNAIL); + if (buffer != null) { + mThumbnail = Bitmap.createHardwareBitmap(buffer); + } mStartX = opts.getInt(KEY_ANIM_START_X, 0); mStartY = opts.getInt(KEY_ANIM_START_Y, 0); mWidth = opts.getInt(KEY_ANIM_WIDTH, 0); @@ -919,9 +925,14 @@ public class ActivityOptions { return mCustomInPlaceResId; } - /** @hide */ - public Bitmap getThumbnail() { - return mThumbnail; + /** + * The thumbnail is copied into a hardware bitmap when it is bundled and sent to the system, so + * it should always be backed by a GraphicBuffer on the other end. + * + * @hide + */ + public GraphicBuffer getThumbnail() { + return mThumbnail.createGraphicBufferHandle(); } /** @hide */ @@ -1230,7 +1241,14 @@ public class ActivityOptions { case ANIM_THUMBNAIL_SCALE_DOWN: case ANIM_THUMBNAIL_ASPECT_SCALE_UP: case ANIM_THUMBNAIL_ASPECT_SCALE_DOWN: - b.putParcelable(KEY_ANIM_THUMBNAIL, mThumbnail); + // Once we parcel the thumbnail for transfering over to the system, create a copy of + // the bitmap to a hardware bitmap and pass through the GraphicBuffer + if (mThumbnail == null) { + b.putParcelable(KEY_ANIM_THUMBNAIL, null); + } else { + final Bitmap hwBitmap = mThumbnail.copy(Config.HARDWARE, true /* immutable */); + b.putParcelable(KEY_ANIM_THUMBNAIL, hwBitmap.createGraphicBufferHandle()); + } b.putInt(KEY_ANIM_START_X, mStartX); b.putInt(KEY_ANIM_START_Y, mStartY); b.putInt(KEY_ANIM_WIDTH, mWidth); |
