Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Unified Diff: cc/prioritized_texture_manager.cc

Issue 11280268: Merge 170403 - Use a lock to deal with concurrent access to the m_evictedBackings (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/prioritized_texture_manager.h ('k') | cc/prioritized_texture_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/prioritized_texture_manager.cc
diff --git a/cc/prioritized_texture_manager.cc b/cc/prioritized_texture_manager.cc
index 19aa739efab0a3df9a4c78076aeec2e55b234560..7069a4b2d37a7dcdacc6d99855b240a2bf98712a 100644
--- a/cc/prioritized_texture_manager.cc
+++ b/cc/prioritized_texture_manager.cc
@@ -37,7 +37,7 @@ PrioritizedTextureManager::~PrioritizedTextureManager()
while (m_textures.size() > 0)
unregisterTexture(*m_textures.begin());
- deleteUnlinkedEvictedBackings();
+ unlinkAndClearEvictedBackings();
DCHECK(m_evictedBackings.empty());
// Each remaining backing is a leaked opengl texture. There should be none.
@@ -308,15 +308,6 @@ void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider)
EvictOnlyRecyclable,
UnlinkBackings,
resourceProvider);
-
- // Unlink all evicted backings
- for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
- if ((*it)->owner())
- (*it)->owner()->unlink();
- }
-
- // And clear the list of evicted backings
- deleteUnlinkedEvictedBackings();
}
void PrioritizedTextureManager::clearAllMemory(ResourceProvider* resourceProvider)
@@ -345,39 +336,23 @@ bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int
resourceProvider);
}
-void PrioritizedTextureManager::getEvictedBackings(BackingList& evictedBackings)
-{
- DCHECK(Proxy::isImplThread());
- evictedBackings.clear();
- evictedBackings.insert(evictedBackings.begin(), m_evictedBackings.begin(), m_evictedBackings.end());
-}
-
-void PrioritizedTextureManager::unlinkEvictedBackings(const BackingList& evictedBackings)
+void PrioritizedTextureManager::unlinkAndClearEvictedBackings()
{
DCHECK(Proxy::isMainThread());
- for (BackingList::const_iterator it = evictedBackings.begin(); it != evictedBackings.end(); ++it) {
- PrioritizedTexture::Backing* backing = (*it);
- if (backing->owner())
- backing->owner()->unlink();
- }
-}
-
-void PrioritizedTextureManager::deleteUnlinkedEvictedBackings()
-{
- DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
- BackingList newEvictedBackings;
+ base::AutoLock scoped_lock(m_evictedBackingsLock);
for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
PrioritizedTexture::Backing* backing = (*it);
if (backing->owner())
- newEvictedBackings.push_back(backing);
- else
- delete backing;
+ backing->owner()->unlink();
+ delete backing;
}
- m_evictedBackings.swap(newEvictedBackings);
+ m_evictedBackings.clear();
}
bool PrioritizedTextureManager::linkedEvictedBackingsExist() const
{
+ DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
+ base::AutoLock scoped_lock(m_evictedBackingsLock);
for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
if ((*it)->owner())
return true;
@@ -441,6 +416,7 @@ void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* reso
backing->deleteResource(resourceProvider);
m_memoryUseBytes -= backing->bytes();
m_backings.pop_front();
+ base::AutoLock scoped_lock(m_evictedBackingsLock);
m_evictedBackings.push_back(backing);
}
@@ -463,6 +439,7 @@ void PrioritizedTextureManager::assertInvariants()
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
PrioritizedTexture* texture = (*it);
PrioritizedTexture::Backing* backing = texture->backing();
+ base::AutoLock scoped_lock(m_evictedBackingsLock);
if (backing) {
if (backing->resourceHasBeenDeleted()) {
DCHECK(std::find(m_backings.begin(), m_backings.end(), backing) == m_backings.end());
« no previous file with comments | « cc/prioritized_texture_manager.h ('k') | cc/prioritized_texture_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698