addresses parts of 3096779 and 3097475

3097475: Animation setting should control the screen on animation
3096779: CRT power-on animation can briefly show the top app instead of lockscreen

There is now a parameter that controls wether the ON and/or OFF animation are
performed. we also always clear the screen to black on power off, to make
sure it won't briefly appear on power on.
HOWEVER, 3096779 is not 100% fixed in the case where we're doing the animation
because there is a race, where SF doesn't wait (b/c it doesn't know) for the
framework to have redrawn the lockscreen.

Change-Id: Ie0f02c9225fcdf24b1e8907e268eb7da2c5b0a03
This commit is contained in:
Mathias Agopian
2010-10-14 14:54:06 -07:00
parent 6d71f6a0ae
commit d4e03f3742
3 changed files with 37 additions and 19 deletions

View File

@@ -77,6 +77,11 @@ public:
eOrientationSwapMask = 0x01 eOrientationSwapMask = 0x01
}; };
enum {
eElectronBeamAnimationOn = 0x01,
eElectronBeamAnimationOff = 0x10
};
// flags for setOrientation // flags for setOrientation
enum { enum {
eOrientationAnimationDisable = 0x00000001 eOrientationAnimationDisable = 0x00000001

View File

@@ -80,7 +80,7 @@ SurfaceFlinger::SurfaceFlinger()
mVisibleRegionsDirty(false), mVisibleRegionsDirty(false),
mDeferReleaseConsole(false), mDeferReleaseConsole(false),
mFreezeDisplay(false), mFreezeDisplay(false),
mElectronBeamAnimation(false), mElectronBeamAnimationMode(0),
mFreezeCount(0), mFreezeCount(0),
mFreezeDisplayTime(0), mFreezeDisplayTime(0),
mDebugRegion(0), mDebugRegion(0),
@@ -424,8 +424,7 @@ void SurfaceFlinger::handleConsoleEvents()
hw.acquireScreen(); hw.acquireScreen();
// this is a temporary work-around, eventually this should be called // this is a temporary work-around, eventually this should be called
// by the power-manager // by the power-manager
if (mElectronBeamAnimation) SurfaceFlinger::turnElectronBeamOn(mElectronBeamAnimationMode);
SurfaceFlinger::turnElectronBeamOn(0);
} }
if (mDeferReleaseConsole && hw.isScreenAcquired()) { if (mDeferReleaseConsole && hw.isScreenAcquired()) {
@@ -1901,14 +1900,24 @@ status_t SurfaceFlinger::electronBeamOnAnimationImplLocked()
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
status_t SurfaceFlinger::turnElectronBeamOffImplLocked() status_t SurfaceFlinger::turnElectronBeamOffImplLocked(int32_t mode)
{ {
DisplayHardware& hw(graphicPlane(0).editDisplayHardware()); DisplayHardware& hw(graphicPlane(0).editDisplayHardware());
if (!hw.canDraw()) { if (!hw.canDraw()) {
// we're already off // we're already off
return NO_ERROR; return NO_ERROR;
} }
if (mode & ISurfaceComposer::eElectronBeamAnimationOff) {
electronBeamOffAnimationImplLocked(); electronBeamOffAnimationImplLocked();
}
// always clear the whole screen at the end of the animation
glClearColor(0,0,0,1);
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_SCISSOR_TEST);
hw.flip( Region(hw.bounds()) );
hw.setCanDraw(false); hw.setCanDraw(false);
return NO_ERROR; return NO_ERROR;
} }
@@ -1917,22 +1926,23 @@ status_t SurfaceFlinger::turnElectronBeamOff(int32_t mode)
{ {
class MessageTurnElectronBeamOff : public MessageBase { class MessageTurnElectronBeamOff : public MessageBase {
SurfaceFlinger* flinger; SurfaceFlinger* flinger;
int32_t mode;
status_t result; status_t result;
public: public:
MessageTurnElectronBeamOff(SurfaceFlinger* flinger) MessageTurnElectronBeamOff(SurfaceFlinger* flinger, int32_t mode)
: flinger(flinger), result(PERMISSION_DENIED) { : flinger(flinger), mode(mode), result(PERMISSION_DENIED) {
} }
status_t getResult() const { status_t getResult() const {
return result; return result;
} }
virtual bool handler() { virtual bool handler() {
Mutex::Autolock _l(flinger->mStateLock); Mutex::Autolock _l(flinger->mStateLock);
result = flinger->turnElectronBeamOffImplLocked(); result = flinger->turnElectronBeamOffImplLocked(mode);
return true; return true;
} }
}; };
sp<MessageBase> msg = new MessageTurnElectronBeamOff(this); sp<MessageBase> msg = new MessageTurnElectronBeamOff(this, mode);
status_t res = postMessageSync(msg); status_t res = postMessageSync(msg);
if (res == NO_ERROR) { if (res == NO_ERROR) {
res = static_cast<MessageTurnElectronBeamOff*>( msg.get() )->getResult(); res = static_cast<MessageTurnElectronBeamOff*>( msg.get() )->getResult();
@@ -1940,21 +1950,23 @@ status_t SurfaceFlinger::turnElectronBeamOff(int32_t mode)
// work-around: when the power-manager calls us we activate the // work-around: when the power-manager calls us we activate the
// animation. eventually, the "on" animation will be called // animation. eventually, the "on" animation will be called
// by the power-manager itself // by the power-manager itself
mElectronBeamAnimation = true; mElectronBeamAnimationMode = mode;
} }
return res; return res;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
status_t SurfaceFlinger::turnElectronBeamOnImplLocked() status_t SurfaceFlinger::turnElectronBeamOnImplLocked(int32_t mode)
{ {
DisplayHardware& hw(graphicPlane(0).editDisplayHardware()); DisplayHardware& hw(graphicPlane(0).editDisplayHardware());
if (hw.canDraw()) { if (hw.canDraw()) {
// we're already on // we're already on
return NO_ERROR; return NO_ERROR;
} }
if (mode & ISurfaceComposer::eElectronBeamAnimationOn) {
electronBeamOnAnimationImplLocked(); electronBeamOnAnimationImplLocked();
}
hw.setCanDraw(true); hw.setCanDraw(true);
// make sure to redraw the whole screen when the animation is done // make sure to redraw the whole screen when the animation is done
@@ -1968,22 +1980,23 @@ status_t SurfaceFlinger::turnElectronBeamOn(int32_t mode)
{ {
class MessageTurnElectronBeamOn : public MessageBase { class MessageTurnElectronBeamOn : public MessageBase {
SurfaceFlinger* flinger; SurfaceFlinger* flinger;
int32_t mode;
status_t result; status_t result;
public: public:
MessageTurnElectronBeamOn(SurfaceFlinger* flinger) MessageTurnElectronBeamOn(SurfaceFlinger* flinger, int32_t mode)
: flinger(flinger), result(PERMISSION_DENIED) { : flinger(flinger), mode(mode), result(PERMISSION_DENIED) {
} }
status_t getResult() const { status_t getResult() const {
return result; return result;
} }
virtual bool handler() { virtual bool handler() {
Mutex::Autolock _l(flinger->mStateLock); Mutex::Autolock _l(flinger->mStateLock);
result = flinger->turnElectronBeamOnImplLocked(); result = flinger->turnElectronBeamOnImplLocked(mode);
return true; return true;
} }
}; };
postMessageAsync( new MessageTurnElectronBeamOn(this) ); postMessageAsync( new MessageTurnElectronBeamOn(this, mode) );
return NO_ERROR; return NO_ERROR;
} }

View File

@@ -328,8 +328,8 @@ private:
uint32_t* width, uint32_t* height, PixelFormat* format, uint32_t* width, uint32_t* height, PixelFormat* format,
uint32_t reqWidth = 0, uint32_t reqHeight = 0); uint32_t reqWidth = 0, uint32_t reqHeight = 0);
status_t turnElectronBeamOffImplLocked(); status_t turnElectronBeamOffImplLocked(int32_t mode);
status_t turnElectronBeamOnImplLocked(); status_t turnElectronBeamOnImplLocked(int32_t mode);
status_t electronBeamOffAnimationImplLocked(); status_t electronBeamOffAnimationImplLocked();
status_t electronBeamOnAnimationImplLocked(); status_t electronBeamOnAnimationImplLocked();
status_t renderScreenToTextureLocked(DisplayID dpy, status_t renderScreenToTextureLocked(DisplayID dpy,
@@ -395,7 +395,7 @@ private:
bool mVisibleRegionsDirty; bool mVisibleRegionsDirty;
bool mDeferReleaseConsole; bool mDeferReleaseConsole;
bool mFreezeDisplay; bool mFreezeDisplay;
bool mElectronBeamAnimation; int32_t mElectronBeamAnimationMode;
int32_t mFreezeCount; int32_t mFreezeCount;
nsecs_t mFreezeDisplayTime; nsecs_t mFreezeDisplayTime;
Vector< sp<LayerBase> > mVisibleLayersSortedByZ; Vector< sp<LayerBase> > mVisibleLayersSortedByZ;