Add relative layer to SurfaceParams am: 6ec2f9151b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12131836

Change-Id: I4f6d02baf45d599c2248944dac7ddbda7eb67b91
This commit is contained in:
Tracy Zhou
2020-07-11 18:13:21 +00:00
committed by Automerger Merge Worker

View File

@@ -46,6 +46,7 @@ public class SyncRtSurfaceTransactionApplierCompat {
public static final int FLAG_CORNER_RADIUS = 1 << 4; public static final int FLAG_CORNER_RADIUS = 1 << 4;
public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5; public static final int FLAG_BACKGROUND_BLUR_RADIUS = 1 << 5;
public static final int FLAG_VISIBILITY = 1 << 6; public static final int FLAG_VISIBILITY = 1 << 6;
public static final int FLAG_RELATIVE_LAYER = 1 << 7;
private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0; private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0;
@@ -192,6 +193,8 @@ public class SyncRtSurfaceTransactionApplierCompat {
Matrix matrix; Matrix matrix;
Rect windowCrop; Rect windowCrop;
int layer; int layer;
SurfaceControl relativeTo;
int relativeLayer;
boolean visible; boolean visible;
/** /**
@@ -248,6 +251,18 @@ public class SyncRtSurfaceTransactionApplierCompat {
return this; return this;
} }
/**
* @param relativeTo The surface that's set relative layer to.
* @param relativeLayer The relative layer.
* @return this Builder
*/
public Builder withRelativeLayerTo(SurfaceControl relativeTo, int relativeLayer) {
this.relativeTo = relativeTo;
this.relativeLayer = relativeLayer;
flags |= FLAG_RELATIVE_LAYER;
return this;
}
/** /**
* @param radius the Radius for rounded corners to apply to the surface. * @param radius the Radius for rounded corners to apply to the surface.
* @return this Builder * @return this Builder
@@ -283,7 +298,7 @@ public class SyncRtSurfaceTransactionApplierCompat {
*/ */
public SurfaceParams build() { public SurfaceParams build() {
return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer, return new SurfaceParams(surface, flags, alpha, matrix, windowCrop, layer,
cornerRadius, backgroundBlurRadius, visible); relativeTo, relativeLayer, cornerRadius, backgroundBlurRadius, visible);
} }
} }
@@ -297,21 +312,25 @@ public class SyncRtSurfaceTransactionApplierCompat {
* @param windowCrop Crop to apply, only applied if not {@code null} * @param windowCrop Crop to apply, only applied if not {@code null}
*/ */
public SurfaceParams(SurfaceControlCompat surface, float alpha, Matrix matrix, public SurfaceParams(SurfaceControlCompat surface, float alpha, Matrix matrix,
Rect windowCrop, int layer, float cornerRadius) { Rect windowCrop, int layer, SurfaceControl relativeTo, int relativeLayer,
float cornerRadius) {
this(surface.mSurfaceControl, this(surface.mSurfaceControl,
FLAG_ALL & ~(FLAG_VISIBILITY | FLAG_BACKGROUND_BLUR_RADIUS), alpha, FLAG_ALL & ~(FLAG_VISIBILITY | FLAG_BACKGROUND_BLUR_RADIUS), alpha,
matrix, windowCrop, layer, cornerRadius, 0 /* backgroundBlurRadius */, true); matrix, windowCrop, layer, relativeTo, relativeLayer, cornerRadius,
0 /* backgroundBlurRadius */, true);
} }
private SurfaceParams(SurfaceControl surface, int flags, float alpha, Matrix matrix, private SurfaceParams(SurfaceControl surface, int flags, float alpha, Matrix matrix,
Rect windowCrop, int layer, float cornerRadius, int backgroundBlurRadius, Rect windowCrop, int layer, SurfaceControl relativeTo, int relativeLayer,
boolean visible) { float cornerRadius, int backgroundBlurRadius, boolean visible) {
this.flags = flags; this.flags = flags;
this.surface = surface; this.surface = surface;
this.alpha = alpha; this.alpha = alpha;
this.matrix = new Matrix(matrix); this.matrix = new Matrix(matrix);
this.windowCrop = windowCrop != null ? new Rect(windowCrop) : null; this.windowCrop = windowCrop != null ? new Rect(windowCrop) : null;
this.layer = layer; this.layer = layer;
this.relativeTo = relativeTo;
this.relativeLayer = relativeLayer;
this.cornerRadius = cornerRadius; this.cornerRadius = cornerRadius;
this.backgroundBlurRadius = backgroundBlurRadius; this.backgroundBlurRadius = backgroundBlurRadius;
this.visible = visible; this.visible = visible;
@@ -327,6 +346,8 @@ public class SyncRtSurfaceTransactionApplierCompat {
public final Matrix matrix; public final Matrix matrix;
public final Rect windowCrop; public final Rect windowCrop;
public final int layer; public final int layer;
public final SurfaceControl relativeTo;
public final int relativeLayer;
public final boolean visible; public final boolean visible;
public void applyTo(SurfaceControl.Transaction t) { public void applyTo(SurfaceControl.Transaction t) {
@@ -355,6 +376,9 @@ public class SyncRtSurfaceTransactionApplierCompat {
t.hide(surface); t.hide(surface);
} }
} }
if ((flags & FLAG_RELATIVE_LAYER) != 0) {
t.setRelativeLayer(surface, relativeTo, relativeLayer);
}
} }
} }
} }