Merge "Optimize the Parcel read/write of remote animation" into sc-dev

This commit is contained in:
Riddle Hsu
2021-03-03 03:58:07 +00:00
committed by Android (Google) Code Review
5 changed files with 37 additions and 38 deletions

View File

@@ -202,7 +202,7 @@ public final class PictureInPictureParams implements Parcelable {
} }
if (in.readInt() != 0) { if (in.readInt() != 0) {
mUserActions = new ArrayList<>(); mUserActions = new ArrayList<>();
in.readParcelableList(mUserActions, RemoteAction.class.getClassLoader()); in.readTypedList(mUserActions, RemoteAction.CREATOR);
} }
if (in.readInt() != 0) { if (in.readInt() != 0) {
mSourceRectHint = Rect.CREATOR.createFromParcel(in); mSourceRectHint = Rect.CREATOR.createFromParcel(in);
@@ -386,7 +386,7 @@ public final class PictureInPictureParams implements Parcelable {
} }
if (mUserActions != null) { if (mUserActions != null) {
out.writeInt(1); out.writeInt(1);
out.writeParcelableList(mUserActions, 0); out.writeTypedList(mUserActions, 0);
} else { } else {
out.writeInt(0); out.writeInt(0);
} }

View File

@@ -28,8 +28,8 @@ public class AppTransitionAnimationSpec implements Parcelable {
public AppTransitionAnimationSpec(Parcel in) { public AppTransitionAnimationSpec(Parcel in) {
taskId = in.readInt(); taskId = in.readInt();
rect = in.readParcelable(null); rect = in.readTypedObject(Rect.CREATOR);
buffer = in.readParcelable(null); buffer = in.readTypedObject(HardwareBuffer.CREATOR);
} }
@Override @Override
@@ -40,8 +40,8 @@ public class AppTransitionAnimationSpec implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(taskId); dest.writeInt(taskId);
dest.writeParcelable(rect, 0 /* flags */); dest.writeTypedObject(rect, 0 /* flags */);
dest.writeParcelable(buffer, 0); dest.writeTypedObject(buffer, 0 /* flags */);
} }
public static final @android.annotation.NonNull Parcelable.Creator<AppTransitionAnimationSpec> CREATOR public static final @android.annotation.NonNull Parcelable.Creator<AppTransitionAnimationSpec> CREATOR

View File

@@ -184,13 +184,13 @@ public class RemoteAnimationDefinition implements Parcelable {
} }
private RemoteAnimationAdapterEntry(Parcel in) { private RemoteAnimationAdapterEntry(Parcel in) {
adapter = in.readParcelable(RemoteAnimationAdapter.class.getClassLoader()); adapter = in.readTypedObject(RemoteAnimationAdapter.CREATOR);
activityTypeFilter = in.readInt(); activityTypeFilter = in.readInt();
} }
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(adapter, flags); dest.writeTypedObject(adapter, flags);
dest.writeInt(activityTypeFilter); dest.writeInt(activityTypeFilter);
} }

View File

