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

Side by Side Diff: cc/prioritized_resource_manager.cc

Issue 11606012: cc: Unify context losing machinery (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 if (wastedMemory > tenPercentOfMemory) 304 if (wastedMemory > tenPercentOfMemory)
305 evictBackingsToReduceMemory(memoryUseBytes() - (wastedMemory - tenPercen tOfMemory), 305 evictBackingsToReduceMemory(memoryUseBytes() - (wastedMemory - tenPercen tOfMemory),
306 PriorityCalculator::allowEverythingCutoff(), 306 PriorityCalculator::allowEverythingCutoff(),
307 EvictOnlyRecyclable, 307 EvictOnlyRecyclable,
308 UnlinkBackings, 308 UnlinkBackings,
309 resourceProvider); 309 resourceProvider);
310 } 310 }
311 311
312 void PrioritizedResourceManager::clearAllMemory(ResourceProvider* resourceProvid er) 312 void PrioritizedResourceManager::clearAllMemory(ResourceProvider* resourceProvid er)
313 { 313 {
314 DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked()); 314 DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
ccameron 2012/12/18 19:24:01 Or alternatively, if resourceProvider is NULL, we
315 DCHECK(resourceProvider);
316 evictBackingsToReduceMemory(0, 315 evictBackingsToReduceMemory(0,
317 PriorityCalculator::allowEverythingCutoff(), 316 PriorityCalculator::allowEverythingCutoff(),
318 EvictAnything, 317 EvictAnything,
319 DoNotUnlinkBackings, 318 DoNotUnlinkBackings,
320 resourceProvider); 319 resourceProvider);
321 } 320 }
322 321
323 bool PrioritizedResourceManager::reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, ResourceProvider* resourceProvider) 322 bool PrioritizedResourceManager::reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, ResourceProvider* resourceProvider)
324 { 323 {
325 DCHECK(m_proxy->isImplThread()); 324 DCHECK(m_proxy->isImplThread());
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 DCHECK(resourceProvider); 396 DCHECK(resourceProvider);
398 ResourceProvider::ResourceId resourceId = resourceProvider->createManagedRes ource(size, format, ResourceProvider::TextureUsageAny); 397 ResourceProvider::ResourceId resourceId = resourceProvider->createManagedRes ource(size, format, ResourceProvider::TextureUsageAny);
399 PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(res ourceId, resourceProvider, size, format); 398 PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(res ourceId, resourceProvider, size, format);
400 m_memoryUseBytes += backing->bytes(); 399 m_memoryUseBytes += backing->bytes();
401 return backing; 400 return backing;
402 } 401 }
403 402
404 void PrioritizedResourceManager::evictFirstBackingResource(ResourceProvider* res ourceProvider) 403 void PrioritizedResourceManager::evictFirstBackingResource(ResourceProvider* res ourceProvider)
405 { 404 {
406 DCHECK(m_proxy->isImplThread()); 405 DCHECK(m_proxy->isImplThread());
407 DCHECK(resourceProvider);
408 DCHECK(!m_backings.empty()); 406 DCHECK(!m_backings.empty());
409 PrioritizedResource::Backing* backing = m_backings.front(); 407 PrioritizedResource::Backing* backing = m_backings.front();
410 408
411 // Note that we create a backing and its resource at the same time, but we 409 // Note that we create a backing and its resource at the same time, but we
412 // delete the backing structure and its resource in two steps. This is becau se 410 // delete the backing structure and its resource in two steps. This is becau se
413 // we can delete the resource while the main thread is running, but we canno t 411 // we can delete the resource while the main thread is running, but we canno t
414 // unlink backings while the main thread is running. 412 // unlink backings while the main thread is running.
415 backing->deleteResource(resourceProvider); 413 backing->deleteResource(resourceProvider);
416 m_memoryUseBytes -= backing->bytes(); 414 m_memoryUseBytes -= backing->bytes();
417 m_backings.pop_front(); 415 m_backings.pop_front();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 468 }
471 #endif 469 #endif
472 } 470 }
473 471
474 const Proxy* PrioritizedResourceManager::proxyForDebug() const 472 const Proxy* PrioritizedResourceManager::proxyForDebug() const
475 { 473 {
476 return m_proxy; 474 return m_proxy;
477 } 475 }
478 476
479 } // namespace cc 477 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698