am f57c1388: Merge "SurfaceFlinger: fix layer removal race condition" into ics-mr1

* commit 'f57c1388860486a70cc773f2cfeaa3ea3b38a473':
  SurfaceFlinger: fix layer removal race condition
This commit is contained in:
Jesse Hall 2011-12-02 18:33:14 -08:00 committed by Android Git Automerger
commit 19a586f70a
2 changed files with 10 additions and 1 deletions

View File

@ -710,6 +710,14 @@ void SurfaceFlinger::computeVisibleRegions(
void SurfaceFlinger::commitTransaction() void SurfaceFlinger::commitTransaction()
{ {
if (!mLayersPendingRemoval.isEmpty()) {
// Notify removed layers now that they can't be drawn from
for (size_t i = 0; i < mLayersPendingRemoval.size(); i++) {
mLayersPendingRemoval[i]->onRemoved();
}
mLayersPendingRemoval.clear();
}
mDrawingState = mCurrentState; mDrawingState = mCurrentState;
mTransationPending = false; mTransationPending = false;
mTransactionCV.broadcast(); mTransactionCV.broadcast();
@ -1162,7 +1170,7 @@ status_t SurfaceFlinger::purgatorizeLayer_l(const sp<LayerBase>& layerBase)
mLayerPurgatory.add(layerBase); mLayerPurgatory.add(layerBase);
} }
layerBase->onRemoved(); mLayersPendingRemoval.push(layerBase);
// it's possible that we don't find a layer, because it might // it's possible that we don't find a layer, because it might
// have been destroyed already -- this is not technically an error // have been destroyed already -- this is not technically an error

View File

@ -345,6 +345,7 @@ private:
Condition mTransactionCV; Condition mTransactionCV;
SortedVector< sp<LayerBase> > mLayerPurgatory; SortedVector< sp<LayerBase> > mLayerPurgatory;
bool mTransationPending; bool mTransationPending;
Vector< sp<LayerBase> > mLayersPendingRemoval;
// protected by mStateLock (but we could use another lock) // protected by mStateLock (but we could use another lock)
GraphicPlane mGraphicPlanes[1]; GraphicPlane mGraphicPlanes[1];