diff options
| author | 2011-10-21 15:18:28 -0700 | |
|---|---|---|
| committer | 2011-10-21 15:41:01 -0700 | |
| commit | 6497eabf0eaba7eb239431043b32365fb0daa7a1 (patch) | |
| tree | a43723253c7dad1fa8cb574239815ff505ee901d | |
| parent | 8bf89f305eb3a2010b1a63048a4aa18ccbc42e78 (diff) | |
mDirtyRegion is single threaded, but could be accessed from a hwc thread
We now have mInvalidateRegion which holds the region to invalidate, it
can be set from any thread as long as mInvalidateLock is held. We use
fine-grained locking here because mInvalidateRegion can be set from anywhere,
in particular frmo HWC callbacks.
Bug: 5466774
Change-Id: Iafca20aa3f5b25a87755e65bde7b769aa8f997bc
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 18 | ||||
| -rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 7 |
2 files changed, 23 insertions, 2 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 4b2866cb67fc..ba8f6308b1a0 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -788,6 +788,8 @@ void SurfaceFlinger::handlePageFlip() } unlockPageFlip(currentLayers); + + mDirtyRegion.orSelf(getAndClearInvalidateRegion()); mDirtyRegion.andSelf(screenRegion); } @@ -1798,12 +1800,24 @@ status_t SurfaceFlinger::onTransact( } void SurfaceFlinger::repaintEverything() { - Mutex::Autolock _l(mStateLock); const DisplayHardware& hw(graphicPlane(0).displayHardware()); - mDirtyRegion.set(hw.bounds()); + const Rect bounds(hw.getBounds()); + setInvalidateRegion(Region(bounds)); signalEvent(); } +void SurfaceFlinger::setInvalidateRegion(const Region& reg) { + Mutex::Autolock _l(mInvalidateLock); + mInvalidateRegion = reg; +} + +Region SurfaceFlinger::getAndClearInvalidateRegion() { + Mutex::Autolock _l(mInvalidateLock); + Region reg(mInvalidateRegion); + mInvalidateRegion.clear(); + return reg; +} + // --------------------------------------------------------------------------- status_t SurfaceFlinger::renderScreenToTexture(DisplayID dpy, diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 3c8f4e5ccf40..3284fdba999a 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -308,6 +308,9 @@ private: void composeSurfaces(const Region& dirty); + void setInvalidateRegion(const Region& reg); + Region getAndClearInvalidateRegion(); + ssize_t addClientLayer(const sp<Client>& client, const sp<LayerBaseClient>& lbc); status_t addLayer_l(const sp<LayerBase>& layer); @@ -367,6 +370,10 @@ private: bool mLayersRemoved; DefaultKeyedVector< wp<IBinder>, wp<Layer> > mLayerMap; + // access must be protected by mInvalidateLock + mutable Mutex mInvalidateLock; + Region mInvalidateRegion; + // constant members (no synchronization needed for access) sp<IMemoryHeap> mServerHeap; surface_flinger_cblk_t* mServerCblk; |