Merge "Log display white balance in animator" into qt-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
5ba87c154e
@@ -589,16 +589,18 @@ public final class ColorDisplayService extends SystemService {
|
|||||||
if (immediate) {
|
if (immediate) {
|
||||||
dtm.setColorMatrix(tintController.getLevel(), to);
|
dtm.setColorMatrix(tintController.getLevel(), to);
|
||||||
} else {
|
} else {
|
||||||
tintController.setAnimator(ValueAnimator.ofObject(COLOR_MATRIX_EVALUATOR,
|
TintValueAnimator valueAnimator = TintValueAnimator.ofMatrix(COLOR_MATRIX_EVALUATOR,
|
||||||
from == null ? MATRIX_IDENTITY : from, to));
|
from == null ? MATRIX_IDENTITY : from, to);
|
||||||
tintController.getAnimator().setDuration(TRANSITION_DURATION);
|
tintController.setAnimator(valueAnimator);
|
||||||
tintController.getAnimator().setInterpolator(AnimationUtils.loadInterpolator(
|
valueAnimator.setDuration(TRANSITION_DURATION);
|
||||||
|
valueAnimator.setInterpolator(AnimationUtils.loadInterpolator(
|
||||||
getContext(), android.R.interpolator.fast_out_slow_in));
|
getContext(), android.R.interpolator.fast_out_slow_in));
|
||||||
tintController.getAnimator().addUpdateListener((ValueAnimator animator) -> {
|
valueAnimator.addUpdateListener((ValueAnimator animator) -> {
|
||||||
final float[] value = (float[]) animator.getAnimatedValue();
|
final float[] value = (float[]) animator.getAnimatedValue();
|
||||||
dtm.setColorMatrix(tintController.getLevel(), value);
|
dtm.setColorMatrix(tintController.getLevel(), value);
|
||||||
|
((TintValueAnimator) animator).updateMinMaxComponents();
|
||||||
});
|
});
|
||||||
tintController.getAnimator().addListener(new AnimatorListenerAdapter() {
|
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
||||||
|
|
||||||
private boolean mIsCancelled;
|
private boolean mIsCancelled;
|
||||||
|
|
||||||
@@ -609,9 +611,14 @@ public final class ColorDisplayService extends SystemService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animator) {
|
public void onAnimationEnd(Animator animator) {
|
||||||
|
TintValueAnimator t = (TintValueAnimator) animator;
|
||||||
Slog.d(TAG, tintController.getClass().getSimpleName()
|
Slog.d(TAG, tintController.getClass().getSimpleName()
|
||||||
+ " Animation cancelled: " + mIsCancelled
|
+ " Animation cancelled: " + mIsCancelled
|
||||||
+ " to matrix: " + TintController.matrixToString(to, 16));
|
+ " to matrix: " + TintController.matrixToString(to, 16)
|
||||||
|
+ " min matrix coefficients: "
|
||||||
|
+ TintController.matrixToString(t.getMin(), 16)
|
||||||
|
+ " max matrix coefficients: "
|
||||||
|
+ TintController.matrixToString(t.getMax(), 16));
|
||||||
if (!mIsCancelled) {
|
if (!mIsCancelled) {
|
||||||
// Ensure final color matrix is set at the end of the animation. If the
|
// Ensure final color matrix is set at the end of the animation. If the
|
||||||
// animation is cancelled then don't set the final color matrix so the new
|
// animation is cancelled then don't set the final color matrix so the new
|
||||||
@@ -621,7 +628,7 @@ public final class ColorDisplayService extends SystemService {
|
|||||||
tintController.setAnimator(null);
|
tintController.setAnimator(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tintController.getAnimator().start();
|
valueAnimator.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1108,6 +1115,51 @@ public final class ColorDisplayService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only animates matrices and saves min and max coefficients for logging.
|
||||||
|
*/
|
||||||
|
static class TintValueAnimator extends ValueAnimator {
|
||||||
|
private float[] min;
|
||||||
|
private float[] max;
|
||||||
|
|
||||||
|
public static TintValueAnimator ofMatrix(ColorMatrixEvaluator evaluator,
|
||||||
|
Object... values) {
|
||||||
|
TintValueAnimator anim = new TintValueAnimator();
|
||||||
|
anim.setObjectValues(values);
|
||||||
|
anim.setEvaluator(evaluator);
|
||||||
|
if (values == null || values.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
float[] m = (float[]) values[0];
|
||||||
|
anim.min = new float[m.length];
|
||||||
|
anim.max = new float[m.length];
|
||||||
|
for (int i = 0; i < m.length; ++i) {
|
||||||
|
anim.min[i] = Float.MAX_VALUE;
|
||||||
|
anim.max[i] = Float.MIN_VALUE;
|
||||||
|
}
|
||||||
|
return anim;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMinMaxComponents() {
|
||||||
|
float[] value = (float[]) getAnimatedValue();
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < value.length; ++i) {
|
||||||
|
min[i] = Math.min(min[i], value[i]);
|
||||||
|
max[i] = Math.max(max[i], value[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float[] getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interpolates between two 4x4 color transform matrices (in column-major order).
|
* Interpolates between two 4x4 color transform matrices (in column-major order).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ import java.io.PrintWriter;
|
|||||||
|
|
||||||
abstract class TintController {
|
abstract class TintController {
|
||||||
|
|
||||||
private ValueAnimator mAnimator;
|
private ColorDisplayService.TintValueAnimator mAnimator;
|
||||||
private Boolean mIsActivated;
|
private Boolean mIsActivated;
|
||||||
|
|
||||||
public ValueAnimator getAnimator() {
|
public ColorDisplayService.TintValueAnimator getAnimator() {
|
||||||
return mAnimator;
|
return mAnimator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAnimator(ValueAnimator animator) {
|
public void setAnimator(ColorDisplayService.TintValueAnimator animator) {
|
||||||
mAnimator = animator;
|
mAnimator = animator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user