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

Side by Side Diff: cc/prioritized_resource_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month 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
« no previous file with comments | « cc/prioritized_resource_manager.cc ('k') | cc/proxy.h » ('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 "cc/prioritized_resource.h" 7 #include "cc/prioritized_resource.h"
8 8
9 #include "cc/prioritized_resource_manager.h" 9 #include "cc/prioritized_resource_manager.h"
10 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread 10 #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
11 #include "cc/test/fake_graphics_context.h" 11 #include "cc/test/fake_graphics_context.h"
12 #include "cc/test/fake_proxy.h"
12 #include "cc/test/tiled_layer_test_common.h" 13 #include "cc/test/tiled_layer_test_common.h"
13 #include "cc/texture.h" 14 #include "cc/texture.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 using namespace cc; 17 using namespace cc;
17 using namespace WebKitTests; 18 using namespace WebKitTests;
18 19
19 namespace cc { 20 namespace cc {
20 21
21 class PrioritizedResourceTest : public testing::Test { 22 class PrioritizedResourceTest : public testing::Test {
22 public: 23 public:
23 PrioritizedResourceTest() 24 PrioritizedResourceTest()
24 : m_textureSize(256, 256) 25 : m_proxy(scoped_ptr<Thread>(NULL))
26 , m_textureSize(256, 256)
25 , m_textureFormat(GL_RGBA) 27 , m_textureFormat(GL_RGBA)
26 , m_context(WebKit::createFakeGraphicsContext()) 28 , m_context(WebKit::createFakeGraphicsContext())
27 { 29 {
28 DebugScopedSetImplThread implThread; 30 DebugScopedSetImplThread implThread(&m_proxy);
29 m_resourceProvider = ResourceProvider::create(m_context.get()); 31 m_resourceProvider = ResourceProvider::create(m_context.get());
30 } 32 }
31 33
32 virtual ~PrioritizedResourceTest() 34 virtual ~PrioritizedResourceTest()
33 { 35 {
34 DebugScopedSetImplThread implThread; 36 DebugScopedSetImplThread implThread(&m_proxy);
35 m_resourceProvider.reset(); 37 m_resourceProvider.reset();
36 } 38 }
37 39
38 size_t texturesMemorySize(size_t textureCount) 40 size_t texturesMemorySize(size_t textureCount)
39 { 41 {
40 return Texture::memorySizeBytes(m_textureSize, m_textureFormat) * textur eCount; 42 return Texture::memorySizeBytes(m_textureSize, m_textureFormat) * textur eCount;
41 } 43 }
42 44
43 scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures) 45 scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures)
44 { 46 {
45 return PrioritizedResourceManager::create(texturesMemorySize(maxTextures ), 1024, 0); 47 return PrioritizedResourceManager::create(texturesMemorySize(maxTextures ), 1024, 0, &m_proxy);
46 } 48 }
47 49
48 bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestL ate) 50 bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestL ate)
49 { 51 {
50 resourceManagerAssertInvariants(texture->resourceManager()); 52 resourceManagerAssertInvariants(texture->resourceManager());
51 if (requestLate) 53 if (requestLate)
52 texture->requestLate(); 54 texture->requestLate();
53 resourceManagerAssertInvariants(texture->resourceManager()); 55 resourceManagerAssertInvariants(texture->resourceManager());
54 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 56 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
55 bool success = texture->canAcquireBackingTexture(); 57 bool success = texture->canAcquireBackingTexture();
56 if (success) 58 if (success)
57 texture->acquireBackingTexture(resourceProvider()); 59 texture->acquireBackingTexture(resourceProvider());
58 return success; 60 return success;
59 } 61 }
60 62
61 void prioritizeTexturesAndBackings(PrioritizedResourceManager* resourceManag er) 63 void prioritizeTexturesAndBackings(PrioritizedResourceManager* resourceManag er)
62 { 64 {
63 resourceManager->prioritizeTextures(); 65 resourceManager->prioritizeTextures();
64 resourceManagerUpdateBackingsPriorities(resourceManager); 66 resourceManagerUpdateBackingsPriorities(resourceManager);
65 } 67 }
66 68
67 void resourceManagerUpdateBackingsPriorities(PrioritizedResourceManager* res ourceManager) 69 void resourceManagerUpdateBackingsPriorities(PrioritizedResourceManager* res ourceManager)
68 { 70 {
69 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 71 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
70 resourceManager->pushTexturePrioritiesToBackings(); 72 resourceManager->pushTexturePrioritiesToBackings();
71 } 73 }
72 74
73 ResourceProvider* resourceProvider() 75 ResourceProvider* resourceProvider()
74 { 76 {
75 return m_resourceProvider.get(); 77 return m_resourceProvider.get();
76 } 78 }
77 79
78 void resourceManagerAssertInvariants(PrioritizedResourceManager* resourceMan ager) 80 void resourceManagerAssertInvariants(PrioritizedResourceManager* resourceMan ager)
79 { 81 {
80 #ifndef NDEBUG 82 #ifndef NDEBUG
81 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 83 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
82 resourceManager->assertInvariants(); 84 resourceManager->assertInvariants();
83 #endif 85 #endif
84 } 86 }
85 87
86 bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) 88 bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture)
87 { 89 {
88 return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate(); 90 return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate();
89 } 91 }
90 92
91 protected: 93 protected:
94 FakeProxy m_proxy;
92 const gfx::Size m_textureSize; 95 const gfx::Size m_textureSize;
93 const GLenum m_textureFormat; 96 const GLenum m_textureFormat;
94 scoped_ptr<GraphicsContext> m_context; 97 scoped_ptr<GraphicsContext> m_context;
95 scoped_ptr<ResourceProvider> m_resourceProvider; 98 scoped_ptr<ResourceProvider> m_resourceProvider;
96 }; 99 };
97 100
98 } 101 }
99 102
100 namespace { 103 namespace {
101 104
(...skipping 26 matching lines...) Expand all
128 // Only upper half should be available. 131 // Only upper half should be available.
129 prioritizeTexturesAndBackings(resourceManager.get()); 132 prioritizeTexturesAndBackings(resourceManager.get());
130 EXPECT_FALSE(validateTexture(textures[0], false)); 133 EXPECT_FALSE(validateTexture(textures[0], false));
131 EXPECT_FALSE(validateTexture(textures[7], false)); 134 EXPECT_FALSE(validateTexture(textures[7], false));
132 EXPECT_TRUE(validateTexture(textures[8], false)); 135 EXPECT_TRUE(validateTexture(textures[8], false));
133 EXPECT_TRUE(validateTexture(textures[15], false)); 136 EXPECT_TRUE(validateTexture(textures[15], false));
134 137
135 EXPECT_EQ(texturesMemorySize(maxTextures), resourceManager->memoryAboveCutof fBytes()); 138 EXPECT_EQ(texturesMemorySize(maxTextures), resourceManager->memoryAboveCutof fBytes());
136 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 139 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
137 140
138 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 141 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
139 resourceManager->clearAllMemory(resourceProvider()); 142 resourceManager->clearAllMemory(resourceProvider());
140 } 143 }
141 144
142 TEST_F(PrioritizedResourceTest, changeMemoryLimits) 145 TEST_F(PrioritizedResourceTest, changeMemoryLimits)
143 { 146 {
144 const size_t maxTextures = 8; 147 const size_t maxTextures = 8;
145 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 148 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
146 scoped_ptr<PrioritizedResource> textures[maxTextures]; 149 scoped_ptr<PrioritizedResource> textures[maxTextures];
147 150
148 for (size_t i = 0; i < maxTextures; ++i) 151 for (size_t i = 0; i < maxTextures; ++i)
149 textures[i] = resourceManager->createTexture(m_textureSize, m_textureFor mat); 152 textures[i] = resourceManager->createTexture(m_textureSize, m_textureFor mat);
150 for (size_t i = 0; i < maxTextures; ++i) 153 for (size_t i = 0; i < maxTextures; ++i)
151 textures[i]->setRequestPriority(100 + i); 154 textures[i]->setRequestPriority(100 + i);
152 155
153 // Set max limit to 8 textures 156 // Set max limit to 8 textures
154 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); 157 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
155 prioritizeTexturesAndBackings(resourceManager.get()); 158 prioritizeTexturesAndBackings(resourceManager.get());
156 for (size_t i = 0; i < maxTextures; ++i) 159 for (size_t i = 0; i < maxTextures; ++i)
157 validateTexture(textures[i], false); 160 validateTexture(textures[i], false);
158 { 161 {
159 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 162 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
160 resourceManager->reduceMemory(resourceProvider()); 163 resourceManager->reduceMemory(resourceProvider());
161 } 164 }
162 165
163 EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes()); 166 EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes());
164 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 167 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
165 168
166 // Set max limit to 5 textures 169 // Set max limit to 5 textures
167 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(5)); 170 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(5));
168 prioritizeTexturesAndBackings(resourceManager.get()); 171 prioritizeTexturesAndBackings(resourceManager.get());
169 for (size_t i = 0; i < maxTextures; ++i) 172 for (size_t i = 0; i < maxTextures; ++i)
170 EXPECT_EQ(validateTexture(textures[i], false), i < 5); 173 EXPECT_EQ(validateTexture(textures[i], false), i < 5);
171 { 174 {
172 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 175 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
173 resourceManager->reduceMemory(resourceProvider()); 176 resourceManager->reduceMemory(resourceProvider());
174 } 177 }
175 178
176 EXPECT_EQ(texturesMemorySize(5), resourceManager->memoryAboveCutoffBytes()); 179 EXPECT_EQ(texturesMemorySize(5), resourceManager->memoryAboveCutoffBytes());
177 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 180 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
178 181
179 // Set max limit to 4 textures 182 // Set max limit to 4 textures
180 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(4)); 183 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(4));
181 prioritizeTexturesAndBackings(resourceManager.get()); 184 prioritizeTexturesAndBackings(resourceManager.get());
182 for (size_t i = 0; i < maxTextures; ++i) 185 for (size_t i = 0; i < maxTextures; ++i)
183 EXPECT_EQ(validateTexture(textures[i], false), i < 4); 186 EXPECT_EQ(validateTexture(textures[i], false), i < 4);
184 { 187 {
185 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 188 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
186 resourceManager->reduceMemory(resourceProvider()); 189 resourceManager->reduceMemory(resourceProvider());
187 } 190 }
188 191
189 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); 192 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
190 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 193 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
191 194
192 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 195 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
193 resourceManager->clearAllMemory(resourceProvider()); 196 resourceManager->clearAllMemory(resourceProvider());
194 } 197 }
195 198
196 TEST_F(PrioritizedResourceTest, changePriorityCutoff) 199 TEST_F(PrioritizedResourceTest, changePriorityCutoff)
197 { 200 {
198 const size_t maxTextures = 8; 201 const size_t maxTextures = 8;
199 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 202 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
200 scoped_ptr<PrioritizedResource> textures[maxTextures]; 203 scoped_ptr<PrioritizedResource> textures[maxTextures];
201 204
202 for (size_t i = 0; i < maxTextures; ++i) 205 for (size_t i = 0; i < maxTextures; ++i)
203 textures[i] = resourceManager->createTexture(m_textureSize, m_textureFor mat); 206 textures[i] = resourceManager->createTexture(m_textureSize, m_textureFor mat);
204 for (size_t i = 0; i < maxTextures; ++i) 207 for (size_t i = 0; i < maxTextures; ++i)
205 textures[i]->setRequestPriority(100 + i); 208 textures[i]->setRequestPriority(100 + i);
206 209
207 // Set the cutoff to drop two textures. Try to requestLate on all textures, and 210 // Set the cutoff to drop two textures. Try to requestLate on all textures, and
208 // make sure that requestLate doesn't work on a texture with equal priority to 211 // make sure that requestLate doesn't work on a texture with equal priority to
209 // the cutoff. 212 // the cutoff.
210 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); 213 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
211 resourceManager->setExternalPriorityCutoff(106); 214 resourceManager->setExternalPriorityCutoff(106);
212 prioritizeTexturesAndBackings(resourceManager.get()); 215 prioritizeTexturesAndBackings(resourceManager.get());
213 for (size_t i = 0; i < maxTextures; ++i) 216 for (size_t i = 0; i < maxTextures; ++i)
214 EXPECT_EQ(validateTexture(textures[i], true), i < 6); 217 EXPECT_EQ(validateTexture(textures[i], true), i < 6);
215 { 218 {
216 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 219 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
217 resourceManager->reduceMemory(resourceProvider()); 220 resourceManager->reduceMemory(resourceProvider());
218 } 221 }
219 EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes()); 222 EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes());
220 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 223 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
221 224
222 // Set the cutoff to drop two more textures. 225 // Set the cutoff to drop two more textures.
223 resourceManager->setExternalPriorityCutoff(104); 226 resourceManager->setExternalPriorityCutoff(104);
224 prioritizeTexturesAndBackings(resourceManager.get()); 227 prioritizeTexturesAndBackings(resourceManager.get());
225 for (size_t i = 0; i < maxTextures; ++i) 228 for (size_t i = 0; i < maxTextures; ++i)
226 EXPECT_EQ(validateTexture(textures[i], false), i < 4); 229 EXPECT_EQ(validateTexture(textures[i], false), i < 4);
227 { 230 {
228 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 231 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
229 resourceManager->reduceMemory(resourceProvider()); 232 resourceManager->reduceMemory(resourceProvider());
230 } 233 }
231 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); 234 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
232 235
233 // Do a one-time eviction for one more texture based on priority cutoff 236 // Do a one-time eviction for one more texture based on priority cutoff
234 PrioritizedResourceManager::BackingList evictedBackings; 237 PrioritizedResourceManager::BackingList evictedBackings;
235 { 238 {
236 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 239 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
237 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, re sourceProvider()); 240 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, re sourceProvider());
238 resourceManager->getEvictedBackings(evictedBackings); 241 resourceManager->getEvictedBackings(evictedBackings);
239 EXPECT_EQ(0, evictedBackings.size()); 242 EXPECT_EQ(0, evictedBackings.size());
240 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, re sourceProvider()); 243 resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, re sourceProvider());
241 resourceManager->getEvictedBackings(evictedBackings); 244 resourceManager->getEvictedBackings(evictedBackings);
242 EXPECT_EQ(1, evictedBackings.size()); 245 EXPECT_EQ(1, evictedBackings.size());
243 } 246 }
244 resourceManager->unlinkEvictedBackings(evictedBackings); 247 resourceManager->unlinkEvictedBackings(evictedBackings);
245 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryUseBytes()); 248 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryUseBytes());
246 249
247 // Re-allocate the the texture after the one-time drop. 250 // Re-allocate the the texture after the one-time drop.
248 prioritizeTexturesAndBackings(resourceManager.get()); 251 prioritizeTexturesAndBackings(resourceManager.get());
249 for (size_t i = 0; i < maxTextures; ++i) 252 for (size_t i = 0; i < maxTextures; ++i)
250 EXPECT_EQ(validateTexture(textures[i], false), i < 4); 253 EXPECT_EQ(validateTexture(textures[i], false), i < 4);
251 { 254 {
252 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 255 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
253 resourceManager->reduceMemory(resourceProvider()); 256 resourceManager->reduceMemory(resourceProvider());
254 } 257 }
255 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); 258 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
256 259
257 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 260 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
258 resourceManager->clearAllMemory(resourceProvider()); 261 resourceManager->clearAllMemory(resourceProvider());
259 } 262 }
260 263
261 TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures) 264 TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures)
262 { 265 {
263 const size_t maxTextures = 4; 266 const size_t maxTextures = 4;
264 const size_t numTextures = 4; 267 const size_t numTextures = 4;
265 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 268 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
266 scoped_ptr<PrioritizedResource> textures[numTextures]; 269 scoped_ptr<PrioritizedResource> textures[numTextures];
267 scoped_ptr<PrioritizedResource> moreTextures[numTextures]; 270 scoped_ptr<PrioritizedResource> moreTextures[numTextures];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 EXPECT_TRUE(validateTexture(moreTextures[1], false)); 310 EXPECT_TRUE(validateTexture(moreTextures[1], false));
308 EXPECT_TRUE(validateTexture(moreTextures[2], false)); 311 EXPECT_TRUE(validateTexture(moreTextures[2], false));
309 EXPECT_TRUE(validateTexture(moreTextures[3], false)); 312 EXPECT_TRUE(validateTexture(moreTextures[3], false));
310 313
311 // Lower priority have been fully evicted. 314 // Lower priority have been fully evicted.
312 EXPECT_FALSE(textures[0]->haveBackingTexture()); 315 EXPECT_FALSE(textures[0]->haveBackingTexture());
313 EXPECT_FALSE(textures[1]->haveBackingTexture()); 316 EXPECT_FALSE(textures[1]->haveBackingTexture());
314 EXPECT_FALSE(textures[2]->haveBackingTexture()); 317 EXPECT_FALSE(textures[2]->haveBackingTexture());
315 EXPECT_FALSE(textures[3]->haveBackingTexture()); 318 EXPECT_FALSE(textures[3]->haveBackingTexture());
316 319
317 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 320 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
318 resourceManager->clearAllMemory(resourceProvider()); 321 resourceManager->clearAllMemory(resourceProvider());
319 } 322 }
320 323
321 TEST_F(PrioritizedResourceTest, resourceManagerPrioritiesAreEqual) 324 TEST_F(PrioritizedResourceTest, resourceManagerPrioritiesAreEqual)
322 { 325 {
323 const size_t maxTextures = 16; 326 const size_t maxTextures = 16;
324 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 327 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
325 scoped_ptr<PrioritizedResource> textures[maxTextures]; 328 scoped_ptr<PrioritizedResource> textures[maxTextures];
326 329
327 for (size_t i = 0; i < maxTextures; ++i) 330 for (size_t i = 0; i < maxTextures; ++i)
(...skipping 19 matching lines...) Expand all
347 350
348 // Manually reserving textures should only succeed on the higher priority te xtures, 351 // Manually reserving textures should only succeed on the higher priority te xtures,
349 // and on remaining textures up to the memory limit. 352 // and on remaining textures up to the memory limit.
350 for (size_t i = 0; i < 8; i++) 353 for (size_t i = 0; i < 8; i++)
351 EXPECT_TRUE(validateTexture(textures[i], true)); 354 EXPECT_TRUE(validateTexture(textures[i], true));
352 for (size_t i = 9; i < maxTextures; i++) 355 for (size_t i = 9; i < maxTextures; i++)
353 EXPECT_FALSE(validateTexture(textures[i], true)); 356 EXPECT_FALSE(validateTexture(textures[i], true));
354 EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes()); 357 EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes());
355 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 358 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
356 359
357 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 360 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
358 resourceManager->clearAllMemory(resourceProvider()); 361 resourceManager->clearAllMemory(resourceProvider());
359 } 362 }
360 363
361 TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst) 364 TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst)
362 { 365 {
363 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(1); 366 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(1);
364 scoped_ptr<PrioritizedResource> texture = resourceManager->createTexture(m_t extureSize, m_textureFormat); 367 scoped_ptr<PrioritizedResource> texture = resourceManager->createTexture(m_t extureSize, m_textureFormat);
365 368
366 // Texture is initially invalid, but it will become available. 369 // Texture is initially invalid, but it will become available.
367 EXPECT_FALSE(texture->haveBackingTexture()); 370 EXPECT_FALSE(texture->haveBackingTexture());
368 371
369 texture->setRequestPriority(100); 372 texture->setRequestPriority(100);
370 prioritizeTexturesAndBackings(resourceManager.get()); 373 prioritizeTexturesAndBackings(resourceManager.get());
371 374
372 EXPECT_TRUE(validateTexture(texture, false)); 375 EXPECT_TRUE(validateTexture(texture, false));
373 EXPECT_TRUE(texture->canAcquireBackingTexture()); 376 EXPECT_TRUE(texture->canAcquireBackingTexture());
374 EXPECT_TRUE(texture->haveBackingTexture()); 377 EXPECT_TRUE(texture->haveBackingTexture());
375 378
376 { 379 {
377 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 380 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
378 resourceManager->clearAllMemory(resourceProvider()); 381 resourceManager->clearAllMemory(resourceProvider());
379 } 382 }
380 resourceManager.reset(); 383 resourceManager.reset();
381 384
382 EXPECT_FALSE(texture->canAcquireBackingTexture()); 385 EXPECT_FALSE(texture->canAcquireBackingTexture());
383 EXPECT_FALSE(texture->haveBackingTexture()); 386 EXPECT_FALSE(texture->haveBackingTexture());
384 } 387 }
385 388
386 TEST_F(PrioritizedResourceTest, textureMovedToNewManager) 389 TEST_F(PrioritizedResourceTest, textureMovedToNewManager)
387 { 390 {
388 scoped_ptr<PrioritizedResourceManager> resourceManagerOne = createManager(1) ; 391 scoped_ptr<PrioritizedResourceManager> resourceManagerOne = createManager(1) ;
389 scoped_ptr<PrioritizedResourceManager> resourceManagerTwo = createManager(1) ; 392 scoped_ptr<PrioritizedResourceManager> resourceManagerTwo = createManager(1) ;
390 scoped_ptr<PrioritizedResource> texture = resourceManagerOne->createTexture( m_textureSize, m_textureFormat); 393 scoped_ptr<PrioritizedResource> texture = resourceManagerOne->createTexture( m_textureSize, m_textureFormat);
391 394
392 // Texture is initially invalid, but it will become available. 395 // Texture is initially invalid, but it will become available.
393 EXPECT_FALSE(texture->haveBackingTexture()); 396 EXPECT_FALSE(texture->haveBackingTexture());
394 397
395 texture->setRequestPriority(100); 398 texture->setRequestPriority(100);
396 prioritizeTexturesAndBackings(resourceManagerOne.get()); 399 prioritizeTexturesAndBackings(resourceManagerOne.get());
397 400
398 EXPECT_TRUE(validateTexture(texture, false)); 401 EXPECT_TRUE(validateTexture(texture, false));
399 EXPECT_TRUE(texture->canAcquireBackingTexture()); 402 EXPECT_TRUE(texture->canAcquireBackingTexture());
400 EXPECT_TRUE(texture->haveBackingTexture()); 403 EXPECT_TRUE(texture->haveBackingTexture());
401 404
402 texture->setTextureManager(0); 405 texture->setTextureManager(0);
403 406
404 { 407 {
405 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 408 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
406 resourceManagerOne->clearAllMemory(resourceProvider()); 409 resourceManagerOne->clearAllMemory(resourceProvider());
407 } 410 }
408 resourceManagerOne.reset(); 411 resourceManagerOne.reset();
409 412
410 EXPECT_FALSE(texture->canAcquireBackingTexture()); 413 EXPECT_FALSE(texture->canAcquireBackingTexture());
411 EXPECT_FALSE(texture->haveBackingTexture()); 414 EXPECT_FALSE(texture->haveBackingTexture());
412 415
413 texture->setTextureManager(resourceManagerTwo.get()); 416 texture->setTextureManager(resourceManagerTwo.get());
414 417
415 prioritizeTexturesAndBackings(resourceManagerTwo.get()); 418 prioritizeTexturesAndBackings(resourceManagerTwo.get());
416 419
417 EXPECT_TRUE(validateTexture(texture, false)); 420 EXPECT_TRUE(validateTexture(texture, false));
418 EXPECT_TRUE(texture->canAcquireBackingTexture()); 421 EXPECT_TRUE(texture->canAcquireBackingTexture());
419 EXPECT_TRUE(texture->haveBackingTexture()); 422 EXPECT_TRUE(texture->haveBackingTexture());
420 423
421 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 424 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
422 resourceManagerTwo->clearAllMemory(resourceProvider()); 425 resourceManagerTwo->clearAllMemory(resourceProvider());
423 } 426 }
424 427
425 TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSu rface) 428 TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSu rface)
426 { 429 {
427 const size_t maxTextures = 8; 430 const size_t maxTextures = 8;
428 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 431 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
429 432
430 // Half of the memory is taken by surfaces (with high priority place-holder) 433 // Half of the memory is taken by surfaces (with high priority place-holder)
431 scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager-> createTexture(m_textureSize, m_textureFormat); 434 scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager-> createTexture(m_textureSize, m_textureFormat);
(...skipping 25 matching lines...) Expand all
457 prioritizeTexturesAndBackings(resourceManager.get()); 460 prioritizeTexturesAndBackings(resourceManager.get());
458 EXPECT_FALSE(validateTexture(textures[0], false)); 461 EXPECT_FALSE(validateTexture(textures[0], false));
459 EXPECT_FALSE(validateTexture(textures[3], false)); 462 EXPECT_FALSE(validateTexture(textures[3], false));
460 EXPECT_TRUE(validateTexture(textures[4], false)); 463 EXPECT_TRUE(validateTexture(textures[4], false));
461 EXPECT_TRUE(validateTexture(textures[7], false)); 464 EXPECT_TRUE(validateTexture(textures[7], false));
462 465
463 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); 466 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
464 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextur es()); 467 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextur es());
465 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 468 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
466 469
467 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 470 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
468 resourceManager->clearAllMemory(resourceProvider()); 471 resourceManager->clearAllMemory(resourceProvider());
469 } 472 }
470 473
471 TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLat e) 474 TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLat e)
472 { 475 {
473 const size_t maxTextures = 8; 476 const size_t maxTextures = 8;
474 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 477 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
475 478
476 // Half of the memory is taken by surfaces (with high priority place-holder) 479 // Half of the memory is taken by surfaces (with high priority place-holder)
477 scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager-> createTexture(m_textureSize, m_textureFormat); 480 scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager-> createTexture(m_textureSize, m_textureFormat);
(...skipping 16 matching lines...) Expand all
494 EXPECT_FALSE(validateTexture(textures[i], false)); 497 EXPECT_FALSE(validateTexture(textures[i], false));
495 for (unsigned i = 0; i < maxTextures; i += 2) 498 for (unsigned i = 0; i < maxTextures; i += 2)
496 EXPECT_TRUE(validateTexture(textures[i], true)); 499 EXPECT_TRUE(validateTexture(textures[i], true));
497 for (unsigned i = 1; i < maxTextures; i += 2) 500 for (unsigned i = 1; i < maxTextures; i += 2)
498 EXPECT_FALSE(validateTexture(textures[i], true)); 501 EXPECT_FALSE(validateTexture(textures[i], true));
499 502
500 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); 503 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
501 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextur es()); 504 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextur es());
502 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 505 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
503 506
504 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 507 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
505 resourceManager->clearAllMemory(resourceProvider()); 508 resourceManager->clearAllMemory(resourceProvider());
506 } 509 }
507 510
508 TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvai lable) 511 TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvai lable)
509 { 512 {
510 const size_t maxTextures = 8; 513 const size_t maxTextures = 8;
511 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 514 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
512 515
513 // Half of the memory is taken by surfaces (with high priority place-holder) 516 // Half of the memory is taken by surfaces (with high priority place-holder)
514 scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager-> createTexture(m_textureSize, m_textureFormat); 517 scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager-> createTexture(m_textureSize, m_textureFormat);
(...skipping 19 matching lines...) Expand all
534 EXPECT_FALSE(validateTexture(textures[7], true)); 537 EXPECT_FALSE(validateTexture(textures[7], true));
535 538
536 // Root surface textures are valid. 539 // Root surface textures are valid.
537 for (size_t i = 0; i < 6; ++i) 540 for (size_t i = 0; i < 6; ++i)
538 EXPECT_TRUE(validateTexture(textures[i], false)); 541 EXPECT_TRUE(validateTexture(textures[i], false));
539 542
540 EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes()); 543 EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes());
541 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryForSelfManagedTextur es()); 544 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryForSelfManagedTextur es());
542 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes()); 545 EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCut offBytes());
543 546
544 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 547 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
545 resourceManager->clearAllMemory(resourceProvider()); 548 resourceManager->clearAllMemory(resourceProvider());
546 } 549 }
547 550
548 TEST_F(PrioritizedResourceTest, requestLateBackingsSorting) 551 TEST_F(PrioritizedResourceTest, requestLateBackingsSorting)
549 { 552 {
550 const size_t maxTextures = 8; 553 const size_t maxTextures = 8;
551 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures); 554 scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTe xtures);
552 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); 555 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
553 556
554 // Create textures to fill our memory limit. 557 // Create textures to fill our memory limit.
(...skipping 27 matching lines...) Expand all
582 // Make sure that we have backings for all of the textures. 585 // Make sure that we have backings for all of the textures.
583 for (size_t i = 0; i < maxTextures; ++i) 586 for (size_t i = 0; i < maxTextures; ++i)
584 EXPECT_TRUE(textures[i]->haveBackingTexture()); 587 EXPECT_TRUE(textures[i]->haveBackingTexture());
585 588
586 // Make sure that only the requestLate textures are above the priority cutof f 589 // Make sure that only the requestLate textures are above the priority cutof f
587 for (size_t i = 0; i < maxTextures; i += 2) 590 for (size_t i = 0; i < maxTextures; i += 2)
588 EXPECT_TRUE(textureBackingIsAbovePriorityCutoff(textures[i].get())); 591 EXPECT_TRUE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
589 for (size_t i = 1; i < maxTextures; i += 2) 592 for (size_t i = 1; i < maxTextures; i += 2)
590 EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get())); 593 EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
591 594
592 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 595 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
593 resourceManager->clearAllMemory(resourceProvider()); 596 resourceManager->clearAllMemory(resourceProvider());
594 } 597 }
595 598
596 TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources) 599 TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources)
597 { 600 {
598 const size_t maxTextures = 4; 601 const size_t maxTextures = 4;
599 scoped_ptr<PrioritizedResourceManager> resourceManager = 602 scoped_ptr<PrioritizedResourceManager> resourceManager =
600 createManager(maxTextures); 603 createManager(maxTextures);
601 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); 604 resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
602 605
603 // Create textures to fill our memory limit. 606 // Create textures to fill our memory limit.
604 scoped_ptr<PrioritizedResource> textures[maxTextures]; 607 scoped_ptr<PrioritizedResource> textures[maxTextures];
605 608
606 for (size_t i = 0; i < maxTextures; ++i) 609 for (size_t i = 0; i < maxTextures; ++i)
607 textures[i] = resourceManager->createTexture(m_textureSize, m_textureFor mat); 610 textures[i] = resourceManager->createTexture(m_textureSize, m_textureFor mat);
608 611
609 // Set equal priorities, and allocate backings for all textures. 612 // Set equal priorities, and allocate backings for all textures.
610 for (size_t i = 0; i < maxTextures; ++i) 613 for (size_t i = 0; i < maxTextures; ++i)
611 textures[i]->setRequestPriority(100); 614 textures[i]->setRequestPriority(100);
612 prioritizeTexturesAndBackings(resourceManager.get()); 615 prioritizeTexturesAndBackings(resourceManager.get());
613 for (unsigned i = 0; i < maxTextures; ++i) 616 for (unsigned i = 0; i < maxTextures; ++i)
614 EXPECT_TRUE(validateTexture(textures[i], false)); 617 EXPECT_TRUE(validateTexture(textures[i], false));
615 618
616 ResourceUpdateQueue queue; 619 ResourceUpdateQueue queue;
617 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 620 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
618 for (size_t i = 0; i < maxTextures; ++i) { 621 for (size_t i = 0; i < maxTextures; ++i) {
619 const ResourceUpdate upload = ResourceUpdate::Create( 622 const ResourceUpdate upload = ResourceUpdate::Create(
620 textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d()); 623 textures[i].get(), NULL, gfx::Rect(), gfx::Rect(), gfx::Vector2d());
621 queue.appendFullUpload(upload); 624 queue.appendFullUpload(upload);
622 } 625 }
623 626
624 // Make sure that we have backings for all of the textures. 627 // Make sure that we have backings for all of the textures.
625 for (size_t i = 0; i < maxTextures; ++i) 628 for (size_t i = 0; i < maxTextures; ++i)
626 EXPECT_TRUE(textures[i]->haveBackingTexture()); 629 EXPECT_TRUE(textures[i]->haveBackingTexture());
627 630
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 prioritizeTexturesAndBackings(resourceManager.get()); 662 prioritizeTexturesAndBackings(resourceManager.get());
660 663
661 // The first two textures should be available, others should not. 664 // The first two textures should be available, others should not.
662 for (size_t i = 0; i < 2; ++i) 665 for (size_t i = 0; i < 2; ++i)
663 EXPECT_TRUE(validateTexture(textures[i], false)); 666 EXPECT_TRUE(validateTexture(textures[i], false));
664 for (size_t i = 2; i < maxTextures; ++i) 667 for (size_t i = 2; i < maxTextures; ++i)
665 EXPECT_FALSE(validateTexture(textures[i], false)); 668 EXPECT_FALSE(validateTexture(textures[i], false));
666 669
667 // Validate the statistics. 670 // Validate the statistics.
668 { 671 {
669 DebugScopedSetImplThread implThread; 672 DebugScopedSetImplThread implThread(&m_proxy);
670 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); 673 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
671 EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes()); 674 EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes());
672 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearby Bytes()); 675 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearby Bytes());
673 } 676 }
674 677
675 // Re-prioritize the textures, but do not push the values to backings. 678 // Re-prioritize the textures, but do not push the values to backings.
676 textures[0]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1); 679 textures[0]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1);
677 textures[1]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1); 680 textures[1]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1);
678 textures[2]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1); 681 textures[2]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1);
679 textures[3]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCut off() - 1); 682 textures[3]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCut off() - 1);
680 textures[4]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCut off()); 683 textures[4]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCut off());
681 resourceManager->prioritizeTextures(); 684 resourceManager->prioritizeTextures();
682 685
683 // Verify that we still see the old values. 686 // Verify that we still see the old values.
684 { 687 {
685 DebugScopedSetImplThread implThread; 688 DebugScopedSetImplThread implThread(&m_proxy);
686 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); 689 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
687 EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes()); 690 EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes());
688 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearby Bytes()); 691 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearby Bytes());
689 } 692 }
690 693
691 // Push priorities to backings, and verify we see the new values. 694 // Push priorities to backings, and verify we see the new values.
692 { 695 {
693 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 696 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
694 resourceManager->pushTexturePrioritiesToBackings(); 697 resourceManager->pushTexturePrioritiesToBackings();
695 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); 698 EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
696 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); 699 EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes());
697 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby Bytes()); 700 EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearby Bytes());
698 } 701 }
699 702
700 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 703 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
701 resourceManager->clearAllMemory(resourceProvider()); 704 resourceManager->clearAllMemory(resourceProvider());
702 } 705 }
703 706
704 707
705 } // anonymous namespace 708 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/prioritized_resource_manager.cc ('k') | cc/proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698