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>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package android.view;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -15,19 +15,19 @@ import android.os.Parcelable;
|
||||
*/
|
||||
public class AppTransitionAnimationSpec implements Parcelable {
|
||||
public final int taskId;
|
||||
public final Bitmap bitmap;
|
||||
public final GraphicBuffer buffer;
|
||||
public final Rect rect;
|
||||
|
||||
public AppTransitionAnimationSpec(int taskId, Bitmap bitmap, Rect rect) {
|
||||
public AppTransitionAnimationSpec(int taskId, GraphicBuffer buffer, Rect rect) {
|
||||
this.taskId = taskId;
|
||||
this.bitmap = bitmap;
|
||||
this.rect = rect;
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
public AppTransitionAnimationSpec(Parcel in) {
|
||||
taskId = in.readInt();
|
||||
bitmap = in.readParcelable(null);
|
||||
rect = in.readParcelable(null);
|
||||
buffer = in.readParcelable(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,9 +38,8 @@ public class AppTransitionAnimationSpec implements Parcelable {
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(taskId);
|
||||
dest.writeParcelable(bitmap, 0 /* flags */);
|
||||
dest.writeParcelable(rect, 0 /* flags */);
|
||||
|
||||
dest.writeParcelable(buffer, 0);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<AppTransitionAnimationSpec> CREATOR
|
||||
@@ -56,6 +55,6 @@ public class AppTransitionAnimationSpec implements Parcelable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{taskId: " + taskId + ", bitmap: " + bitmap + ", rect: " + rect + "}";
|
||||
return "{taskId: " + taskId + ", buffer: " + buffer + ", rect: " + rect + "}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.android.internal.policy.IShortcutService;
|
||||
import android.content.res.CompatibilityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
@@ -96,9 +97,9 @@ interface IWindowManager
|
||||
int startHeight);
|
||||
void overridePendingAppTransitionClipReveal(int startX, int startY,
|
||||
int startWidth, int startHeight);
|
||||
void overridePendingAppTransitionThumb(in Bitmap srcThumb, int startX, int startY,
|
||||
void overridePendingAppTransitionThumb(in GraphicBuffer srcThumb, int startX, int startY,
|
||||
IRemoteCallback startedCallback, boolean scaleUp);
|
||||
void overridePendingAppTransitionAspectScaledThumb(in Bitmap srcThumb, int startX,
|
||||
void overridePendingAppTransitionAspectScaledThumb(in GraphicBuffer srcThumb, int startX,
|
||||
int startY, int targetWidth, int targetHeight, IRemoteCallback startedCallback,
|
||||
boolean scaleUp);
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user