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

Side by Side Diff: cc/prioritized_texture_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 165064 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
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_texture.h" 7 #include "cc/prioritized_texture.h"
8 8
9 #include "cc/prioritized_texture_manager.h" 9 #include "cc/prioritized_texture_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 PrioritizedTextureTest : public testing::Test { 22 class PrioritizedTextureTest : public testing::Test {
22 public: 23 public:
23 PrioritizedTextureTest() 24 PrioritizedTextureTest()
24 : m_textureSize(256, 256) 25 : m_proxy(0)
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 ~PrioritizedTextureTest() 34 virtual ~PrioritizedTextureTest()
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<PrioritizedTextureManager> createManager(size_t maxTextures) 45 scoped_ptr<PrioritizedTextureManager> createManager(size_t maxTextures)
44 { 46 {
45 return PrioritizedTextureManager::create(texturesMemorySize(maxTextures) , 1024, 0); 47 return PrioritizedTextureManager::create(texturesMemorySize(maxTextures) , 1024, 0, &m_proxy);
46 } 48 }
47 49
48 bool validateTexture(scoped_ptr<PrioritizedTexture>& texture, bool requestLa te) 50 bool validateTexture(scoped_ptr<PrioritizedTexture>& texture, bool requestLa te)
49 { 51 {
50 textureManagerAssertInvariants(texture->textureManager()); 52 textureManagerAssertInvariants(texture->textureManager());
51 if (requestLate) 53 if (requestLate)
52 texture->requestLate(); 54 texture->requestLate();
53 textureManagerAssertInvariants(texture->textureManager()); 55 textureManagerAssertInvariants(texture->textureManager());
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(PrioritizedTextureManager* textureManager ) 63 void prioritizeTexturesAndBackings(PrioritizedTextureManager* textureManager )
62 { 64 {
63 textureManager->prioritizeTextures(); 65 textureManager->prioritizeTextures();
64 textureManagerUpdateBackingsPriorities(textureManager); 66 textureManagerUpdateBackingsPriorities(textureManager);
65 } 67 }
66 68
67 void textureManagerUpdateBackingsPriorities(PrioritizedTextureManager* textu reManager) 69 void textureManagerUpdateBackingsPriorities(PrioritizedTextureManager* textu reManager)
68 { 70 {
69 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 71 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
70 textureManager->pushTexturePrioritiesToBackings(); 72 textureManager->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 textureManagerAssertInvariants(PrioritizedTextureManager* textureManage r) 80 void textureManagerAssertInvariants(PrioritizedTextureManager* textureManage r)
79 { 81 {
80 #ifndef NDEBUG 82 #ifndef NDEBUG
81 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 83 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
82 textureManager->assertInvariants(); 84 textureManager->assertInvariants();
83 #endif 85 #endif
84 } 86 }
85 87
86 bool textureBackingIsAbovePriorityCutoff(PrioritizedTexture* texture) 88 bool textureBackingIsAbovePriorityCutoff(PrioritizedTexture* 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 IntSize m_textureSize; 95 const IntSize 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(textureManager.get()); 132 prioritizeTexturesAndBackings(textureManager.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), textureManager->memoryAboveCutoff Bytes()); 138 EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoff Bytes());
136 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 139 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
137 140
138 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 141 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
139 textureManager->clearAllMemory(resourceProvider()); 142 textureManager->clearAllMemory(resourceProvider());
140 } 143 }
141 144
142 TEST_F(PrioritizedTextureTest, changeMemoryLimits) 145 TEST_F(PrioritizedTextureTest, changeMemoryLimits)
143 { 146 {
144 const size_t maxTextures = 8; 147 const size_t maxTextures = 8;
145 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 148 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
146 scoped_ptr<PrioritizedTexture> textures[maxTextures]; 149 scoped_ptr<PrioritizedTexture> 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] = textureManager->createTexture(m_textureSize, m_textureForm at); 152 textures[i] = textureManager->createTexture(m_textureSize, m_textureForm at);
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 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); 157 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
155 prioritizeTexturesAndBackings(textureManager.get()); 158 prioritizeTexturesAndBackings(textureManager.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 textureManager->reduceMemory(resourceProvider()); 163 textureManager->reduceMemory(resourceProvider());
161 } 164 }
162 165
163 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); 166 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
164 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 167 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
165 168
166 // Set max limit to 5 textures 169 // Set max limit to 5 textures
167 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5)); 170 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5));
168 prioritizeTexturesAndBackings(textureManager.get()); 171 prioritizeTexturesAndBackings(textureManager.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 textureManager->reduceMemory(resourceProvider()); 176 textureManager->reduceMemory(resourceProvider());
174 } 177 }
175 178
176 EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes()); 179 EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes());
177 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 180 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
178 181
179 // Set max limit to 4 textures 182 // Set max limit to 4 textures
180 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4)); 183 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4));
181 prioritizeTexturesAndBackings(textureManager.get()); 184 prioritizeTexturesAndBackings(textureManager.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 textureManager->reduceMemory(resourceProvider()); 189 textureManager->reduceMemory(resourceProvider());
187 } 190 }
188 191
189 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); 192 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
190 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 193 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
191 194
192 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 195 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
193 textureManager->clearAllMemory(resourceProvider()); 196 textureManager->clearAllMemory(resourceProvider());
194 } 197 }
195 198
196 TEST_F(PrioritizedTextureTest, changePriorityCutoff) 199 TEST_F(PrioritizedTextureTest, changePriorityCutoff)
197 { 200 {
198 const size_t maxTextures = 8; 201 const size_t maxTextures = 8;
199 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 202 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
200 scoped_ptr<PrioritizedTexture> textures[maxTextures]; 203 scoped_ptr<PrioritizedTexture> 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] = textureManager->createTexture(m_textureSize, m_textureForm at); 206 textures[i] = textureManager->createTexture(m_textureSize, m_textureForm at);
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 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); 213 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
211 textureManager->setExternalPriorityCutoff(106); 214 textureManager->setExternalPriorityCutoff(106);
212 prioritizeTexturesAndBackings(textureManager.get()); 215 prioritizeTexturesAndBackings(textureManager.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 textureManager->reduceMemory(resourceProvider()); 220 textureManager->reduceMemory(resourceProvider());
218 } 221 }
219 EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes()); 222 EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
220 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 223 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
221 224
222 // Set the cutoff to drop two more textures. 225 // Set the cutoff to drop two more textures.
223 textureManager->setExternalPriorityCutoff(104); 226 textureManager->setExternalPriorityCutoff(104);
224 prioritizeTexturesAndBackings(textureManager.get()); 227 prioritizeTexturesAndBackings(textureManager.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 textureManager->reduceMemory(resourceProvider()); 232 textureManager->reduceMemory(resourceProvider());
230 } 233 }
231 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); 234 EXPECT_EQ(texturesMemorySize(4), textureManager->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 PrioritizedTextureManager::BackingList evictedBackings; 237 PrioritizedTextureManager::BackingList evictedBackings;
235 { 238 {
236 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked; 239 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked(&m_proxy);
237 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, res ourceProvider()); 240 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, res ourceProvider());
238 textureManager->getEvictedBackings(evictedBackings); 241 textureManager->getEvictedBackings(evictedBackings);
239 EXPECT_EQ(0, evictedBackings.size()); 242 EXPECT_EQ(0, evictedBackings.size());
240 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, res ourceProvider()); 243 textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, res ourceProvider());
241 textureManager->getEvictedBackings(evictedBackings); 244 textureManager->getEvictedBackings(evictedBackings);
242 EXPECT_EQ(1, evictedBackings.size()); 245 EXPECT_EQ(1, evictedBackings.size());
243 } 246 }
244 textureManager->unlinkEvictedBackings(evictedBackings); 247 textureManager->unlinkEvictedBackings(evictedBackings);
245 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryUseBytes()); 248 EXPECT_EQ(texturesMemorySize(3), textureManager->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(textureManager.get()); 251 prioritizeTexturesAndBackings(textureManager.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 textureManager->reduceMemory(resourceProvider()); 256 textureManager->reduceMemory(resourceProvider());
254 } 257 }
255 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); 258 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
256 259
257 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 260 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
258 textureManager->clearAllMemory(resourceProvider()); 261 textureManager->clearAllMemory(resourceProvider());
259 } 262 }
260 263
261 TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures) 264 TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures)
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<PrioritizedTextureManager> textureManager = createManager(maxText ures); 268 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
266 scoped_ptr<PrioritizedTexture> textures[numTextures]; 269 scoped_ptr<PrioritizedTexture> textures[numTextures];
267 scoped_ptr<PrioritizedTexture> moreTextures[numTextures]; 270 scoped_ptr<PrioritizedTexture> 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 textureManager->clearAllMemory(resourceProvider()); 321 textureManager->clearAllMemory(resourceProvider());
319 } 322 }
320 323
321 TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual) 324 TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual)
322 { 325 {
323 const size_t maxTextures = 16; 326 const size_t maxTextures = 16;
324 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 327 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
325 scoped_ptr<PrioritizedTexture> textures[maxTextures]; 328 scoped_ptr<PrioritizedTexture> 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), textureManager->memoryAboveCutoffBytes()); 357 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
355 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 358 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
356 359
357 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 360 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
358 textureManager->clearAllMemory(resourceProvider()); 361 textureManager->clearAllMemory(resourceProvider());
359 } 362 }
360 363
361 TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst) 364 TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst)
362 { 365 {
363 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(1); 366 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(1);
364 scoped_ptr<PrioritizedTexture> texture = textureManager->createTexture(m_tex tureSize, m_textureFormat); 367 scoped_ptr<PrioritizedTexture> texture = textureManager->createTexture(m_tex tureSize, 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(textureManager.get()); 373 prioritizeTexturesAndBackings(textureManager.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 textureManager->clearAllMemory(resourceProvider()); 381 textureManager->clearAllMemory(resourceProvider());
379 } 382 }
380 textureManager.reset(); 383 textureManager.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(PrioritizedTextureTest, textureMovedToNewManager) 389 TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
387 { 390 {
388 scoped_ptr<PrioritizedTextureManager> textureManagerOne = createManager(1); 391 scoped_ptr<PrioritizedTextureManager> textureManagerOne = createManager(1);
389 scoped_ptr<PrioritizedTextureManager> textureManagerTwo = createManager(1); 392 scoped_ptr<PrioritizedTextureManager> textureManagerTwo = createManager(1);
390 scoped_ptr<PrioritizedTexture> texture = textureManagerOne->createTexture(m_ textureSize, m_textureFormat); 393 scoped_ptr<PrioritizedTexture> texture = textureManagerOne->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(textureManagerOne.get()); 399 prioritizeTexturesAndBackings(textureManagerOne.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 textureManagerOne->clearAllMemory(resourceProvider()); 409 textureManagerOne->clearAllMemory(resourceProvider());
407 } 410 }
408 textureManagerOne.reset(); 411 textureManagerOne.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(textureManagerTwo.get()); 416 texture->setTextureManager(textureManagerTwo.get());
414 417
415 prioritizeTexturesAndBackings(textureManagerTwo.get()); 418 prioritizeTexturesAndBackings(textureManagerTwo.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 textureManagerTwo->clearAllMemory(resourceProvider()); 425 textureManagerTwo->clearAllMemory(resourceProvider());
423 } 426 }
424 427
425 TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSur face) 428 TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSur face)
426 { 429 {
427 const size_t maxTextures = 8; 430 const size_t maxTextures = 8;
428 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 431 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
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<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->cr eateTexture(m_textureSize, m_textureFormat); 434 scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->cr eateTexture(m_textureSize, m_textureFormat);
(...skipping 25 matching lines...) Expand all
457 prioritizeTexturesAndBackings(textureManager.get()); 460 prioritizeTexturesAndBackings(textureManager.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), textureManager->memoryAboveCutoffBytes()); 466 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
464 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s()); 467 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s());
465 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 468 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
466 469
467 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 470 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
468 textureManager->clearAllMemory(resourceProvider()); 471 textureManager->clearAllMemory(resourceProvider());
469 } 472 }
470 473
471 TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate ) 474 TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate )
472 { 475 {
473 const size_t maxTextures = 8; 476 const size_t maxTextures = 8;
474 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 477 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
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<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->cr eateTexture(m_textureSize, m_textureFormat); 480 scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->cr eateTexture(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), textureManager->memoryAboveCutoffBytes()); 503 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
501 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s()); 504 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s());
502 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 505 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
503 506
504 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 507 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
505 textureManager->clearAllMemory(resourceProvider()); 508 textureManager->clearAllMemory(resourceProvider());
506 } 509 }
507 510
508 TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail able) 511 TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail able)
509 { 512 {
510 const size_t maxTextures = 8; 513 const size_t maxTextures = 8;
511 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 514 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
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<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->cr eateTexture(m_textureSize, m_textureFormat); 517 scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->cr eateTexture(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), textureManager->memoryAboveCutoffBytes()); 543 EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
541 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTexture s()); 544 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTexture s());
542 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 545 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
543 546
544 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 547 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
545 textureManager->clearAllMemory(resourceProvider()); 548 textureManager->clearAllMemory(resourceProvider());
546 } 549 }
547 550
548 TEST_F(PrioritizedTextureTest, requestLateBackingsSorting) 551 TEST_F(PrioritizedTextureTest, requestLateBackingsSorting)
549 { 552 {
550 const size_t maxTextures = 8; 553 const size_t maxTextures = 8;
551 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures); 554 scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxText ures);
552 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); 555 textureManager->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 textureManager->clearAllMemory(resourceProvider()); 596 textureManager->clearAllMemory(resourceProvider());
594 } 597 }
595 598
596 TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources) 599 TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources)
597 { 600 {
598 const size_t maxTextures = 4; 601 const size_t maxTextures = 4;
599 scoped_ptr<PrioritizedTextureManager> textureManager = 602 scoped_ptr<PrioritizedTextureManager> textureManager =
600 createManager(maxTextures); 603 createManager(maxTextures);
601 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); 604 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
602 605
603 // Create textures to fill our memory limit. 606 // Create textures to fill our memory limit.
604 scoped_ptr<PrioritizedTexture> textures[maxTextures]; 607 scoped_ptr<PrioritizedTexture> 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] = textureManager->createTexture(m_textureSize, m_textureForm at); 610 textures[i] = textureManager->createTexture(m_textureSize, m_textureForm at);
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(textureManager.get()); 615 prioritizeTexturesAndBackings(textureManager.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, IntRect(), IntRect(), IntSize()); 623 textures[i].get(), NULL, IntRect(), IntRect(), IntSize());
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(textureManager.get()); 662 prioritizeTexturesAndBackings(textureManager.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), textureManager->memoryUseBytes()); 673 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
671 EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes()); 674 EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes());
672 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyB ytes()); 675 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyB ytes());
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 textureManager->prioritizeTextures(); 684 textureManager->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), textureManager->memoryUseBytes()); 689 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
687 EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes()); 690 EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes());
688 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyB ytes()); 691 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyB ytes());
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 textureManager->pushTexturePrioritiesToBackings(); 697 textureManager->pushTexturePrioritiesToBackings();
695 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes()); 698 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
696 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes()); 699 EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes());
697 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyB ytes()); 700 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyB ytes());
698 } 701 }
699 702
700 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; 703 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked( &m_proxy);
701 textureManager->clearAllMemory(resourceProvider()); 704 textureManager->clearAllMemory(resourceProvider());
702 } 705 }
703 706
704 707
705 } // namespace 708 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698