diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 141 |
1 files changed, 29 insertions, 112 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index ba8f630..1b00e93 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -80,15 +80,12 @@ const String16 sDump("android.permission.DUMP"); SurfaceFlinger::SurfaceFlinger() : BnSurfaceComposer(), Thread(false), mTransactionFlags(0), - mResizeTransationPending(false), + mTransationPending(false), mLayersRemoved(false), mBootTime(systemTime()), mVisibleRegionsDirty(false), mHwWorkListDirty(false), - mFreezeDisplay(false), mElectronBeamAnimationMode(0), - mFreezeCount(0), - mFreezeDisplayTime(0), mDebugRegion(0), mDebugBackground(0), mDebugDDMS(0), @@ -191,11 +188,6 @@ void SurfaceFlinger::binderDied(const wp<IBinder>& who) { // the window manager died on us. prepare its eulogy. - // unfreeze the screen in case it was... frozen - mFreezeDisplayTime = 0; - mFreezeCount = 0; - mFreezeDisplay = false; - // reset screen orientation setOrientation(0, eOrientationDefault, 0); @@ -323,33 +315,7 @@ void SurfaceFlinger::waitForEvent() { while (true) { nsecs_t timeout = -1; - const nsecs_t freezeDisplayTimeout = ms2ns(5000); - if (UNLIKELY(isFrozen())) { - // wait 5 seconds - const nsecs_t now = systemTime(); - if (mFreezeDisplayTime == 0) { - mFreezeDisplayTime = now; - } - nsecs_t waitTime = freezeDisplayTimeout - (now - mFreezeDisplayTime); - timeout = waitTime>0 ? waitTime : 0; - } - sp<MessageBase> msg = mEventQueue.waitMessage(timeout); - - // see if we timed out - if (isFrozen()) { - const nsecs_t now = systemTime(); - nsecs_t frozenTime = (now - mFreezeDisplayTime); - if (frozenTime >= freezeDisplayTimeout) { - // we timed out and are still frozen - LOGW("timeout expired mFreezeDisplay=%d, mFreezeCount=%d", - mFreezeDisplay, mFreezeCount); - mFreezeDisplayTime = 0; - mFreezeCount = 0; - mFreezeDisplay = false; - } - } - if (msg != 0) { switch (msg->what) { case MessageQueue::INVALIDATE: @@ -589,13 +555,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) mDirtyRegion.set(hw.bounds()); } - if (mCurrentState.freezeDisplay != mDrawingState.freezeDisplay) { - // freezing or unfreezing the display -> trigger animation if needed - mFreezeDisplay = mCurrentState.freezeDisplay; - if (mFreezeDisplay) - mFreezeDisplayTime = 0; - } - if (currentLayers.size() > mDrawingState.layersSortedByZ.size()) { // layers have been added mVisibleRegionsDirty = true; @@ -621,11 +580,6 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) commitTransaction(); } -sp<FreezeLock> SurfaceFlinger::getFreezeLock() const -{ - return new FreezeLock(const_cast<SurfaceFlinger *>(this)); -} - void SurfaceFlinger::computeVisibleRegions( const LayerVector& currentLayers, Region& dirtyRegion, Region& opaqueRegion) { @@ -755,7 +709,7 @@ void SurfaceFlinger::computeVisibleRegions( void SurfaceFlinger::commitTransaction() { mDrawingState = mCurrentState; - mResizeTransationPending = false; + mTransationPending = false; mTransactionCV.broadcast(); } @@ -1243,15 +1197,14 @@ uint32_t SurfaceFlinger::setTransactionFlags(uint32_t flags) void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state, - int orientation) { + int orientation, uint32_t flags) { Mutex::Autolock _l(mStateLock); - uint32_t flags = 0; + uint32_t transactionFlags = 0; if (mCurrentState.orientation != orientation) { if (uint32_t(orientation)<=eOrientation270 || orientation==42) { mCurrentState.orientation = orientation; - flags |= eTransactionNeeded; - mResizeTransationPending = true; + transactionFlags |= eTransactionNeeded; } else if (orientation != eOrientationUnchanged) { LOGW("setTransactionState: ignoring unrecognized orientation: %d", orientation); @@ -1262,56 +1215,31 @@ void SurfaceFlinger::setTransactionState(const Vector<ComposerState>& state, for (size_t i=0 ; i<count ; i++) { const ComposerState& s(state[i]); sp<Client> client( static_cast<Client *>(s.client.get()) ); - flags |= setClientStateLocked(client, s.state); - } - if (flags) { - setTransactionFlags(flags); - } - - signalEvent(); - - // if there is a transaction with a resize, wait for it to - // take effect before returning. - while (mResizeTransationPending) { - status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5)); - if (CC_UNLIKELY(err != NO_ERROR)) { - // just in case something goes wrong in SF, return to the - // called after a few seconds. - LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!"); - mResizeTransationPending = false; - break; + transactionFlags |= setClientStateLocked(client, s.state); + } + + if (transactionFlags) { + // this triggers the transaction + setTransactionFlags(transactionFlags); + + // if this is a synchronous transaction, wait for it to take effect + // before returning. + if (flags & eSynchronous) { + mTransationPending = true; + } + while (mTransationPending) { + status_t err = mTransactionCV.waitRelative(mStateLock, s2ns(5)); + if (CC_UNLIKELY(err != NO_ERROR)) { + // just in case something goes wrong in SF, return to the + // called after a few seconds. + LOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!"); + mTransationPending = false; + break; + } } } } -status_t SurfaceFlinger::freezeDisplay(DisplayID dpy, uint32_t flags) -{ - if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT)) - return BAD_VALUE; - - Mutex::Autolock _l(mStateLock); - mCurrentState.freezeDisplay = 1; - setTransactionFlags(eTransactionNeeded); - - // flags is intended to communicate some sort of animation behavior - // (for instance fading) - return NO_ERROR; -} - -status_t SurfaceFlinger::unfreezeDisplay(DisplayID dpy, uint32_t flags) -{ - if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT)) - return BAD_VALUE; - - Mutex::Autolock _l(mStateLock); - mCurrentState.freezeDisplay = 0; - setTransactionFlags(eTransactionNeeded); - - // flags is intended to communicate some sort of animation behavior - // (for instance fading) - return NO_ERROR; -} - int SurfaceFlinger::setOrientation(DisplayID dpy, int orientation, uint32_t flags) { @@ -1434,11 +1362,6 @@ sp<LayerScreenshot> SurfaceFlinger::createScreenshotSurface( uint32_t w, uint32_t h, uint32_t flags) { sp<LayerScreenshot> layer = new LayerScreenshot(this, display, client); - status_t err = layer->capture(); - if (err != NO_ERROR) { - layer.clear(); - LOGW("createScreenshotSurface failed (%s)", strerror(-err)); - } return layer; } @@ -1512,7 +1435,6 @@ uint32_t SurfaceFlinger::setClientStateLocked( if (what & eSizeChanged) { if (layer->setSize(s.w, s.h)) { flags |= eTraversalNeeded; - mResizeTransationPending = true; } } if (what & eAlphaChanged) { @@ -1632,8 +1554,7 @@ status_t SurfaceFlinger::dump(int fd, const Vector<String16>& args) mWormholeRegion.dump(result, "WormholeRegion"); const DisplayHardware& hw(graphicPlane(0).displayHardware()); snprintf(buffer, SIZE, - " display frozen: %s, freezeCount=%d, orientation=%d, canDraw=%d\n", - mFreezeDisplay?"yes":"no", mFreezeCount, + " orientation=%d, canDraw=%d\n", mCurrentState.orientation, hw.canDraw()); result.append(buffer); snprintf(buffer, SIZE, @@ -1693,8 +1614,6 @@ status_t SurfaceFlinger::onTransact( case CREATE_CONNECTION: case SET_TRANSACTION_STATE: case SET_ORIENTATION: - case FREEZE_DISPLAY: - case UNFREEZE_DISPLAY: case BOOT_FINISHED: case TURN_ELECTRON_BEAM_OFF: case TURN_ELECTRON_BEAM_ON: @@ -1766,10 +1685,6 @@ status_t SurfaceFlinger::onTransact( GraphicLog::getInstance().setEnabled(enabled); return NO_ERROR; } - case 1007: // set mFreezeCount - mFreezeCount = data.readInt32(); - mFreezeDisplayTime = 0; - return NO_ERROR; case 1008: // toggle use of hw composer n = data.readInt32(); mDebugDisableHWC = n ? 1 : 0; @@ -1866,8 +1781,10 @@ status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy, // redraw the screen entirely... glDisable(GL_TEXTURE_EXTERNAL_OES); glDisable(GL_TEXTURE_2D); + glDisable(GL_SCISSOR_TEST); glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_SCISSOR_TEST); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ); |