| OLD | NEW |
| 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 |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 // Make sure that only the requestLate textures are above the priority cutof
f | 525 // Make sure that only the requestLate textures are above the priority cutof
f |
| 526 for (size_t i = 0; i < maxTextures; i += 2) | 526 for (size_t i = 0; i < maxTextures; i += 2) |
| 527 EXPECT_TRUE(textureBackingIsAbovePriorityCutoff(textures[i].get())); | 527 EXPECT_TRUE(textureBackingIsAbovePriorityCutoff(textures[i].get())); |
| 528 for (size_t i = 1; i < maxTextures; i += 2) | 528 for (size_t i = 1; i < maxTextures; i += 2) |
| 529 EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get())); | 529 EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get())); |
| 530 | 530 |
| 531 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; | 531 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
| 532 textureManager->clearAllMemory(resourceProvider()); | 532 textureManager->clearAllMemory(resourceProvider()); |
| 533 } | 533 } |
| 534 | 534 |
| 535 TEST_F(CCPrioritizedTextureTest, clearUploadsToEvictedResources) |
| 536 { |
| 537 const size_t maxTextures = 4; |
| 538 scoped_ptr<CCPrioritizedTextureManager> textureManager = |
| 539 createManager(maxTextures); |
| 540 textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); |
| 541 |
| 542 // Create textures to fill our memory limit. |
| 543 scoped_ptr<CCPrioritizedTexture> textures[maxTextures]; |
| 544 |
| 545 for (size_t i = 0; i < maxTextures; ++i) |
| 546 textures[i] = textureManager->createTexture(m_textureSize, m_textureForm
at); |
| 547 |
| 548 // Set equal priorities, and allocate backings for all textures. |
| 549 for (size_t i = 0; i < maxTextures; ++i) |
| 550 textures[i]->setRequestPriority(100); |
| 551 prioritizeTexturesAndBackings(textureManager.get()); |
| 552 for (unsigned i = 0; i < maxTextures; ++i) |
| 553 EXPECT_TRUE(validateTexture(textures[i], false)); |
| 554 |
| 555 CCTextureUpdateQueue queue; |
| 556 DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
| 557 for (size_t i = 0; i < maxTextures; ++i) { |
| 558 const TextureUploader::Parameters upload = { textures[i].get() }; |
| 559 queue.appendFullUpload(upload); |
| 560 } |
| 561 |
| 562 // Make sure that we have backings for all of the textures. |
| 563 for (size_t i = 0; i < maxTextures; ++i) |
| 564 EXPECT_TRUE(textures[i]->haveBackingTexture()); |
| 565 |
| 566 queue.clearUploadsToEvictedResources(); |
| 567 EXPECT_EQ(4, queue.fullUploadSize()); |
| 568 |
| 569 textureManager->reduceMemoryOnImplThread( |
| 570 texturesMemorySize(1), resourceProvider()); |
| 571 queue.clearUploadsToEvictedResources(); |
| 572 EXPECT_EQ(1, queue.fullUploadSize()); |
| 573 |
| 574 textureManager->reduceMemoryOnImplThread(0, resourceProvider()); |
| 575 queue.clearUploadsToEvictedResources(); |
| 576 EXPECT_EQ(0, queue.fullUploadSize()); |
| 577 |
| 578 } |
| 535 | 579 |
| 536 } // namespace | 580 } // namespace |
| OLD | NEW |