| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/prioritized_resource_manager.h" | 5 #include "cc/prioritized_resource_manager.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "cc/prioritized_resource.h" | 9 #include "cc/prioritized_resource.h" |
| 10 #include "cc/priority_calculator.h" | 10 #include "cc/priority_calculator.h" |
| 11 #include "cc/proxy.h" | 11 #include "cc/proxy.h" |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 | 13 |
| 14 using namespace std; | 14 using namespace std; |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 PrioritizedResourceManager::PrioritizedResourceManager(int pool, const Proxy* pr
oxy) | 18 PrioritizedResourceManager::PrioritizedResourceManager(const Proxy* proxy) |
| 19 : m_proxy(proxy) | 19 : m_proxy(proxy) |
| 20 , m_maxMemoryLimitBytes(defaultMemoryAllocationLimit()) | 20 , m_maxMemoryLimitBytes(defaultMemoryAllocationLimit()) |
| 21 , m_externalPriorityCutoff(PriorityCalculator::allowEverythingCutoff()) | 21 , m_externalPriorityCutoff(PriorityCalculator::allowEverythingCutoff()) |
| 22 , m_memoryUseBytes(0) | 22 , m_memoryUseBytes(0) |
| 23 , m_memoryAboveCutoffBytes(0) | 23 , m_memoryAboveCutoffBytes(0) |
| 24 , m_memoryAvailableBytes(0) | 24 , m_memoryAvailableBytes(0) |
| 25 , m_pool(pool) | |
| 26 , m_backingsTailNotSorted(false) | 25 , m_backingsTailNotSorted(false) |
| 27 , m_memoryVisibleBytes(0) | 26 , m_memoryVisibleBytes(0) |
| 28 , m_memoryVisibleAndNearbyBytes(0) | 27 , m_memoryVisibleAndNearbyBytes(0) |
| 29 , m_memoryVisibleLastPushedBytes(0) | 28 , m_memoryVisibleLastPushedBytes(0) |
| 30 , m_memoryVisibleAndNearbyLastPushedBytes(0) | 29 , m_memoryVisibleAndNearbyLastPushedBytes(0) |
| 31 { | 30 { |
| 32 } | 31 } |
| 33 | 32 |
| 34 PrioritizedResourceManager::~PrioritizedResourceManager() | 33 PrioritizedResourceManager::~PrioritizedResourceManager() |
| 35 { | 34 { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 { | 388 { |
| 390 DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMai
nThreadBlocked())); | 389 DCHECK(m_proxy->isMainThread() || (m_proxy->isImplThread() && m_proxy->isMai
nThreadBlocked())); |
| 391 if (texture->backing()) | 390 if (texture->backing()) |
| 392 texture->unlink(); | 391 texture->unlink(); |
| 393 } | 392 } |
| 394 | 393 |
| 395 PrioritizedResource::Backing* PrioritizedResourceManager::createBacking(gfx::Siz
e size, GLenum format, ResourceProvider* resourceProvider) | 394 PrioritizedResource::Backing* PrioritizedResourceManager::createBacking(gfx::Siz
e size, GLenum format, ResourceProvider* resourceProvider) |
| 396 { | 395 { |
| 397 DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); | 396 DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); |
| 398 DCHECK(resourceProvider); | 397 DCHECK(resourceProvider); |
| 399 ResourceProvider::ResourceId resourceId = resourceProvider->createResource(m
_pool, size, format, ResourceProvider::TextureUsageAny); | 398 ResourceProvider::ResourceId resourceId = resourceProvider->createResource(s
ize, format, ResourceProvider::TextureUsageAny); |
| 400 PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(res
ourceId, resourceProvider, size, format); | 399 PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(res
ourceId, resourceProvider, size, format); |
| 401 m_memoryUseBytes += backing->bytes(); | 400 m_memoryUseBytes += backing->bytes(); |
| 402 return backing; | 401 return backing; |
| 403 } | 402 } |
| 404 | 403 |
| 405 void PrioritizedResourceManager::evictFirstBackingResource(ResourceProvider* res
ourceProvider) | 404 void PrioritizedResourceManager::evictFirstBackingResource(ResourceProvider* res
ourceProvider) |
| 406 { | 405 { |
| 407 DCHECK(m_proxy->isImplThread()); | 406 DCHECK(m_proxy->isImplThread()); |
| 408 DCHECK(resourceProvider); | 407 DCHECK(resourceProvider); |
| 409 DCHECK(!m_backings.empty()); | 408 DCHECK(!m_backings.empty()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 470 } |
| 472 #endif | 471 #endif |
| 473 } | 472 } |
| 474 | 473 |
| 475 const Proxy* PrioritizedResourceManager::proxyForDebug() const | 474 const Proxy* PrioritizedResourceManager::proxyForDebug() const |
| 476 { | 475 { |
| 477 return m_proxy; | 476 return m_proxy; |
| 478 } | 477 } |
| 479 | 478 |
| 480 } // namespace cc | 479 } // namespace cc |
| OLD | NEW |