From 1bbafb96101de04c43adb5e3ca2494070d20a46a Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 11 Mar 2011 16:54:47 -0800 Subject: [PATCH] Fix some const-ness and comments mDrawingState doesn't need to be accessed by the mStateLock, because by definition it's only accessed from the main thread. Similarily, the list of layers in the drawing state cannot change (ie: is const). Change-Id: I2e5da7f4d8caee7af7802b432cd45cc81c7c08b0 --- services/surfaceflinger/SurfaceFlinger.cpp | 12 +++++------- services/surfaceflinger/SurfaceFlinger.h | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index a9fa1ef42..ea283c606 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -600,7 +600,7 @@ sp SurfaceFlinger::getFreezeLock() const } void SurfaceFlinger::computeVisibleRegions( - LayerVector& currentLayers, Region& dirtyRegion, Region& opaqueRegion) + const LayerVector& currentLayers, Region& dirtyRegion, Region& opaqueRegion) { const GraphicPlane& plane(graphicPlane(0)); const Transform& planeTransform(plane.transform()); @@ -735,8 +735,7 @@ void SurfaceFlinger::commitTransaction() void SurfaceFlinger::handlePageFlip() { bool visibleRegions = mVisibleRegionsDirty; - LayerVector& currentLayers( - const_cast(mDrawingState.layersSortedByZ)); + const LayerVector& currentLayers(mDrawingState.layersSortedByZ); visibleRegions |= lockPageFlip(currentLayers); const DisplayHardware& hw = graphicPlane(0).displayHardware(); @@ -748,9 +747,8 @@ void SurfaceFlinger::handlePageFlip() /* * rebuild the visible layer list */ + const size_t count = currentLayers.size(); mVisibleLayersSortedByZ.clear(); - const LayerVector& currentLayers(mDrawingState.layersSortedByZ); - size_t count = currentLayers.size(); mVisibleLayersSortedByZ.setCapacity(count); for (size_t i=0 ; ivisibleRegionScreen.isEmpty()) @@ -2515,7 +2513,7 @@ ssize_t UserClient::getTokenForSurface(const sp& sur) const } break; } - if (++name >= SharedBufferStack::NUM_LAYERS_MAX) + if (++name >= int32_t(SharedBufferStack::NUM_LAYERS_MAX)) name = NO_MEMORY; } while(name >= 0); @@ -2562,7 +2560,7 @@ sp GraphicBufferAlloc::createGraphicBuffer(uint32_t w, uint32_t h void GraphicBufferAlloc::freeAllGraphicBuffersExcept(int bufIdx) { Mutex::Autolock _l(mLock); - if (0 <= bufIdx && bufIdx < mBuffers.size()) { + if (bufIdx >= 0 && size_t(bufIdx) < mBuffers.size()) { sp b(mBuffers[bufIdx]); mBuffers.clear(); mBuffers.add(b); diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 95668190f..0964848ed 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -304,7 +304,7 @@ private: Vector< sp >& ditchedLayers); void computeVisibleRegions( - LayerVector& currentLayers, + const LayerVector& currentLayers, Region& dirtyRegion, Region& wormholeRegion); @@ -371,7 +371,6 @@ private: // access must be protected by mStateLock mutable Mutex mStateLock; State mCurrentState; - State mDrawingState; volatile int32_t mTransactionFlags; volatile int32_t mTransactionCount; Condition mTransactionCV; @@ -395,6 +394,7 @@ private: // Can only accessed from the main thread, these members // don't need synchronization + State mDrawingState; Region mDirtyRegion; Region mDirtyRegionRemovedLayer; Region mInvalidRegion;