@@ -222,20 +222,20 @@ public class RemoteAnimationTarget implements Parcelable {
public RemoteAnimationTarget(Parcel in) { public RemoteAnimationTarget(Parcel in) {
taskId = in.readInt(); taskId = in.readInt();
mode = in.readInt(); mode = in.readInt();
leash = in.readParcelable(null); leash = in.readTypedObject(SurfaceControl.CREATOR);
isTranslucent = in.readBoolean(); isTranslucent = in.readBoolean();
clipRect = in.readParcelable(null); clipRect = in.readTypedObject(Rect.CREATOR);
contentInsets = in.readParcelable(null); contentInsets = in.readTypedObject(Rect.CREATOR);
prefixOrderIndex = in.readInt(); prefixOrderIndex = in.readInt();
position = in.readParcelable(null); position = in.readTypedObject(Point.CREATOR);
localBounds = in.readParcelable(null); localBounds = in.readTypedObject(Rect.CREATOR);
sourceContainerBounds = in.readParcelable(null); sourceContainerBounds = in.readTypedObject(Rect.CREATOR);
screenSpaceBounds = in.readParcelable(null); screenSpaceBounds = in.readTypedObject(Rect.CREATOR);
windowConfiguration = in.readParcelable(null); windowConfiguration = in.readTypedObject(WindowConfiguration.CREATOR);
isNotInRecents = in.readBoolean(); isNotInRecents = in.readBoolean();
startLeash = in.readParcelable(null); startLeash = in.readTypedObject(SurfaceControl.CREATOR);
startBounds = in.readParcelable(null); startBounds = in.readTypedObject(Rect.CREATOR);
pictureInPictureParams = in.readParcelable(null); pictureInPictureParams = in.readTypedObject(PictureInPictureParams.CREATOR);
} }
@Override @Override
@@ -247,20 +247,20 @@ public class RemoteAnimationTarget implements Parcelable {
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(taskId); dest.writeInt(taskId);
dest.writeInt(mode); dest.writeInt(mode);
dest.writeParcelable(leash, 0 /* flags */); dest.writeTypedObject(leash, 0 /* flags */);
dest.writeBoolean(isTranslucent); dest.writeBoolean(isTranslucent);
dest.writeParcelable(clipRect, 0 /* flags */); dest.writeTypedObject(clipRect, 0 /* flags */);
dest.writeParcelable(contentInsets, 0 /* flags */); dest.writeTypedObject(contentInsets, 0 /* flags */);
dest.writeInt(prefixOrderIndex); dest.writeInt(prefixOrderIndex);
dest.writeParcelable(position, 0 /* flags */); dest.writeTypedObject(position, 0 /* flags */);
dest.writeParcelable(localBounds, 0 /* flags */); dest.writeTypedObject(localBounds, 0 /* flags */);
dest.writeParcelable(sourceContainerBounds, 0 /* flags */); dest.writeTypedObject(sourceContainerBounds, 0 /* flags */);
dest.writeParcelable(screenSpaceBounds, 0 /* flags */); dest.writeTypedObject(screenSpaceBounds, 0 /* flags */);
dest.writeParcelable(windowConfiguration, 0 /* flags */); dest.writeTypedObject(windowConfiguration, 0 /* flags */);
dest.writeBoolean(isNotInRecents); dest.writeBoolean(isNotInRecents);
dest.writeParcelable(startLeash, 0 /* flags */); dest.writeTypedObject(startLeash, 0 /* flags */);
dest.writeParcelable(startBounds, 0 /* flags */); dest.writeTypedObject(startBounds, 0 /* flags */);
dest.writeParcelable(pictureInPictureParams, 0 /* flags */); dest.writeTypedObject(pictureInPictureParams, 0 /* flags */);
} }
public void dump(PrintWriter pw, String prefix) { public void dump(PrintWriter pw, String prefix) {

View File

@@ -46,7 +46,7 @@ public class TaskSnapshot implements Parcelable {
private final int mOrientation; private final int mOrientation;
/** See {@link android.view.Surface.Rotation} */ /** See {@link android.view.Surface.Rotation} */
@Surface.Rotation @Surface.Rotation
private int mRotation; private final int mRotation;
/** The size of the snapshot before scaling */ /** The size of the snapshot before scaling */
private final Point mTaskSize; private final Point mTaskSize;
private final Rect mContentInsets; private final Rect mContentInsets;
@@ -90,15 +90,15 @@ public class TaskSnapshot implements Parcelable {
private TaskSnapshot(Parcel source) { private TaskSnapshot(Parcel source) {
mId = source.readLong(); mId = source.readLong();
mTopActivityComponent = ComponentName.readFromParcel(source); mTopActivityComponent = ComponentName.readFromParcel(source);
mSnapshot = source.readParcelable(null /* classLoader */); mSnapshot = source.readTypedObject(HardwareBuffer.CREATOR);
int colorSpaceId = source.readInt(); int colorSpaceId = source.readInt();
mColorSpace = colorSpaceId >= 0 && colorSpaceId < ColorSpace.Named.values().length mColorSpace = colorSpaceId >= 0 && colorSpaceId < ColorSpace.Named.values().length
? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]) ? ColorSpace.get(ColorSpace.Named.values()[colorSpaceId])
: ColorSpace.get(ColorSpace.Named.SRGB); : ColorSpace.get(ColorSpace.Named.SRGB);
mOrientation = source.readInt(); mOrientation = source.readInt();
mRotation = source.readInt(); mRotation = source.readInt();
mTaskSize = source.readParcelable(null /* classLoader */); mTaskSize = source.readTypedObject(Point.CREATOR);
mContentInsets = source.readParcelable(null /* classLoader */); mContentInsets = source.readTypedObject(Rect.CREATOR);
mIsLowResolution = source.readBoolean(); mIsLowResolution = source.readBoolean();
mIsRealSnapshot = source.readBoolean(); mIsRealSnapshot = source.readBoolean();
mWindowingMode = source.readInt(); mWindowingMode = source.readInt();
@@ -235,13 +235,12 @@ public class TaskSnapshot implements Parcelable {
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mId); dest.writeLong(mId);
ComponentName.writeToParcel(mTopActivityComponent, dest); ComponentName.writeToParcel(mTopActivityComponent, dest);
dest.writeParcelable(mSnapshot != null && !mSnapshot.isClosed() ? mSnapshot : null, dest.writeTypedObject(mSnapshot != null && !mSnapshot.isClosed() ? mSnapshot : null, 0);
0);
dest.writeInt(mColorSpace.getId()); dest.writeInt(mColorSpace.getId());
dest.writeInt(mOrientation); dest.writeInt(mOrientation);
dest.writeInt(mRotation); dest.writeInt(mRotation);
dest.writeParcelable(mTaskSize, 0); dest.writeTypedObject(mTaskSize, 0);
dest.writeParcelable(mContentInsets, 0); dest.writeTypedObject(mContentInsets, 0);
dest.writeBoolean(mIsLowResolution); dest.writeBoolean(mIsLowResolution);
dest.writeBoolean(mIsRealSnapshot); dest.writeBoolean(mIsRealSnapshot);
dest.writeInt(mWindowingMode); dest.writeInt(mWindowingMode);