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

Side by Side Diff: cc/CCPrioritizedTextureTest.cpp

Issue 10920059: Rolls cc and webkit_compositor up to 127340 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/CCPrioritizedTextureManager.cpp ('k') | cc/CCSingleThreadProxy.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 "CCPrioritizedTexture.h" 7 #include "CCPrioritizedTexture.h"
8 8
9 #include "CCPrioritizedTextureManager.h" 9 #include "CCPrioritizedTextureManager.h"
10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread 10 #include "CCSingleThreadProxy.h" // For DebugScopedSetImplThread
11 #include "CCTexture.h" 11 #include "CCTexture.h"
12 #include "CCTiledLayerTestCommon.h" 12 #include "CCTiledLayerTestCommon.h"
13 #include "FakeCCGraphicsContext.h" 13 #include "FakeCCGraphicsContext.h"
14 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
15 #include <public/WebCompositor.h>
15 16
16 using namespace WebCore; 17 using namespace WebCore;
17 using namespace WebKitTests; 18 using namespace WebKitTests;
18 using namespace WTF; 19 using namespace WTF;
19 20
20 namespace { 21 namespace {
21 22
22 class CCPrioritizedTextureTest : public testing::Test { 23 class CCPrioritizedTextureTest : public testing::Test {
23 public: 24 public:
24 CCPrioritizedTextureTest() 25 CCPrioritizedTextureTest()
25 : m_textureSize(256, 256) 26 : m_textureSize(256, 256)
26 , m_textureFormat(GraphicsContext3D::RGBA) 27 , m_textureFormat(GraphicsContext3D::RGBA)
27 , m_context(WebKit::createFakeCCGraphicsContext()) 28 , m_context(WebKit::createFakeCCGraphicsContext())
28 { 29 {
30 WebKit::WebCompositor::initialize(0);
29 DebugScopedSetImplThread implThread; 31 DebugScopedSetImplThread implThread;
30 m_resourceProvider = CCResourceProvider::create(m_context.get()); 32 m_resourceProvider = CCResourceProvider::create(m_context.get());
31 } 33 }
32 34
33 virtual ~CCPrioritizedTextureTest() 35 virtual ~CCPrioritizedTextureTest()
34 { 36 {
35 DebugScopedSetImplThread implThread; 37 {
36 m_resourceProvider.clear(); 38 DebugScopedSetImplThread implThread;
39 m_resourceProvider.clear();
40 }
41 WebKit::WebCompositor::shutdown();
37 } 42 }
38 43
39 size_t texturesMemorySize(size_t textureCount) 44 size_t texturesMemorySize(size_t textureCount)
40 { 45 {
41 return CCTexture::memorySizeBytes(m_textureSize, m_textureFormat) * text ureCount; 46 return CCTexture::memorySizeBytes(m_textureSize, m_textureFormat) * text ureCount;
42 } 47 }
43 48
44 PassOwnPtr<CCPrioritizedTextureManager> createManager(size_t maxTextures) 49 PassOwnPtr<CCPrioritizedTextureManager> createManager(size_t maxTextures)
45 { 50 {
46 return CCPrioritizedTextureManager::create(texturesMemorySize(maxTexture s), 1024, 0); 51 return CCPrioritizedTextureManager::create(texturesMemorySize(maxTexture s), 1024, 0);
47 } 52 }
48 53
49 bool validateTexture(OwnPtr<CCPrioritizedTexture>& texture, bool requestLate ) 54 bool validateTexture(OwnPtr<CCPrioritizedTexture>& texture, bool requestLate )
50 { 55 {
51 DebugScopedSetImplThread implThread;
52 #if !ASSERT_DISABLED 56 #if !ASSERT_DISABLED
53 texture->textureManager()->assertInvariants(); 57 texture->textureManager()->assertInvariants();
54 #endif 58 #endif
55 if (requestLate) 59 if (requestLate)
56 texture->requestLate(); 60 texture->requestLate();
61 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
57 bool success = texture->canAcquireBackingTexture(); 62 bool success = texture->canAcquireBackingTexture();
58 if (success) 63 if (success)
59 texture->acquireBackingTexture(resourceProvider()); 64 texture->acquireBackingTexture(resourceProvider());
60 return success; 65 return success;
61 } 66 }
62 67
63 CCResourceProvider* resourceProvider() 68 CCResourceProvider* resourceProvider()
64 { 69 {
65 return m_resourceProvider.get(); 70 return m_resourceProvider.get();
66 } 71 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Only upper half should be available. 106 // Only upper half should be available.
102 textureManager->prioritizeTextures(); 107 textureManager->prioritizeTextures();
103 EXPECT_FALSE(validateTexture(textures[0], false)); 108 EXPECT_FALSE(validateTexture(textures[0], false));
104 EXPECT_FALSE(validateTexture(textures[7], false)); 109 EXPECT_FALSE(validateTexture(textures[7], false));
105 EXPECT_TRUE(validateTexture(textures[8], false)); 110 EXPECT_TRUE(validateTexture(textures[8], false));
106 EXPECT_TRUE(validateTexture(textures[15], false)); 111 EXPECT_TRUE(validateTexture(textures[15], false));
107 112
108 EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoff Bytes()); 113 EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoff Bytes());
109 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 114 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
110 115
111 DebugScopedSetImplThread implThread; 116 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
112 textureManager->clearAllMemory(resourceProvider()); 117 textureManager->clearAllMemory(resourceProvider());
113 } 118 }
114 119
115 TEST_F(CCPrioritizedTextureTest, changeMemoryLimits) 120 TEST_F(CCPrioritizedTextureTest, changeMemoryLimits)
116 { 121 {
117 const size_t maxTextures = 8; 122 const size_t maxTextures = 8;
118 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es); 123 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es);
119 OwnPtr<CCPrioritizedTexture> textures[maxTextures]; 124 OwnPtr<CCPrioritizedTexture> textures[maxTextures];
120 125
121 for (size_t i = 0; i < maxTextures; ++i) 126 for (size_t i = 0; i < maxTextures; ++i)
122 textures[i] = textureManager->createTexture(m_textureSize, m_textureForm at); 127 textures[i] = textureManager->createTexture(m_textureSize, m_textureForm at);
123 for (size_t i = 0; i < maxTextures; ++i) 128 for (size_t i = 0; i < maxTextures; ++i)
124 textures[i]->setRequestPriority(100 + i); 129 textures[i]->setRequestPriority(100 + i);
125 130
126 // Set max limit to 8 textures 131 // Set max limit to 8 textures
127 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); 132 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
128 textureManager->prioritizeTextures(); 133 textureManager->prioritizeTextures();
129 for (size_t i = 0; i < maxTextures; ++i) 134 for (size_t i = 0; i < maxTextures; ++i)
130 validateTexture(textures[i], false); 135 validateTexture(textures[i], false);
131 { 136 {
132 DebugScopedSetImplThread implThread; 137 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
133 textureManager->reduceMemory(resourceProvider()); 138 textureManager->reduceMemory(resourceProvider());
134 } 139 }
135 140
136 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); 141 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
137 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 142 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
138 143
139 // Set max limit to 5 textures 144 // Set max limit to 5 textures
140 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5)); 145 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5));
141 textureManager->prioritizeTextures(); 146 textureManager->prioritizeTextures();
142 for (size_t i = 0; i < maxTextures; ++i) 147 for (size_t i = 0; i < maxTextures; ++i)
143 EXPECT_EQ(validateTexture(textures[i], false), i < 5); 148 EXPECT_EQ(validateTexture(textures[i], false), i < 5);
144 { 149 {
145 DebugScopedSetImplThread implThread; 150 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
146 textureManager->reduceMemory(resourceProvider()); 151 textureManager->reduceMemory(resourceProvider());
147 } 152 }
148 153
149 EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes()); 154 EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes());
150 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 155 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
151 156
152 // Set max limit to 4 textures 157 // Set max limit to 4 textures
153 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4)); 158 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4));
154 textureManager->prioritizeTextures(); 159 textureManager->prioritizeTextures();
155 for (size_t i = 0; i < maxTextures; ++i) 160 for (size_t i = 0; i < maxTextures; ++i)
156 EXPECT_EQ(validateTexture(textures[i], false), i < 4); 161 EXPECT_EQ(validateTexture(textures[i], false), i < 4);
157 { 162 {
158 DebugScopedSetImplThread implThread; 163 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
159 textureManager->reduceMemory(resourceProvider()); 164 textureManager->reduceMemory(resourceProvider());
160 } 165 }
161 166
162 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); 167 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
163 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 168 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
164 169
165 DebugScopedSetImplThread implThread; 170 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
166 textureManager->clearAllMemory(resourceProvider()); 171 textureManager->clearAllMemory(resourceProvider());
167 } 172 }
168 173
169 TEST_F(CCPrioritizedTextureTest, textureManagerPartialUpdateTextures) 174 TEST_F(CCPrioritizedTextureTest, textureManagerPartialUpdateTextures)
170 { 175 {
171 const size_t maxTextures = 4; 176 const size_t maxTextures = 4;
172 const size_t numTextures = 4; 177 const size_t numTextures = 4;
173 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es); 178 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es);
174 OwnPtr<CCPrioritizedTexture> textures[numTextures]; 179 OwnPtr<CCPrioritizedTexture> textures[numTextures];
175 OwnPtr<CCPrioritizedTexture> moreTextures[numTextures]; 180 OwnPtr<CCPrioritizedTexture> moreTextures[numTextures];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 EXPECT_TRUE(validateTexture(moreTextures[1], false)); 220 EXPECT_TRUE(validateTexture(moreTextures[1], false));
216 EXPECT_TRUE(validateTexture(moreTextures[2], false)); 221 EXPECT_TRUE(validateTexture(moreTextures[2], false));
217 EXPECT_TRUE(validateTexture(moreTextures[3], false)); 222 EXPECT_TRUE(validateTexture(moreTextures[3], false));
218 223
219 // Lower priority have been fully evicted. 224 // Lower priority have been fully evicted.
220 EXPECT_FALSE(textures[0]->haveBackingTexture()); 225 EXPECT_FALSE(textures[0]->haveBackingTexture());
221 EXPECT_FALSE(textures[1]->haveBackingTexture()); 226 EXPECT_FALSE(textures[1]->haveBackingTexture());
222 EXPECT_FALSE(textures[2]->haveBackingTexture()); 227 EXPECT_FALSE(textures[2]->haveBackingTexture());
223 EXPECT_FALSE(textures[3]->haveBackingTexture()); 228 EXPECT_FALSE(textures[3]->haveBackingTexture());
224 229
225 DebugScopedSetImplThread implThread; 230 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
226 textureManager->clearAllMemory(resourceProvider()); 231 textureManager->clearAllMemory(resourceProvider());
227 } 232 }
228 233
229 TEST_F(CCPrioritizedTextureTest, textureManagerPrioritiesAreEqual) 234 TEST_F(CCPrioritizedTextureTest, textureManagerPrioritiesAreEqual)
230 { 235 {
231 const size_t maxTextures = 16; 236 const size_t maxTextures = 16;
232 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es); 237 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es);
233 OwnPtr<CCPrioritizedTexture> textures[maxTextures]; 238 OwnPtr<CCPrioritizedTexture> textures[maxTextures];
234 239
235 for (size_t i = 0; i < maxTextures; ++i) 240 for (size_t i = 0; i < maxTextures; ++i)
(...skipping 19 matching lines...) Expand all
255 260
256 // Manually reserving textures should only succeed on the higher priority te xtures, 261 // Manually reserving textures should only succeed on the higher priority te xtures,
257 // and on remaining textures up to the memory limit. 262 // and on remaining textures up to the memory limit.
258 for (size_t i = 0; i < 8; i++) 263 for (size_t i = 0; i < 8; i++)
259 EXPECT_TRUE(validateTexture(textures[i], true)); 264 EXPECT_TRUE(validateTexture(textures[i], true));
260 for (size_t i = 9; i < maxTextures; i++) 265 for (size_t i = 9; i < maxTextures; i++)
261 EXPECT_FALSE(validateTexture(textures[i], true)); 266 EXPECT_FALSE(validateTexture(textures[i], true));
262 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); 267 EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
263 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 268 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
264 269
265 DebugScopedSetImplThread implThread; 270 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
266 textureManager->clearAllMemory(resourceProvider()); 271 textureManager->clearAllMemory(resourceProvider());
267 } 272 }
268 273
269 TEST_F(CCPrioritizedTextureTest, textureManagerDestroyedFirst) 274 TEST_F(CCPrioritizedTextureTest, textureManagerDestroyedFirst)
270 { 275 {
271 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(1); 276 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(1);
272 OwnPtr<CCPrioritizedTexture> texture = textureManager->createTexture(m_textu reSize, m_textureFormat); 277 OwnPtr<CCPrioritizedTexture> texture = textureManager->createTexture(m_textu reSize, m_textureFormat);
273 278
274 // Texture is initially invalid, but it will become available. 279 // Texture is initially invalid, but it will become available.
275 EXPECT_FALSE(texture->haveBackingTexture()); 280 EXPECT_FALSE(texture->haveBackingTexture());
276 281
277 texture->setRequestPriority(100); 282 texture->setRequestPriority(100);
278 textureManager->prioritizeTextures(); 283 textureManager->prioritizeTextures();
279 284
280 EXPECT_TRUE(validateTexture(texture, false)); 285 EXPECT_TRUE(validateTexture(texture, false));
281 EXPECT_TRUE(texture->canAcquireBackingTexture()); 286 EXPECT_TRUE(texture->canAcquireBackingTexture());
282 EXPECT_TRUE(texture->haveBackingTexture()); 287 EXPECT_TRUE(texture->haveBackingTexture());
283 288
284 { 289 {
285 DebugScopedSetImplThread implThread; 290 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
286 textureManager->clearAllMemory(resourceProvider()); 291 textureManager->clearAllMemory(resourceProvider());
287 } 292 }
288 textureManager.clear(); 293 textureManager.clear();
289 294
290 EXPECT_FALSE(texture->canAcquireBackingTexture()); 295 EXPECT_FALSE(texture->canAcquireBackingTexture());
291 EXPECT_FALSE(texture->haveBackingTexture()); 296 EXPECT_FALSE(texture->haveBackingTexture());
292 } 297 }
293 298
294 TEST_F(CCPrioritizedTextureTest, textureMovedToNewManager) 299 TEST_F(CCPrioritizedTextureTest, textureMovedToNewManager)
295 { 300 {
296 OwnPtr<CCPrioritizedTextureManager> textureManagerOne = createManager(1); 301 OwnPtr<CCPrioritizedTextureManager> textureManagerOne = createManager(1);
297 OwnPtr<CCPrioritizedTextureManager> textureManagerTwo = createManager(1); 302 OwnPtr<CCPrioritizedTextureManager> textureManagerTwo = createManager(1);
298 OwnPtr<CCPrioritizedTexture> texture = textureManagerOne->createTexture(m_te xtureSize, m_textureFormat); 303 OwnPtr<CCPrioritizedTexture> texture = textureManagerOne->createTexture(m_te xtureSize, m_textureFormat);
299 304
300 // Texture is initially invalid, but it will become available. 305 // Texture is initially invalid, but it will become available.
301 EXPECT_FALSE(texture->haveBackingTexture()); 306 EXPECT_FALSE(texture->haveBackingTexture());
302 307
303 texture->setRequestPriority(100); 308 texture->setRequestPriority(100);
304 textureManagerOne->prioritizeTextures(); 309 textureManagerOne->prioritizeTextures();
305 310
306 EXPECT_TRUE(validateTexture(texture, false)); 311 EXPECT_TRUE(validateTexture(texture, false));
307 EXPECT_TRUE(texture->canAcquireBackingTexture()); 312 EXPECT_TRUE(texture->canAcquireBackingTexture());
308 EXPECT_TRUE(texture->haveBackingTexture()); 313 EXPECT_TRUE(texture->haveBackingTexture());
309 314
310 texture->setTextureManager(0); 315 texture->setTextureManager(0);
311 316
312 { 317 {
313 DebugScopedSetImplThread implThread; 318 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBloc ked;
314 textureManagerOne->clearAllMemory(resourceProvider()); 319 textureManagerOne->clearAllMemory(resourceProvider());
315 } 320 }
316 textureManagerOne.clear(); 321 textureManagerOne.clear();
317 322
318 EXPECT_FALSE(texture->canAcquireBackingTexture()); 323 EXPECT_FALSE(texture->canAcquireBackingTexture());
319 EXPECT_FALSE(texture->haveBackingTexture()); 324 EXPECT_FALSE(texture->haveBackingTexture());
320 325
321 texture->setTextureManager(textureManagerTwo.get()); 326 texture->setTextureManager(textureManagerTwo.get());
322 327
323 textureManagerTwo->prioritizeTextures(); 328 textureManagerTwo->prioritizeTextures();
324 329
325 EXPECT_TRUE(validateTexture(texture, false)); 330 EXPECT_TRUE(validateTexture(texture, false));
326 EXPECT_TRUE(texture->canAcquireBackingTexture()); 331 EXPECT_TRUE(texture->canAcquireBackingTexture());
327 EXPECT_TRUE(texture->haveBackingTexture()); 332 EXPECT_TRUE(texture->haveBackingTexture());
328 333
329 DebugScopedSetImplThread implThread; 334 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
330 textureManagerTwo->clearAllMemory(resourceProvider()); 335 textureManagerTwo->clearAllMemory(resourceProvider());
331 } 336 }
332 337
333 TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootS urface) 338 TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootS urface)
334 { 339 {
335 const size_t maxTextures = 8; 340 const size_t maxTextures = 8;
336 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es); 341 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es);
337 342
338 // Half of the memory is taken by surfaces (with high priority place-holder) 343 // Half of the memory is taken by surfaces (with high priority place-holder)
339 OwnPtr<CCPrioritizedTexture> renderSurfacePlaceHolder = textureManager->crea teTexture(m_textureSize, m_textureFormat); 344 OwnPtr<CCPrioritizedTexture> renderSurfacePlaceHolder = textureManager->crea teTexture(m_textureSize, m_textureFormat);
(...skipping 25 matching lines...) Expand all
365 textureManager->prioritizeTextures(); 370 textureManager->prioritizeTextures();
366 EXPECT_FALSE(validateTexture(textures[0], false)); 371 EXPECT_FALSE(validateTexture(textures[0], false));
367 EXPECT_FALSE(validateTexture(textures[3], false)); 372 EXPECT_FALSE(validateTexture(textures[3], false));
368 EXPECT_TRUE(validateTexture(textures[4], false)); 373 EXPECT_TRUE(validateTexture(textures[4], false));
369 EXPECT_TRUE(validateTexture(textures[7], false)); 374 EXPECT_TRUE(validateTexture(textures[7], false));
370 375
371 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); 376 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
372 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s()); 377 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s());
373 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 378 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
374 379
375 DebugScopedSetImplThread implThread; 380 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
376 textureManager->clearAllMemory(resourceProvider()); 381 textureManager->clearAllMemory(resourceProvider());
377 } 382 }
378 383
379 TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLa te) 384 TEST_F(CCPrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLa te)
380 { 385 {
381 const size_t maxTextures = 8; 386 const size_t maxTextures = 8;
382 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es); 387 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es);
383 388
384 // Half of the memory is taken by surfaces (with high priority place-holder) 389 // Half of the memory is taken by surfaces (with high priority place-holder)
385 OwnPtr<CCPrioritizedTexture> renderSurfacePlaceHolder = textureManager->crea teTexture(m_textureSize, m_textureFormat); 390 OwnPtr<CCPrioritizedTexture> renderSurfacePlaceHolder = textureManager->crea teTexture(m_textureSize, m_textureFormat);
(...skipping 16 matching lines...) Expand all
402 EXPECT_FALSE(validateTexture(textures[i], false)); 407 EXPECT_FALSE(validateTexture(textures[i], false));
403 for (unsigned i = 0; i < maxTextures; i += 2) 408 for (unsigned i = 0; i < maxTextures; i += 2)
404 EXPECT_TRUE(validateTexture(textures[i], true)); 409 EXPECT_TRUE(validateTexture(textures[i], true));
405 for (unsigned i = 1; i < maxTextures; i += 2) 410 for (unsigned i = 1; i < maxTextures; i += 2)
406 EXPECT_FALSE(validateTexture(textures[i], true)); 411 EXPECT_FALSE(validateTexture(textures[i], true));
407 412
408 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); 413 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
409 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s()); 414 EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTexture s());
410 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 415 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
411 416
412 DebugScopedSetImplThread implThread; 417 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
413 textureManager->clearAllMemory(resourceProvider()); 418 textureManager->clearAllMemory(resourceProvider());
414 } 419 }
415 420
416 TEST_F(CCPrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAva ilable) 421 TEST_F(CCPrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAva ilable)
417 { 422 {
418 const size_t maxTextures = 8; 423 const size_t maxTextures = 8;
419 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es); 424 OwnPtr<CCPrioritizedTextureManager> textureManager = createManager(maxTextur es);
420 425
421 // Half of the memory is taken by surfaces (with high priority place-holder) 426 // Half of the memory is taken by surfaces (with high priority place-holder)
422 OwnPtr<CCPrioritizedTexture> renderSurfacePlaceHolder = textureManager->crea teTexture(m_textureSize, m_textureFormat); 427 OwnPtr<CCPrioritizedTexture> renderSurfacePlaceHolder = textureManager->crea teTexture(m_textureSize, m_textureFormat);
(...skipping 19 matching lines...) Expand all
442 EXPECT_FALSE(validateTexture(textures[7], true)); 447 EXPECT_FALSE(validateTexture(textures[7], true));
443 448
444 // Root surface textures are valid. 449 // Root surface textures are valid.
445 for (size_t i = 0; i < 6; ++i) 450 for (size_t i = 0; i < 6; ++i)
446 EXPECT_TRUE(validateTexture(textures[i], false)); 451 EXPECT_TRUE(validateTexture(textures[i], false));
447 452
448 EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes()); 453 EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
449 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTexture s()); 454 EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTexture s());
450 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes()); 455 EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutof fBytes());
451 456
452 DebugScopedSetImplThread implThread; 457 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
453 textureManager->clearAllMemory(resourceProvider()); 458 textureManager->clearAllMemory(resourceProvider());
454 } 459 }
455 460
456 } // namespace 461 } // namespace
OLDNEW
« no previous file with comments | « cc/CCPrioritizedTextureManager.cpp ('k') | cc/CCSingleThreadProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698