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

Side by Side Diff: cc/CCPrioritizedTextureManager.cpp

Issue 10919227: Roll in CC changes up to 128196 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months 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
« no previous file with comments | « cc/CCPrioritizedTextureManager.h ('k') | cc/CCRenderSurfaceFilters.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 6
7 #include "CCPrioritizedTextureManager.h" 7 #include "CCPrioritizedTextureManager.h"
8 8
9 #include "CCPrioritizedTexture.h" 9 #include "CCPrioritizedTexture.h"
10 #include "CCPriorityCalculator.h" 10 #include "CCPriorityCalculator.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 wastedMemory += (*it)->bytes(); 221 wastedMemory += (*it)->bytes();
222 } 222 }
223 size_t tenPercentOfMemory = m_memoryAvailableBytes / 10; 223 size_t tenPercentOfMemory = m_memoryAvailableBytes / 10;
224 if (wastedMemory <= tenPercentOfMemory) 224 if (wastedMemory <= tenPercentOfMemory)
225 return; 225 return;
226 reduceMemory(memoryUseBytes() - (wastedMemory - tenPercentOfMemory), resourc eProvider); 226 reduceMemory(memoryUseBytes() - (wastedMemory - tenPercentOfMemory), resourc eProvider);
227 } 227 }
228 228
229 void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourcePro vider) 229 void CCPrioritizedTextureManager::clearAllMemory(CCResourceProvider* resourcePro vider)
230 { 230 {
231 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
232 ASSERT(resourceProvider);
231 // Unlink and destroy all backing textures. 233 // Unlink and destroy all backing textures.
232 while (m_backings.size() > 0) { 234 while (m_backings.size() > 0) {
233 BackingSet::iterator it = m_backings.begin(); 235 BackingSet::iterator it = m_backings.begin();
234 if ((*it)->owner()) 236 if ((*it)->owner())
235 (*it)->owner()->unlink(); 237 (*it)->owner()->unlink();
236 destroyBacking((*it), resourceProvider); 238 destroyBacking((*it), resourceProvider);
237 } 239 }
238 } 240 }
239 241
240 void CCPrioritizedTextureManager::allBackingTexturesWereDeleted() 242 void CCPrioritizedTextureManager::unlinkAllBackings()
241 { 243 {
242 // Same as clearAllMemory, except all our textures were already 244 ASSERT(CCProxy::isMainThread());
243 // deleted externally, so we don't delete them. Passing no 245 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it)
244 // resourceProvider results in leaking the (now invalid) texture ids. 246 if ((*it)->owner())
245 clearAllMemory(0); 247 (*it)->owner()->unlink();
248 }
249
250 void CCPrioritizedTextureManager::deleteAllUnlinkedBackings()
251 {
252 ASSERT(CCProxy::isImplThread() && CCProxy::isMainThreadBlocked());
253 BackingVector backingsToDelete;
254 for (BackingSet::iterator it = m_backings.begin(); it != m_backings.end(); + +it)
255 if (!(*it)->owner())
256 backingsToDelete.append((*it));
257
258 for (BackingVector::iterator it = backingsToDelete.begin(); it != backingsTo Delete.end(); ++it)
259 destroyBacking((*it), 0);
246 } 260 }
247 261
248 void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture) 262 void CCPrioritizedTextureManager::registerTexture(CCPrioritizedTexture* texture)
249 { 263 {
250 ASSERT(CCProxy::isMainThread()); 264 ASSERT(CCProxy::isMainThread());
251 ASSERT(texture); 265 ASSERT(texture);
252 ASSERT(!texture->textureManager()); 266 ASSERT(!texture->textureManager());
253 ASSERT(!texture->backing()); 267 ASSERT(!texture->backing());
254 ASSERT(m_textures.find(texture) == m_textures.end()); 268 ASSERT(m_textures.find(texture) == m_textures.end());
255 269
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()) 356 if ((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff())
343 reachedProtected = true; 357 reachedProtected = true;
344 if (reachedProtected) 358 if (reachedProtected)
345 ASSERT((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff()); 359 ASSERT((*it)->owner() && (*it)->owner()->isAbovePriorityCutoff());
346 } 360 }
347 } 361 }
348 #endif 362 #endif
349 363
350 364
351 } // namespace WebCore 365 } // namespace WebCore
OLDNEW
« no previous file with comments | « cc/CCPrioritizedTextureManager.h ('k') | cc/CCRenderSurfaceFilters.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698