Merge "Exposing some ViewRoomImple methods in shared lib" into rvc-dev am: 0cdc03a772
Change-Id: I7b1de17030cba51f001578a75bd812a20b4c25b4
This commit is contained in:
@@ -38,9 +38,7 @@ android_library {
|
|||||||
"PluginCoreLib",
|
"PluginCoreLib",
|
||||||
],
|
],
|
||||||
|
|
||||||
// Enforce that the library is built against java 7 so that there are
|
|
||||||
// no compatibility issues with launcher
|
|
||||||
java_version: "1.7",
|
|
||||||
|
|
||||||
|
java_version: "1.8",
|
||||||
min_sdk_version: "26",
|
min_sdk_version: "26",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,5 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.android.systemui.shared">
|
package="com.android.systemui.shared">
|
||||||
|
|
||||||
<uses-sdk
|
|
||||||
android:minSdkVersion="26" />
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ import android.view.SurfaceControl;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewRootImpl;
|
import android.view.ViewRootImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Remove this class
|
||||||
|
*/
|
||||||
public class SurfaceControlCompat {
|
public class SurfaceControlCompat {
|
||||||
final SurfaceControl mSurfaceControl;
|
final SurfaceControl mSurfaceControl;
|
||||||
|
|
||||||
@@ -37,4 +40,8 @@ public class SurfaceControlCompat {
|
|||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return mSurfaceControl != null && mSurfaceControl.isValid();
|
return mSurfaceControl != null && mSurfaceControl.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SurfaceControl getSurfaceControl() {
|
||||||
|
return mSurfaceControl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import android.os.Handler;
|
|||||||
import android.os.Handler.Callback;
|
import android.os.Handler.Callback;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
import android.view.SurfaceControl.Transaction;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewRootImpl;
|
import android.view.ViewRootImpl;
|
||||||
|
|
||||||
@@ -108,13 +108,12 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "Sync transaction frameNumber=" + frame);
|
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "Sync transaction frameNumber=" + frame);
|
||||||
TransactionCompat t = new TransactionCompat();
|
Transaction t = new Transaction();
|
||||||
for (int i = params.length - 1; i >= 0; i--) {
|
for (int i = params.length - 1; i >= 0; i--) {
|
||||||
SyncRtSurfaceTransactionApplierCompat.SurfaceParams surfaceParams =
|
SyncRtSurfaceTransactionApplierCompat.SurfaceParams surfaceParams =
|
||||||
params[i];
|
params[i];
|
||||||
SurfaceControlCompat surface = surfaceParams.surface;
|
t.deferTransactionUntil(surfaceParams.surface, mBarrierSurfaceControl, frame);
|
||||||
t.deferTransactionUntil(surface, mBarrierSurfaceControl, frame);
|
surfaceParams.applyTo(t);
|
||||||
applyParams(t, surfaceParams);
|
|
||||||
}
|
}
|
||||||
t.setEarlyWakeup();
|
t.setEarlyWakeup();
|
||||||
t.apply();
|
t.apply();
|
||||||
@@ -152,31 +151,7 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
|
|
||||||
public static void applyParams(TransactionCompat t,
|
public static void applyParams(TransactionCompat t,
|
||||||
SyncRtSurfaceTransactionApplierCompat.SurfaceParams params) {
|
SyncRtSurfaceTransactionApplierCompat.SurfaceParams params) {
|
||||||
if ((params.flags & FLAG_MATRIX) != 0) {
|
params.applyTo(t.mTransaction);
|
||||||
t.setMatrix(params.surface, params.matrix);
|
|
||||||
}
|
|
||||||
if ((params.flags & FLAG_WINDOW_CROP) != 0) {
|
|
||||||
t.setWindowCrop(params.surface, params.windowCrop);
|
|
||||||
}
|
|
||||||
if ((params.flags & FLAG_ALPHA) != 0) {
|
|
||||||
t.setAlpha(params.surface, params.alpha);
|
|
||||||
}
|
|
||||||
if ((params.flags & FLAG_LAYER) != 0) {
|
|
||||||
t.setLayer(params.surface, params.layer);
|
|
||||||
}
|
|
||||||
if ((params.flags & FLAG_CORNER_RADIUS) != 0) {
|
|
||||||
t.setCornerRadius(params.surface, params.cornerRadius);
|
|
||||||
}
|
|
||||||
if ((params.flags & FLAG_BACKGROUND_BLUR_RADIUS) != 0) {
|
|
||||||
t.setBackgroundBlurRadius(params.surface, params.backgroundBlurRadius);
|
|
||||||
}
|
|
||||||
if ((params.flags & FLAG_VISIBILITY) != 0) {
|
|
||||||
if (params.visible) {
|
|
||||||
t.show(params.surface);
|
|
||||||
} else {
|
|
||||||
t.hide(params.surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,7 +185,7 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
|
|
||||||
public static class SurfaceParams {
|
public static class SurfaceParams {
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
final SurfaceControlCompat surface;
|
final SurfaceControl surface;
|
||||||
int flags;
|
int flags;
|
||||||
float alpha;
|
float alpha;
|
||||||
float cornerRadius;
|
float cornerRadius;
|
||||||
@@ -224,6 +199,13 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
* @param surface The surface to modify.
|
* @param surface The surface to modify.
|
||||||
*/
|
*/
|
||||||
public Builder(SurfaceControlCompat surface) {
|
public Builder(SurfaceControlCompat surface) {
|
||||||
|
this(surface.mSurfaceControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param surface The surface to modify.
|
||||||
|
*/
|
||||||
|
public Builder(SurfaceControl surface) {
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,11 +299,12 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
*/
|
*/
|
||||||
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, float cornerRadius) {
|
||||||
this(surface, FLAG_ALL & ~(FLAG_VISIBILITY | FLAG_BACKGROUND_BLUR_RADIUS), alpha,
|
this(surface.mSurfaceControl,
|
||||||
|
FLAG_ALL & ~(FLAG_VISIBILITY | FLAG_BACKGROUND_BLUR_RADIUS), alpha,
|
||||||
matrix, windowCrop, layer, cornerRadius, 0 /* backgroundBlurRadius */, true);
|
matrix, windowCrop, layer, cornerRadius, 0 /* backgroundBlurRadius */, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SurfaceParams(SurfaceControlCompat 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, float cornerRadius, int backgroundBlurRadius,
|
||||||
boolean visible) {
|
boolean visible) {
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
@@ -336,8 +319,9 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final int flags;
|
private final int flags;
|
||||||
|
private final float[] mTmpValues = new float[9];
|
||||||
|
|
||||||
public final SurfaceControlCompat surface;
|
public final SurfaceControl surface;
|
||||||
public final float alpha;
|
public final float alpha;
|
||||||
public final float cornerRadius;
|
public final float cornerRadius;
|
||||||
public final int backgroundBlurRadius;
|
public final int backgroundBlurRadius;
|
||||||
@@ -345,5 +329,33 @@ public class SyncRtSurfaceTransactionApplierCompat {
|
|||||||
public final Rect windowCrop;
|
public final Rect windowCrop;
|
||||||
public final int layer;
|
public final int layer;
|
||||||
public final boolean visible;
|
public final boolean visible;
|
||||||
|
|
||||||
|
public void applyTo(SurfaceControl.Transaction t) {
|
||||||
|
if ((flags & FLAG_MATRIX) != 0) {
|
||||||
|
t.setMatrix(surface, matrix, mTmpValues);
|
||||||
|
}
|
||||||
|
if ((flags & FLAG_WINDOW_CROP) != 0) {
|
||||||
|
t.setWindowCrop(surface, windowCrop);
|
||||||
|
}
|
||||||
|
if ((flags & FLAG_ALPHA) != 0) {
|
||||||
|
t.setAlpha(surface, alpha);
|
||||||
|
}
|
||||||
|
if ((flags & FLAG_LAYER) != 0) {
|
||||||
|
t.setLayer(surface, layer);
|
||||||
|
}
|
||||||
|
if ((flags & FLAG_CORNER_RADIUS) != 0) {
|
||||||
|
t.setCornerRadius(surface, cornerRadius);
|
||||||
|
}
|
||||||
|
if ((flags & FLAG_BACKGROUND_BLUR_RADIUS) != 0) {
|
||||||
|
t.setBackgroundBlurRadius(surface, backgroundBlurRadius);
|
||||||
|
}
|
||||||
|
if ((flags & FLAG_VISIBILITY) != 0) {
|
||||||
|
if (visible) {
|
||||||
|
t.show(surface);
|
||||||
|
} else {
|
||||||
|
t.hide(surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,8 @@ package com.android.systemui.shared.system;
|
|||||||
|
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.SurfaceControl.Transaction;
|
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
import android.view.SurfaceControl.Transaction;
|
||||||
|
|
||||||
public class TransactionCompat {
|
public class TransactionCompat {
|
||||||
|
|
||||||
@@ -109,4 +108,13 @@ public class TransactionCompat {
|
|||||||
mTransaction.setColor(surfaceControl.mSurfaceControl, color);
|
mTransaction.setColor(surfaceControl.mSurfaceControl, color);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deferTransactionUntil(Transaction t, SurfaceControl surfaceControl,
|
||||||
|
SurfaceControl barrier, long frameNumber) {
|
||||||
|
t.deferTransactionUntil(surfaceControl, barrier, frameNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setEarlyWakeup(Transaction t) {
|
||||||
|
t.setEarlyWakeup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License
|
||||||
|
*/
|
||||||
|
package com.android.systemui.shared.system;
|
||||||
|
|
||||||
|
import android.view.SurfaceControl;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewRootImpl;
|
||||||
|
|
||||||
|
import java.util.function.LongConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to expose some ViewRoomImpl methods
|
||||||
|
*/
|
||||||
|
public class ViewRootImplCompat {
|
||||||
|
|
||||||
|
private final ViewRootImpl mViewRoot;
|
||||||
|
|
||||||
|
public ViewRootImplCompat(View view) {
|
||||||
|
mViewRoot = view == null ? null : view.getViewRootImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SurfaceControl getRenderSurfaceControl() {
|
||||||
|
return mViewRoot == null ? null : mViewRoot.getRenderSurfaceControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SurfaceControl getSurfaceControl() {
|
||||||
|
return mViewRoot == null ? null : mViewRoot.getSurfaceControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid() {
|
||||||
|
return mViewRoot != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View getView() {
|
||||||
|
return mViewRoot == null ? null : mViewRoot.getView();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerRtFrameCallback(LongConsumer callback) {
|
||||||
|
if (mViewRoot != null) {
|
||||||
|
mViewRoot.registerRtFrameCallback(callback::accept);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user