Merge "Add additional tracing for nav button backgrounds" into rvc-dev am: e184e6c819
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11869885 Change-Id: Ifa694188a8b88b40cacb6ccc2a7929f92da376cc
This commit is contained in:
@@ -28,7 +28,7 @@ import android.graphics.PixelFormat;
|
|||||||
import android.graphics.RecordingCanvas;
|
import android.graphics.RecordingCanvas;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.os.Trace;
|
||||||
import android.view.RenderNodeAnimator;
|
import android.view.RenderNodeAnimator;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
@@ -74,6 +74,11 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
private final HashSet<Animator> mRunningAnimations = new HashSet<>();
|
private final HashSet<Animator> mRunningAnimations = new HashSet<>();
|
||||||
private final ArrayList<Animator> mTmpArray = new ArrayList<>();
|
private final ArrayList<Animator> mTmpArray = new ArrayList<>();
|
||||||
|
|
||||||
|
private final TraceAnimatorListener mExitHwTraceAnimator =
|
||||||
|
new TraceAnimatorListener("exitHardware");
|
||||||
|
private final TraceAnimatorListener mEnterHwTraceAnimator =
|
||||||
|
new TraceAnimatorListener("enterHardware");
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
OVAL,
|
OVAL,
|
||||||
ROUNDED_RECT
|
ROUNDED_RECT
|
||||||
@@ -221,7 +226,7 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void jumpToCurrentState() {
|
public void jumpToCurrentState() {
|
||||||
cancelAnimations("jumpToCurrentState");
|
endAnimations("jumpToCurrentState", false /* cancel */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -235,7 +240,6 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPressed(boolean pressed) {
|
public void setPressed(boolean pressed) {
|
||||||
Log.d("b/63783866", "KeyButtonRipple.setPressed: pressed=" + pressed);
|
|
||||||
if (mDark != mLastDark && pressed) {
|
if (mDark != mLastDark && pressed) {
|
||||||
mRipplePaint = null;
|
mRipplePaint = null;
|
||||||
mLastDark = mDark;
|
mLastDark = mDark;
|
||||||
@@ -255,14 +259,19 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
mHandler.removeCallbacksAndMessages(null);
|
mHandler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelAnimations(String reason) {
|
private void endAnimations(String reason, boolean cancel) {
|
||||||
Log.d("b/63783866", "KeyButtonRipple.cancelAnimations: reason=" + reason);
|
Trace.beginSection("KeyButtonRipple.endAnim: reason=" + reason + " cancel=" + cancel);
|
||||||
|
Trace.endSection();
|
||||||
mVisible = false;
|
mVisible = false;
|
||||||
mTmpArray.addAll(mRunningAnimations);
|
mTmpArray.addAll(mRunningAnimations);
|
||||||
int size = mTmpArray.size();
|
int size = mTmpArray.size();
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
Animator a = mTmpArray.get(i);
|
Animator a = mTmpArray.get(i);
|
||||||
a.cancel();
|
if (cancel) {
|
||||||
|
a.cancel();
|
||||||
|
} else {
|
||||||
|
a.end();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mTmpArray.clear();
|
mTmpArray.clear();
|
||||||
mRunningAnimations.clear();
|
mRunningAnimations.clear();
|
||||||
@@ -287,7 +296,7 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enterSoftware() {
|
private void enterSoftware() {
|
||||||
cancelAnimations("enterSoftware");
|
endAnimations("enterSoftware", true /* cancel */);
|
||||||
mVisible = true;
|
mVisible = true;
|
||||||
mGlowAlpha = getMaxGlowAlpha();
|
mGlowAlpha = getMaxGlowAlpha();
|
||||||
ObjectAnimator scaleAnimator = ObjectAnimator.ofFloat(this, "glowScale",
|
ObjectAnimator scaleAnimator = ObjectAnimator.ofFloat(this, "glowScale",
|
||||||
@@ -373,8 +382,7 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enterHardware() {
|
private void enterHardware() {
|
||||||
Log.d("b/63783866", "enterHardware");
|
endAnimations("enterHardware", true /* cancel */);
|
||||||
cancelAnimations("enterHardware");
|
|
||||||
mVisible = true;
|
mVisible = true;
|
||||||
mDrawingHardwareGlow = true;
|
mDrawingHardwareGlow = true;
|
||||||
setExtendStart(CanvasProperty.createFloat(getExtendSize() / 2));
|
setExtendStart(CanvasProperty.createFloat(getExtendSize() / 2));
|
||||||
@@ -391,6 +399,7 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
endAnim.setDuration(ANIMATION_DURATION_SCALE);
|
endAnim.setDuration(ANIMATION_DURATION_SCALE);
|
||||||
endAnim.setInterpolator(mInterpolator);
|
endAnim.setInterpolator(mInterpolator);
|
||||||
endAnim.addListener(mAnimatorListener);
|
endAnim.addListener(mAnimatorListener);
|
||||||
|
endAnim.addListener(mEnterHwTraceAnimator);
|
||||||
endAnim.setTarget(mTargetView);
|
endAnim.setTarget(mTargetView);
|
||||||
|
|
||||||
if (isHorizontal()) {
|
if (isHorizontal()) {
|
||||||
@@ -426,13 +435,13 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void exitHardware() {
|
private void exitHardware() {
|
||||||
Log.d("b/63783866", "exitHardware");
|
|
||||||
mPaintProp = CanvasProperty.createPaint(getRipplePaint());
|
mPaintProp = CanvasProperty.createPaint(getRipplePaint());
|
||||||
final RenderNodeAnimator opacityAnim = new RenderNodeAnimator(mPaintProp,
|
final RenderNodeAnimator opacityAnim = new RenderNodeAnimator(mPaintProp,
|
||||||
RenderNodeAnimator.PAINT_ALPHA, 0);
|
RenderNodeAnimator.PAINT_ALPHA, 0);
|
||||||
opacityAnim.setDuration(ANIMATION_DURATION_FADE);
|
opacityAnim.setDuration(ANIMATION_DURATION_FADE);
|
||||||
opacityAnim.setInterpolator(Interpolators.ALPHA_OUT);
|
opacityAnim.setInterpolator(Interpolators.ALPHA_OUT);
|
||||||
opacityAnim.addListener(mAnimatorListener);
|
opacityAnim.addListener(mAnimatorListener);
|
||||||
|
opacityAnim.addListener(mExitHwTraceAnimator);
|
||||||
opacityAnim.setTarget(mTargetView);
|
opacityAnim.setTarget(mTargetView);
|
||||||
|
|
||||||
opacityAnim.start();
|
opacityAnim.start();
|
||||||
@@ -443,16 +452,41 @@ public class KeyButtonRipple extends Drawable {
|
|||||||
|
|
||||||
private final AnimatorListenerAdapter mAnimatorListener =
|
private final AnimatorListenerAdapter mAnimatorListener =
|
||||||
new AnimatorListenerAdapter() {
|
new AnimatorListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animator animation) {
|
||||||
|
mRunningAnimations.remove(animation);
|
||||||
|
if (mRunningAnimations.isEmpty() && !mPressed) {
|
||||||
|
mVisible = false;
|
||||||
|
mDrawingHardwareGlow = false;
|
||||||
|
invalidateSelf();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final class TraceAnimatorListener extends AnimatorListenerAdapter {
|
||||||
|
private final String mName;
|
||||||
|
TraceAnimatorListener(String name) {
|
||||||
|
mName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animator animation) {
|
||||||
|
Trace.beginSection("KeyButtonRipple.start." + mName);
|
||||||
|
Trace.endSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationCancel(Animator animation) {
|
||||||
|
Trace.beginSection("KeyButtonRipple.cancel." + mName);
|
||||||
|
Trace.endSection();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
mRunningAnimations.remove(animation);
|
Trace.beginSection("KeyButtonRipple.end." + mName);
|
||||||
if (mRunningAnimations.isEmpty() && !mPressed) {
|
Trace.endSection();
|
||||||
mVisible = false;
|
|
||||||
mDrawingHardwareGlow = false;
|
|
||||||
invalidateSelf();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interpolator with a smooth log deceleration
|
* Interpolator with a smooth log deceleration
|
||||||
|
|||||||
Reference in New Issue
Block a user