* commit '541d8d2c2bacb81440fb5b5a8766c1e25f1270a9': Improve the power off fade animation.
This commit is contained in:
@@ -206,11 +206,9 @@ final class DisplayPowerController {
|
|||||||
// May be 0 if no warm-up is required.
|
// May be 0 if no warm-up is required.
|
||||||
private int mLightSensorWarmUpTimeConfig;
|
private int mLightSensorWarmUpTimeConfig;
|
||||||
|
|
||||||
// True if we should animate the backlight when turning the screen on or off, which
|
// True if we should fade the screen while turning it off, false if we should play
|
||||||
// tends to be efficient for LCD displays but not for OLED displays.
|
// a stylish electron beam animation instead.
|
||||||
// False if we should play the electron beam animation instead, which is better for
|
private boolean mElectronBeamFadesConfig;
|
||||||
// OLED displays.
|
|
||||||
private boolean mElectronBeamAnimatesBacklightConfig;
|
|
||||||
|
|
||||||
// The pending power request.
|
// The pending power request.
|
||||||
// Initially null until the first call to requestPowerState.
|
// Initially null until the first call to requestPowerState.
|
||||||
@@ -396,7 +394,7 @@ final class DisplayPowerController {
|
|||||||
mScreenBrightnessRangeMinimum = clampAbsoluteBrightness(screenBrightnessMinimum);
|
mScreenBrightnessRangeMinimum = clampAbsoluteBrightness(screenBrightnessMinimum);
|
||||||
mScreenBrightnessRangeMaximum = PowerManager.BRIGHTNESS_ON;
|
mScreenBrightnessRangeMaximum = PowerManager.BRIGHTNESS_ON;
|
||||||
|
|
||||||
mElectronBeamAnimatesBacklightConfig = resources.getBoolean(
|
mElectronBeamFadesConfig = resources.getBoolean(
|
||||||
com.android.internal.R.bool.config_animateScreenLights);
|
com.android.internal.R.bool.config_animateScreenLights);
|
||||||
|
|
||||||
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
|
if (!DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT) {
|
||||||
@@ -682,8 +680,8 @@ final class DisplayPowerController {
|
|||||||
if (mPowerState.getElectronBeamLevel() == 1.0f) {
|
if (mPowerState.getElectronBeamLevel() == 1.0f) {
|
||||||
mPowerState.dismissElectronBeam();
|
mPowerState.dismissElectronBeam();
|
||||||
} else if (mPowerState.prepareElectronBeam(
|
} else if (mPowerState.prepareElectronBeam(
|
||||||
mElectronBeamAnimatesBacklightConfig ?
|
mElectronBeamFadesConfig ?
|
||||||
ElectronBeam.MODE_BLANK :
|
ElectronBeam.MODE_FADE :
|
||||||
ElectronBeam.MODE_WARM_UP)) {
|
ElectronBeam.MODE_WARM_UP)) {
|
||||||
mElectronBeamOnAnimator.start();
|
mElectronBeamOnAnimator.start();
|
||||||
} else {
|
} else {
|
||||||
@@ -704,8 +702,8 @@ final class DisplayPowerController {
|
|||||||
if (mPowerState.getElectronBeamLevel() == 0.0f) {
|
if (mPowerState.getElectronBeamLevel() == 0.0f) {
|
||||||
setScreenOn(false);
|
setScreenOn(false);
|
||||||
} else if (mPowerState.prepareElectronBeam(
|
} else if (mPowerState.prepareElectronBeam(
|
||||||
mElectronBeamAnimatesBacklightConfig ?
|
mElectronBeamFadesConfig ?
|
||||||
ElectronBeam.MODE_BLANK :
|
ElectronBeam.MODE_FADE :
|
||||||
ElectronBeam.MODE_COOL_DOWN)
|
ElectronBeam.MODE_COOL_DOWN)
|
||||||
&& mPowerState.isScreenOn()) {
|
&& mPowerState.isScreenOn()) {
|
||||||
mElectronBeamOffAnimator.start();
|
mElectronBeamOffAnimator.start();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ final class ElectronBeam {
|
|||||||
private EGLContext mEglContext;
|
private EGLContext mEglContext;
|
||||||
private EGLSurface mEglSurface;
|
private EGLSurface mEglSurface;
|
||||||
private boolean mSurfaceVisible;
|
private boolean mSurfaceVisible;
|
||||||
|
private float mSurfaceAlpha;
|
||||||
|
|
||||||
// Texture names. We only use one texture, which contains the screenshot.
|
// Texture names. We only use one texture, which contains the screenshot.
|
||||||
private final int[] mTexNames = new int[1];
|
private final int[] mTexNames = new int[1];
|
||||||
@@ -90,9 +91,20 @@ final class ElectronBeam {
|
|||||||
private final FloatBuffer mVertexBuffer = createNativeFloatBuffer(8);
|
private final FloatBuffer mVertexBuffer = createNativeFloatBuffer(8);
|
||||||
private final FloatBuffer mTexCoordBuffer = createNativeFloatBuffer(8);
|
private final FloatBuffer mTexCoordBuffer = createNativeFloatBuffer(8);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Animates an electron beam warming up.
|
||||||
|
*/
|
||||||
public static final int MODE_WARM_UP = 0;
|
public static final int MODE_WARM_UP = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Animates an electron beam shutting off.
|
||||||
|
*/
|
||||||
public static final int MODE_COOL_DOWN = 1;
|
public static final int MODE_COOL_DOWN = 1;
|
||||||
public static final int MODE_BLANK = 2;
|
|
||||||
|
/**
|
||||||
|
* Animates a simple dim layer to fade the contents of the screen in or out progressively.
|
||||||
|
*/
|
||||||
|
public static final int MODE_FADE = 2;
|
||||||
|
|
||||||
public ElectronBeam(Display display) {
|
public ElectronBeam(Display display) {
|
||||||
mDisplay = display;
|
mDisplay = display;
|
||||||
@@ -138,7 +150,7 @@ final class ElectronBeam {
|
|||||||
|
|
||||||
private boolean tryPrepare() {
|
private boolean tryPrepare() {
|
||||||
if (createSurface()) {
|
if (createSurface()) {
|
||||||
if (mMode == MODE_BLANK) {
|
if (mMode == MODE_FADE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return createEglContext()
|
return createEglContext()
|
||||||
@@ -182,7 +194,7 @@ final class ElectronBeam {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMode == MODE_BLANK) {
|
if (mMode == MODE_FADE) {
|
||||||
return showSurface(1.0f - level);
|
return showSurface(1.0f - level);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,7 +516,7 @@ final class ElectronBeam {
|
|||||||
if (mSurface == null) {
|
if (mSurface == null) {
|
||||||
try {
|
try {
|
||||||
int flags;
|
int flags;
|
||||||
if (mMode == MODE_BLANK) {
|
if (mMode == MODE_FADE) {
|
||||||
flags = Surface.FX_SURFACE_DIM | Surface.HIDDEN;
|
flags = Surface.FX_SURFACE_DIM | Surface.HIDDEN;
|
||||||
} else {
|
} else {
|
||||||
flags = Surface.OPAQUE | Surface.HIDDEN;
|
flags = Surface.OPAQUE | Surface.HIDDEN;
|
||||||
@@ -579,11 +591,12 @@ final class ElectronBeam {
|
|||||||
}
|
}
|
||||||
mSurface = null;
|
mSurface = null;
|
||||||
mSurfaceVisible = false;
|
mSurfaceVisible = false;
|
||||||
|
mSurfaceAlpha = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showSurface(float alpha) {
|
private boolean showSurface(float alpha) {
|
||||||
if (!mSurfaceVisible) {
|
if (!mSurfaceVisible || mSurfaceAlpha != alpha) {
|
||||||
Surface.openTransaction();
|
Surface.openTransaction();
|
||||||
try {
|
try {
|
||||||
mSurface.setLayer(ELECTRON_BEAM_LAYER);
|
mSurface.setLayer(ELECTRON_BEAM_LAYER);
|
||||||
@@ -593,6 +606,7 @@ final class ElectronBeam {
|
|||||||
Surface.closeTransaction();
|
Surface.closeTransaction();
|
||||||
}
|
}
|
||||||
mSurfaceVisible = true;
|
mSurfaceVisible = true;
|
||||||
|
mSurfaceAlpha = alpha;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -683,5 +697,6 @@ final class ElectronBeam {
|
|||||||
pw.println(" mDisplayWidth=" + mDisplayWidth);
|
pw.println(" mDisplayWidth=" + mDisplayWidth);
|
||||||
pw.println(" mDisplayHeight=" + mDisplayHeight);
|
pw.println(" mDisplayHeight=" + mDisplayHeight);
|
||||||
pw.println(" mSurfaceVisible=" + mSurfaceVisible);
|
pw.println(" mSurfaceVisible=" + mSurfaceVisible);
|
||||||
|
pw.println(" mSurfaceAlpha=" + mSurfaceAlpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user