am 50e79632: Merge "Remove ColorFade resouces when screen off." into mnc-dr-dev

* commit '50e796326a39cd15af9031a41e3fe30b1f0f35f6':
  Remove ColorFade resouces when screen off.
This commit is contained in:
Michael Lentine
2015-10-13 22:57:11 +00:00
committed by Android Git Automerger
3 changed files with 41 additions and 11 deletions

View File

@@ -74,6 +74,7 @@ final class ColorFade {
// Set to true when the animation context has been fully prepared. // Set to true when the animation context has been fully prepared.
private boolean mPrepared; private boolean mPrepared;
private boolean mCreatedResources;
private int mMode; private int mMode;
private final DisplayManagerInternal mDisplayManagerInternal; private final DisplayManagerInternal mDisplayManagerInternal;
@@ -169,6 +170,7 @@ final class ColorFade {
} }
// Done. // Done.
mCreatedResources = true;
mPrepared = true; mPrepared = true;
// Dejanking optimization. // Dejanking optimization.
@@ -312,6 +314,34 @@ final class ColorFade {
vtx.put(7, y); vtx.put(7, y);
} }
/**
* Dismisses the color fade animation resources.
*
* This function destroys the resources that are created for the color fade
* animation but does not clean up the surface.
*/
public void dismissResources() {
if (DEBUG) {
Slog.d(TAG, "dismissResources");
}
if (mCreatedResources) {
attachEglContext();
try {
destroyScreenshotTexture();
destroyGLShaders();
destroyGLBuffers();
destroyEglSurface();
} finally {
detachEglContext();
}
// This is being called with no active context so shouldn't be
// needed but is safer to not change for now.
GLES20.glFlush();
mCreatedResources = false;
}
}
/** /**
* Dismisses the color fade animation surface and cleans up. * Dismisses the color fade animation surface and cleans up.
* *
@@ -325,17 +355,8 @@ final class ColorFade {
} }
if (mPrepared) { if (mPrepared) {
attachEglContext(); dismissResources();
try {
destroyScreenshotTexture();
destroyGLShaders();
destroyGLBuffers();
destroyEglSurface();
} finally {
detachEglContext();
}
destroySurface(); destroySurface();
GLES20.glFlush();
mPrepared = false; mPrepared = false;
} }
} }

View File

@@ -837,6 +837,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
if (mPendingScreenOff && target != Display.STATE_OFF) { if (mPendingScreenOff && target != Display.STATE_OFF) {
setScreenState(Display.STATE_OFF); setScreenState(Display.STATE_OFF);
mPendingScreenOff = false; mPendingScreenOff = false;
mPowerState.dismissColorFadeResources();
} }
if (target == Display.STATE_ON) { if (target == Display.STATE_ON) {
@@ -910,6 +911,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
// A black surface is already hiding the contents of the screen. // A black surface is already hiding the contents of the screen.
setScreenState(Display.STATE_OFF); setScreenState(Display.STATE_OFF);
mPendingScreenOff = false; mPendingScreenOff = false;
mPowerState.dismissColorFadeResources();
} else if (performScreenOffTransition } else if (performScreenOffTransition
&& mPowerState.prepareColorFade(mContext, && mPowerState.prepareColorFade(mContext,
mColorFadeFadesConfig ? mColorFadeFadesConfig ?

View File

@@ -187,7 +187,7 @@ final class DisplayPowerState {
} }
/** /**
* Dismisses the electron beam surface. * Dismisses the color fade surface.
*/ */
public void dismissColorFade() { public void dismissColorFade() {
mColorFade.dismiss(); mColorFade.dismiss();
@@ -195,6 +195,13 @@ final class DisplayPowerState {
mColorFadeReady = true; mColorFadeReady = true;
} }
/**
* Dismisses the color fade resources.
*/
public void dismissColorFadeResources() {
mColorFade.dismissResources();
}
/** /**
* Sets the level of the electron beam steering current. * Sets the level of the electron beam steering current.
* *