diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 95 |
1 files changed, 58 insertions, 37 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 492d1cf..13b2c6b 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -86,7 +86,8 @@ const String16 sDump("android.permission.DUMP"); SurfaceFlinger::SurfaceFlinger() : BnSurfaceComposer(), Thread(false), mTransactionFlags(0), - mTransationPending(false), + mTransactionPending(false), + mAnimTransactionPending(false), mLayersRemoved(false), mRepaintEverything(0), mBootTime(systemTime()), @@ -506,7 +507,7 @@ status_t SurfaceFlinger::readyToRun() // or when a texture is (asynchronously) destroyed, and for that // we need a valid surface, so it's convenient to use the main display // for that. - sp<const DisplayDevice> hw = getDefaultDisplayDevice(); + sp<const DisplayDevice> hw(getDefaultDisplayDevice()); // initialize OpenGL ES DisplayDevice::makeCurrent(mEGLDisplay, hw, mEGLContext); @@ -1125,7 +1126,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) // Call makeCurrent() on the primary display so we can // be sure that nothing associated with this display // is current. - const sp<const DisplayDevice>& hw(getDefaultDisplayDevice()); + const sp<const DisplayDevice> hw(getDefaultDisplayDevice()); DisplayDevice::makeCurrent(mEGLDisplay, hw, mEGLContext); mDisplays.removeItem(draw.keyAt(i)); getHwComposer().disconnectDisplay(draw[i].type); @@ -1149,7 +1150,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) continue; } - const sp<DisplayDevice>& disp(getDisplayDevice(display)); + const sp<DisplayDevice> disp(getDisplayDevice(display)); if (disp != NULL) { if (state.layerStack != draw[i].layerStack) { disp->setLayerStack(state.layerStack); @@ -1264,7 +1265,8 @@ void SurfaceFlinger::commitTransaction() } mDrawingState = mCurrentState; - mTransationPending = false; + mTransactionPending = false; + mAnimTransactionPending = false; mTransactionCV.broadcast(); } @@ -1665,6 +1667,21 @@ void SurfaceFlinger::setTransactionState( Mutex::Autolock _l(mStateLock); uint32_t transactionFlags = 0; + if (flags & eAnimation) { + // For window updates that are part of an animation we must wait for + // previous animation "frames" to be handled. + while (mAnimTransactionPending) { + status_t err = mTransactionCV.waitRelative(mStateLock, 500 * 1000); + if (CC_UNLIKELY(err != NO_ERROR)) { + // just in case something goes wrong in SF, return to the + // caller after a few hundred microseconds. + ALOGW_IF(err == TIMED_OUT, "setTransactionState timed out!"); + mAnimTransactionPending = false; + break; + } + } + } + size_t count = displays.size(); for (size_t i=0 ; i<count ; i++) { const DisplayState& s(displays[i]); @@ -1685,15 +1702,18 @@ void SurfaceFlinger::setTransactionState( // if this is a synchronous transaction, wait for it to take effect // before returning. if (flags & eSynchronous) { - mTransationPending = true; + mTransactionPending = true; + } + if (flags & eAnimation) { + mAnimTransactionPending = true; } - while (mTransationPending) { + while (mTransactionPending) { 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. - ALOGW_IF(err == TIMED_OUT, "closeGlobalTransaction timed out!"); - mTransationPending = false; + ALOGW_IF(err == TIMED_OUT, "setTransactionState timed out!"); + mTransactionPending = false; break; } } @@ -2023,48 +2043,48 @@ void SurfaceFlinger::onScreenReleased(const sp<const DisplayDevice>& hw) { void SurfaceFlinger::unblank(const sp<IBinder>& display) { class MessageScreenAcquired : public MessageBase { - SurfaceFlinger* mFlinger; - const sp<DisplayDevice>& mHw; + SurfaceFlinger& mFlinger; + sp<IBinder> mDisplay; public: - MessageScreenAcquired(SurfaceFlinger* flinger, - const sp<DisplayDevice>& hw) : mFlinger(flinger), mHw(hw) { } + MessageScreenAcquired(SurfaceFlinger& flinger, + const sp<IBinder>& disp) : mFlinger(flinger), mDisplay(disp) { } virtual bool handler() { - mFlinger->onScreenAcquired(mHw); + const sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay)); + if (hw == NULL) { + ALOGE("Attempt to unblank null display %p", mDisplay.get()); + } else if (hw->getDisplayType() >= DisplayDevice::NUM_DISPLAY_TYPES) { + ALOGW("Attempt to unblank virtual display"); + } else { + mFlinger.onScreenAcquired(hw); + } return true; } }; - const sp<DisplayDevice>& hw = getDisplayDevice(display); - if (hw == NULL) { - ALOGE("Attempt to unblank null display %p", display.get()); - } else if (hw->getDisplayType() >= DisplayDevice::NUM_DISPLAY_TYPES) { - ALOGW("Attempt to unblank virtual display"); - } else { - sp<MessageBase> msg = new MessageScreenAcquired(this, hw); - postMessageSync(msg); - } + sp<MessageBase> msg = new MessageScreenAcquired(*this, display); + postMessageSync(msg); } void SurfaceFlinger::blank(const sp<IBinder>& display) { class MessageScreenReleased : public MessageBase { - SurfaceFlinger* mFlinger; - const sp<DisplayDevice>& mHw; + SurfaceFlinger& mFlinger; + sp<IBinder> mDisplay; public: - MessageScreenReleased(SurfaceFlinger* flinger, - const sp<DisplayDevice>& hw) : mFlinger(flinger), mHw(hw) { } + MessageScreenReleased(SurfaceFlinger& flinger, + const sp<IBinder>& disp) : mFlinger(flinger), mDisplay(disp) { } virtual bool handler() { - mFlinger->onScreenReleased(mHw); + const sp<DisplayDevice> hw(mFlinger.getDisplayDevice(mDisplay)); + if (hw == NULL) { + ALOGE("Attempt to blank null display %p", mDisplay.get()); + } else if (hw->getDisplayType() >= DisplayDevice::NUM_DISPLAY_TYPES) { + ALOGW("Attempt to blank virtual display"); + } else { + mFlinger.onScreenReleased(hw); + } return true; } }; - const sp<DisplayDevice>& hw = getDisplayDevice(display); - if (hw == NULL) { - ALOGE("Attempt to blank null display %p", display.get()); - } else if (hw->getDisplayType() >= DisplayDevice::NUM_DISPLAY_TYPES) { - ALOGW("Attempt to blank virtual display"); - } else { - sp<MessageBase> msg = new MessageScreenReleased(this, hw); - postMessageSync(msg); - } + sp<MessageBase> msg = new MessageScreenReleased(*this, display); + postMessageSync(msg); } // --------------------------------------------------------------------------- @@ -2339,6 +2359,7 @@ void SurfaceFlinger::dumpAllLocked( const Vector< sp<LayerBase> >& SurfaceFlinger::getLayerSortedByZForHwcDisplay(int disp) { + // Note: mStateLock is held here return getDisplayDevice( getBuiltInDisplay(disp) )->getVisibleLayersSortedByZ(); } |