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

Side by Side Diff: cc/prioritized_resource_unittest.cc

Issue 11411251: Use a lock to deal with concurrent access to the m_evictedBackings (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.h" 5 #include "cc/prioritized_resource.h"
6 6
7 #include "cc/prioritized_resource_manager.h" 7 #include "cc/prioritized_resource_manager.h"
8 #include "cc/resource.h" 8 #include "cc/resource.h"
9 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread 9 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
10 #include "cc/test/fake_graphics_context.h" 10 #include "cc/test/fake_graphics_context.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy); 82 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
83 resourceManager->assertInvariants(); 83 resourceManager->assertInvariants();
84 #endif 84 #endif
85 } 85 }
86 86
87 bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) 87 bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture)
88 { 88 {
89 return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate(); 89 return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate();
90 } 90 }
91 91
92 size_t evictedBackingCount(PrioritizedResourceManager* resourceManager)
93 {
94 return resourceManager->m_evictedBackings.size();
95 }
96
92 protected: 97 protected:
93 FakeProxy m_proxy; 98 FakeProxy m_proxy;
94 const gfx::Size m_textureSize; 99 const gfx::Size m_textureSize;
95 const GLenum m_textureFormat; 100 const GLenum m_textureFormat;
96 scoped_ptr<GraphicsContext> m_context; 101 scoped_ptr<GraphicsContext> m_context;
97 scoped_ptr<ResourceProvider> m_resourceProvider; 102 scoped_ptr<ResourceProvider> m_resourceProvider;
98 }; 103 };
99 104
100 namespace { 105 namespace {
101 106
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 for (size_t i = 0; i < maxTextures; ++i) 230 for (size_t i = 0; i < maxTextures; ++i)
226 EXPECT_EQ(validateTexture(textures[i], false), i < 4); 231 EXPECT_EQ(validateTexture(textures[i], false), i < 4);
227 { 232 {
228 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy); 233 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
229 resourceManager->reduceMemory(resourceProvider()); 234 resourceManager->reduceMemory(resourceProvider());
230 } 235 }
231 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); 236 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
232 237
233 // Do a one-time eviction for one more texture based on priority cutoff 238 // Do a one-time eviction for one more texture based on priority cutoff
234 PrioritizedResourceManager::BackingList evictedBackings; 239 PrioritizedResourceManager::BackingList evictedBackings;
240 resourceManager->unlinkAndClearEvictedBackings();
235 { 241 {
236 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy); 242 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
237 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, re sourceProvider()); 243 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, re sourceProvider());
238 resourceManager->getEvictedBackings(evictedBackings); 244 EXPECT_EQ(0, evictedBackingCount(resourceManager.get()));
239 EXPECT_EQ(0, evictedBackings.size());
240 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, re sourceProvider()); 245 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, re sourceProvider());
241 resourceManager->getEvictedBackings(evictedBackings); 246 EXPECT_EQ(1, evictedBackingCount(resourceManager.get()));
242 EXPECT_EQ(1, evictedBackings.size());
243 } 247 }
244 resourceManager->unlinkEvictedBackings(evictedBackings); 248 resourceManager->unlinkAndClearEvictedBackings();
245 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryUseBytes()); 249 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryUseBytes());
246 250
247 // Re-allocate the the texture after the one-time drop. 251 // Re-allocate the the texture after the one-time drop.
248 prioritizeTexturesAndBackings(resourceManager.get()); 252 prioritizeTexturesAndBackings(resourceManager.get());
249 for (size_t i = 0; i < maxTextures; ++i) 253 for (size_t i = 0; i < maxTextures; ++i)
250 EXPECT_EQ(validateTexture(textures[i], false), i < 4); 254 EXPECT_EQ(validateTexture(textures[i], false), i < 4);
251 { 255 {
252 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy); 256 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
253 resourceManager->reduceMemory(resourceProvider()); 257 resourceManager->reduceMemory(resourceProvider());
254 } 258 }
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); 700 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes());
697 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby Bytes()); 701 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby Bytes());
698 } 702 }
699 703
700 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy); 704 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
701 resourceManager->clearAllMemory(resourceProvider()); 705 resourceManager->clearAllMemory(resourceProvider());
702 } 706 }
703 707
704 } // namespace 708 } // namespace
705 } // namespace cc 709 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698