Index: cc/prioritized_texture_manager.cc |
diff --git a/cc/prioritized_texture_manager.cc b/cc/prioritized_texture_manager.cc |
index 6ad408e982c8149d732b013d75c358f896a897d6..2a216a6146f8e7060b21abfe4e81eaeec702cad3 100644 |
--- a/cc/prioritized_texture_manager.cc |
+++ b/cc/prioritized_texture_manager.cc |
@@ -17,8 +17,9 @@ using namespace std; |
namespace cc { |
-PrioritizedTextureManager::PrioritizedTextureManager(size_t maxMemoryLimitBytes, int, int pool) |
- : m_maxMemoryLimitBytes(maxMemoryLimitBytes) |
+PrioritizedTextureManager::PrioritizedTextureManager(size_t maxMemoryLimitBytes, int, int pool, const Proxy* proxy) |
+ : m_proxy(proxy) |
+ , m_maxMemoryLimitBytes(maxMemoryLimitBytes) |
, m_externalPriorityCutoff(PriorityCalculator::allowEverythingCutoff()) |
, m_memoryUseBytes(0) |
, m_memoryAboveCutoffBytes(0) |
@@ -43,7 +44,7 @@ PrioritizedTextureManager::~PrioritizedTextureManager() |
void PrioritizedTextureManager::prioritizeTextures() |
{ |
TRACE_EVENT0("cc", "PrioritizedTextureManager::prioritizeTextures"); |
- DCHECK(Proxy::isMainThread()); |
+ DCHECK(m_proxy->isMainThread()); |
// Sorting textures in this function could be replaced by a slightly |
// modified O(n) quick-select to partition textures rather than |
@@ -111,7 +112,7 @@ void PrioritizedTextureManager::prioritizeTextures() |
void PrioritizedTextureManager::pushTexturePrioritiesToBackings() |
{ |
TRACE_EVENT0("cc", "PrioritizedTextureManager::pushTexturePrioritiesToBackings"); |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
assertInvariants(); |
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) |
@@ -123,7 +124,7 @@ void PrioritizedTextureManager::pushTexturePrioritiesToBackings() |
void PrioritizedTextureManager::updateBackingsInDrawingImplTree() |
{ |
TRACE_EVENT0("cc", "PrioritizedTextureManager::updateBackingsInDrawingImplTree"); |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
assertInvariants(); |
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) { |
@@ -137,7 +138,7 @@ void PrioritizedTextureManager::updateBackingsInDrawingImplTree() |
void PrioritizedTextureManager::sortBackings() |
{ |
TRACE_EVENT0("cc", "PrioritizedTextureManager::sortBackings"); |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
// Put backings in eviction/recycling order. |
m_backings.sort(compareBackings); |
@@ -146,7 +147,7 @@ void PrioritizedTextureManager::sortBackings() |
void PrioritizedTextureManager::clearPriorities() |
{ |
- DCHECK(Proxy::isMainThread()); |
+ DCHECK(m_proxy->isMainThread()); |
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) { |
// FIXME: We should remove this and just set all priorities to |
// PriorityCalculator::lowestPriority() once we have priorities |
@@ -158,7 +159,7 @@ void PrioritizedTextureManager::clearPriorities() |
bool PrioritizedTextureManager::requestLate(PrioritizedTexture* texture) |
{ |
- DCHECK(Proxy::isMainThread()); |
+ DCHECK(m_proxy->isMainThread()); |
// This is already above cutoff, so don't double count it's memory below. |
if (texture->isAbovePriorityCutoff()) |
@@ -183,7 +184,7 @@ bool PrioritizedTextureManager::requestLate(PrioritizedTexture* texture) |
void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture* texture, ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
DCHECK(!texture->isSelfManaged()); |
DCHECK(texture->isAbovePriorityCutoff()); |
if (texture->backing() || !texture->isAbovePriorityCutoff()) |
@@ -223,7 +224,7 @@ void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture |
bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, EvictionPolicy evictionPolicy, ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
if (memoryUseBytes() <= limitBytes && PriorityCalculator::allowEverythingCutoff() == priorityCutoff) |
return false; |
@@ -243,7 +244,7 @@ bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, i |
void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
evictBackingsToReduceMemory(m_memoryAvailableBytes, PriorityCalculator::allowEverythingCutoff(), EvictOnlyRecyclable, resourceProvider); |
DCHECK(memoryUseBytes() <= maxMemoryLimitBytes()); |
@@ -275,14 +276,14 @@ void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider) |
void PrioritizedTextureManager::clearAllMemory(ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
DCHECK(resourceProvider); |
evictBackingsToReduceMemory(0, PriorityCalculator::allowEverythingCutoff(), EvictAnything, resourceProvider); |
} |
bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
DCHECK(resourceProvider); |
// If we are in the process of uploading a new frame then the backings at the very end of |
// the list are not sorted by priority. Sort them before doing the eviction. |
@@ -293,14 +294,14 @@ bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int |
void PrioritizedTextureManager::getEvictedBackings(BackingList& evictedBackings) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
evictedBackings.clear(); |
evictedBackings.insert(evictedBackings.begin(), m_evictedBackings.begin(), m_evictedBackings.end()); |
} |
void PrioritizedTextureManager::unlinkEvictedBackings(const BackingList& evictedBackings) |
{ |
- DCHECK(Proxy::isMainThread()); |
+ DCHECK(m_proxy->isMainThread()); |
for (BackingList::const_iterator it = evictedBackings.begin(); it != evictedBackings.end(); ++it) { |
PrioritizedTexture::Backing* backing = (*it); |
if (backing->owner()) |
@@ -310,7 +311,7 @@ void PrioritizedTextureManager::unlinkEvictedBackings(const BackingList& evicted |
void PrioritizedTextureManager::deleteUnlinkedEvictedBackings() |
{ |
- DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked())); |
+ DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMainThreadBlocked())); |
BackingList newEvictedBackings; |
for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) { |
PrioritizedTexture::Backing* backing = (*it); |
@@ -333,7 +334,7 @@ bool PrioritizedTextureManager::linkedEvictedBackingsExist() const |
void PrioritizedTextureManager::registerTexture(PrioritizedTexture* texture) |
{ |
- DCHECK(Proxy::isMainThread()); |
+ DCHECK(m_proxy->isMainThread()); |
DCHECK(texture); |
DCHECK(!texture->textureManager()); |
DCHECK(!texture->backing()); |
@@ -346,7 +347,7 @@ void PrioritizedTextureManager::registerTexture(PrioritizedTexture* texture) |
void PrioritizedTextureManager::unregisterTexture(PrioritizedTexture* texture) |
{ |
- DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked())); |
+ DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMainThreadBlocked())); |
DCHECK(texture); |
DCHECK(ContainsKey(m_textures, texture)); |
@@ -358,14 +359,14 @@ void PrioritizedTextureManager::unregisterTexture(PrioritizedTexture* texture) |
void PrioritizedTextureManager::returnBackingTexture(PrioritizedTexture* texture) |
{ |
- DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked())); |
+ DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMainThreadBlocked())); |
if (texture->backing()) |
texture->unlink(); |
} |
PrioritizedTexture::Backing* PrioritizedTextureManager::createBacking(IntSize size, GLenum format, ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
DCHECK(resourceProvider); |
ResourceProvider::ResourceId resourceId = resourceProvider->createResource(m_pool, size, format, ResourceProvider::TextureUsageAny); |
PrioritizedTexture::Backing* backing = new PrioritizedTexture::Backing(resourceId, resourceProvider, size, format); |
@@ -375,7 +376,7 @@ PrioritizedTexture::Backing* PrioritizedTextureManager::createBacking(IntSize si |
void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* resourceProvider) |
{ |
- DCHECK(Proxy::isImplThread()); |
+ DCHECK(m_proxy->isImplThread()); |
DCHECK(resourceProvider); |
DCHECK(!m_backings.empty()); |
PrioritizedTexture::Backing* backing = m_backings.front(); |
@@ -393,7 +394,7 @@ void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* reso |
void PrioritizedTextureManager::assertInvariants() |
{ |
#ifndef NDEBUG |
- DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked()); |
+ DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
// If we hit any of these asserts, there is a bug in this class. To see |
// where the bug is, call this function at the beginning and end of |