Index: cc/prioritized_resource_unittest.cc |
diff --git a/cc/prioritized_texture_unittest.cc b/cc/prioritized_resource_unittest.cc |
similarity index 58% |
rename from cc/prioritized_texture_unittest.cc |
rename to cc/prioritized_resource_unittest.cc |
index 181fb86414e402e235b724186b6f0414e55cc928..328d92c083022bd991a3aabbb6c44534586cf1b8 100644 |
--- a/cc/prioritized_texture_unittest.cc |
+++ b/cc/prioritized_resource_unittest.cc |
@@ -4,9 +4,9 @@ |
#include "config.h" |
-#include "cc/prioritized_texture.h" |
+#include "cc/prioritized_resource.h" |
-#include "cc/prioritized_texture_manager.h" |
+#include "cc/prioritized_resource_manager.h" |
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread |
#include "cc/test/fake_graphics_context.h" |
#include "cc/test/tiled_layer_test_common.h" |
@@ -18,9 +18,9 @@ using namespace WebKitTests; |
namespace cc { |
-class PrioritizedTextureTest : public testing::Test { |
+class PrioritizedResourceTest : public testing::Test { |
public: |
- PrioritizedTextureTest() |
+ PrioritizedResourceTest() |
: m_textureSize(256, 256) |
, m_textureFormat(GL_RGBA) |
, m_context(WebKit::createFakeGraphicsContext()) |
@@ -29,7 +29,7 @@ public: |
m_resourceProvider = ResourceProvider::create(m_context.get()); |
} |
- virtual ~PrioritizedTextureTest() |
+ virtual ~PrioritizedResourceTest() |
{ |
DebugScopedSetImplThread implThread; |
m_resourceProvider.reset(); |
@@ -40,17 +40,17 @@ public: |
return Texture::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount; |
} |
- scoped_ptr<PrioritizedTextureManager> createManager(size_t maxTextures) |
+ scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures) |
{ |
- return PrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0); |
+ return PrioritizedResourceManager::create(texturesMemorySize(maxTextures), 1024, 0); |
} |
- bool validateTexture(scoped_ptr<PrioritizedTexture>& texture, bool requestLate) |
+ bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestLate) |
{ |
- textureManagerAssertInvariants(texture->textureManager()); |
+ resourceManagerAssertInvariants(texture->resourceManager()); |
if (requestLate) |
texture->requestLate(); |
- textureManagerAssertInvariants(texture->textureManager()); |
+ resourceManagerAssertInvariants(texture->resourceManager()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
bool success = texture->canAcquireBackingTexture(); |
if (success) |
@@ -58,16 +58,16 @@ public: |
return success; |
} |
- void prioritizeTexturesAndBackings(PrioritizedTextureManager* textureManager) |
+ void prioritizeTexturesAndBackings(PrioritizedResourceManager* resourceManager) |
{ |
- textureManager->prioritizeTextures(); |
- textureManagerUpdateBackingsPriorities(textureManager); |
+ resourceManager->prioritizeTextures(); |
+ resourceManagerUpdateBackingsPriorities(resourceManager); |
} |
- void textureManagerUpdateBackingsPriorities(PrioritizedTextureManager* textureManager) |
+ void resourceManagerUpdateBackingsPriorities(PrioritizedResourceManager* resourceManager) |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->pushTexturePrioritiesToBackings(); |
+ resourceManager->pushTexturePrioritiesToBackings(); |
} |
ResourceProvider* resourceProvider() |
@@ -75,15 +75,15 @@ public: |
return m_resourceProvider.get(); |
} |
- void textureManagerAssertInvariants(PrioritizedTextureManager* textureManager) |
+ void resourceManagerAssertInvariants(PrioritizedResourceManager* resourceManager) |
{ |
#ifndef NDEBUG |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->assertInvariants(); |
+ resourceManager->assertInvariants(); |
#endif |
} |
- bool textureBackingIsAbovePriorityCutoff(PrioritizedTexture* texture) |
+ bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) |
{ |
return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate(); |
} |
@@ -99,23 +99,23 @@ protected: |
namespace { |
-TEST_F(PrioritizedTextureTest, requestTextureExceedingMaxLimit) |
+TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
// Create textures for double our memory limit. |
- scoped_ptr<PrioritizedTexture> textures[maxTextures*2]; |
+ scoped_ptr<PrioritizedResource> textures[maxTextures*2]; |
for (size_t i = 0; i < maxTextures*2; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Set decreasing priorities |
for (size_t i = 0; i < maxTextures*2; ++i) |
textures[i]->setRequestPriority(100 + i); |
// Only lower half should be available. |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
EXPECT_TRUE(validateTexture(textures[0], false)); |
EXPECT_TRUE(validateTexture(textures[7], false)); |
EXPECT_FALSE(validateTexture(textures[8], false)); |
@@ -126,154 +126,154 @@ TEST_F(PrioritizedTextureTest, requestTextureExceedingMaxLimit) |
textures[i]->setRequestPriority(100 - i); |
// Only upper half should be available. |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
EXPECT_FALSE(validateTexture(textures[0], false)); |
EXPECT_FALSE(validateTexture(textures[7], false)); |
EXPECT_TRUE(validateTexture(textures[8], false)); |
EXPECT_TRUE(validateTexture(textures[15], false)); |
- EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(maxTextures), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, changeMemoryLimits) |
+TEST_F(PrioritizedResourceTest, changeMemoryLimits) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
for (size_t i = 0; i < maxTextures; ++i) |
textures[i]->setRequestPriority(100 + i); |
// Set max limit to 8 textures |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (size_t i = 0; i < maxTextures; ++i) |
validateTexture(textures[i], false); |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemory(resourceProvider()); |
+ resourceManager->reduceMemory(resourceProvider()); |
} |
- EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
// Set max limit to 5 textures |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(5)); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (size_t i = 0; i < maxTextures; ++i) |
EXPECT_EQ(validateTexture(textures[i], false), i < 5); |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemory(resourceProvider()); |
+ resourceManager->reduceMemory(resourceProvider()); |
} |
- EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(5), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
// Set max limit to 4 textures |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(4)); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (size_t i = 0; i < maxTextures; ++i) |
EXPECT_EQ(validateTexture(textures[i], false), i < 4); |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemory(resourceProvider()); |
+ resourceManager->reduceMemory(resourceProvider()); |
} |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, changePriorityCutoff) |
+TEST_F(PrioritizedResourceTest, changePriorityCutoff) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
for (size_t i = 0; i < maxTextures; ++i) |
textures[i]->setRequestPriority(100 + i); |
// Set the cutoff to drop two textures. Try to requestLate on all textures, and |
// make sure that requestLate doesn't work on a texture with equal priority to |
// the cutoff. |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); |
- textureManager->setExternalPriorityCutoff(106); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); |
+ resourceManager->setExternalPriorityCutoff(106); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (size_t i = 0; i < maxTextures; ++i) |
EXPECT_EQ(validateTexture(textures[i], true), i < 6); |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemory(resourceProvider()); |
+ resourceManager->reduceMemory(resourceProvider()); |
} |
- EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
// Set the cutoff to drop two more textures. |
- textureManager->setExternalPriorityCutoff(104); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setExternalPriorityCutoff(104); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (size_t i = 0; i < maxTextures; ++i) |
EXPECT_EQ(validateTexture(textures[i], false), i < 4); |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemory(resourceProvider()); |
+ resourceManager->reduceMemory(resourceProvider()); |
} |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); |
// Do a one-time eviction for one more texture based on priority cutoff |
- PrioritizedTextureManager::BackingList evictedBackings; |
+ PrioritizedResourceManager::BackingList evictedBackings; |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider()); |
- textureManager->getEvictedBackings(evictedBackings); |
+ resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider()); |
+ resourceManager->getEvictedBackings(evictedBackings); |
EXPECT_EQ(0, evictedBackings.size()); |
- textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, resourceProvider()); |
- textureManager->getEvictedBackings(evictedBackings); |
+ resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, resourceProvider()); |
+ resourceManager->getEvictedBackings(evictedBackings); |
EXPECT_EQ(1, evictedBackings.size()); |
} |
- textureManager->unlinkEvictedBackings(evictedBackings); |
- EXPECT_EQ(texturesMemorySize(3), textureManager->memoryUseBytes()); |
+ resourceManager->unlinkEvictedBackings(evictedBackings); |
+ EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryUseBytes()); |
// Re-allocate the the texture after the one-time drop. |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (size_t i = 0; i < maxTextures; ++i) |
EXPECT_EQ(validateTexture(textures[i], false), i < 4); |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->reduceMemory(resourceProvider()); |
+ resourceManager->reduceMemory(resourceProvider()); |
} |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures) |
+TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures) |
{ |
const size_t maxTextures = 4; |
const size_t numTextures = 4; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
- scoped_ptr<PrioritizedTexture> textures[numTextures]; |
- scoped_ptr<PrioritizedTexture> moreTextures[numTextures]; |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResource> textures[numTextures]; |
+ scoped_ptr<PrioritizedResource> moreTextures[numTextures]; |
for (size_t i = 0; i < numTextures; ++i) { |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
- moreTextures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
+ moreTextures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
} |
for (size_t i = 0; i < numTextures; ++i) |
textures[i]->setRequestPriority(200 + i); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
// Allocate textures which are currently high priority. |
EXPECT_TRUE(validateTexture(textures[0], false)); |
@@ -288,7 +288,7 @@ TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures) |
for (size_t i = 0; i < numTextures; ++i) |
moreTextures[i]->setRequestPriority(100 + i); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
// Textures are now below cutoff. |
EXPECT_FALSE(validateTexture(textures[0], false)); |
@@ -315,17 +315,17 @@ TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures) |
EXPECT_FALSE(textures[3]->haveBackingTexture()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual) |
+TEST_F(PrioritizedResourceTest, resourceManagerPrioritiesAreEqual) |
{ |
const size_t maxTextures = 16; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// All 16 textures have the same priority except 2 higher priority. |
for (size_t i = 0; i < maxTextures; ++i) |
@@ -334,16 +334,16 @@ TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual) |
textures[1]->setRequestPriority(99); |
// Set max limit to 8 textures |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8)); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
// The two high priority textures should be available, others should not. |
for (size_t i = 0; i < 2; ++i) |
EXPECT_TRUE(validateTexture(textures[i], false)); |
for (size_t i = 2; i < maxTextures; ++i) |
EXPECT_FALSE(validateTexture(textures[i], false)); |
- EXPECT_EQ(texturesMemorySize(2), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
// Manually reserving textures should only succeed on the higher priority textures, |
// and on remaining textures up to the memory limit. |
@@ -351,23 +351,23 @@ TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual) |
EXPECT_TRUE(validateTexture(textures[i], true)); |
for (size_t i = 9; i < maxTextures; i++) |
EXPECT_FALSE(validateTexture(textures[i], true)); |
- EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst) |
+TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst) |
{ |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(1); |
- scoped_ptr<PrioritizedTexture> texture = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(1); |
+ scoped_ptr<PrioritizedResource> texture = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Texture is initially invalid, but it will become available. |
EXPECT_FALSE(texture->haveBackingTexture()); |
texture->setRequestPriority(100); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
EXPECT_TRUE(validateTexture(texture, false)); |
EXPECT_TRUE(texture->canAcquireBackingTexture()); |
@@ -375,25 +375,25 @@ TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst) |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
- textureManager.reset(); |
+ resourceManager.reset(); |
EXPECT_FALSE(texture->canAcquireBackingTexture()); |
EXPECT_FALSE(texture->haveBackingTexture()); |
} |
-TEST_F(PrioritizedTextureTest, textureMovedToNewManager) |
+TEST_F(PrioritizedResourceTest, textureMovedToNewManager) |
{ |
- scoped_ptr<PrioritizedTextureManager> textureManagerOne = createManager(1); |
- scoped_ptr<PrioritizedTextureManager> textureManagerTwo = createManager(1); |
- scoped_ptr<PrioritizedTexture> texture = textureManagerOne->createTexture(m_textureSize, m_textureFormat); |
+ scoped_ptr<PrioritizedResourceManager> resourceManagerOne = createManager(1); |
+ scoped_ptr<PrioritizedResourceManager> resourceManagerTwo = createManager(1); |
+ scoped_ptr<PrioritizedResource> texture = resourceManagerOne->createTexture(m_textureSize, m_textureFormat); |
// Texture is initially invalid, but it will become available. |
EXPECT_FALSE(texture->haveBackingTexture()); |
texture->setRequestPriority(100); |
- prioritizeTexturesAndBackings(textureManagerOne.get()); |
+ prioritizeTexturesAndBackings(resourceManagerOne.get()); |
EXPECT_TRUE(validateTexture(texture, false)); |
EXPECT_TRUE(texture->canAcquireBackingTexture()); |
@@ -403,47 +403,47 @@ TEST_F(PrioritizedTextureTest, textureMovedToNewManager) |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManagerOne->clearAllMemory(resourceProvider()); |
+ resourceManagerOne->clearAllMemory(resourceProvider()); |
} |
- textureManagerOne.reset(); |
+ resourceManagerOne.reset(); |
EXPECT_FALSE(texture->canAcquireBackingTexture()); |
EXPECT_FALSE(texture->haveBackingTexture()); |
- texture->setTextureManager(textureManagerTwo.get()); |
+ texture->setTextureManager(resourceManagerTwo.get()); |
- prioritizeTexturesAndBackings(textureManagerTwo.get()); |
+ prioritizeTexturesAndBackings(resourceManagerTwo.get()); |
EXPECT_TRUE(validateTexture(texture, false)); |
EXPECT_TRUE(texture->canAcquireBackingTexture()); |
EXPECT_TRUE(texture->haveBackingTexture()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManagerTwo->clearAllMemory(resourceProvider()); |
+ resourceManagerTwo->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSurface) |
+TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSurface) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
// Half of the memory is taken by surfaces (with high priority place-holder) |
- scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat); |
renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); |
renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::renderSurfacePriority()); |
// Create textures to fill our memory limit. |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Set decreasing non-visible priorities outside root surface. |
for (size_t i = 0; i < maxTextures; ++i) |
textures[i]->setRequestPriority(100 + i); |
// Only lower half should be available. |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
EXPECT_TRUE(validateTexture(textures[0], false)); |
EXPECT_TRUE(validateTexture(textures[3], false)); |
EXPECT_FALSE(validateTexture(textures[4], false)); |
@@ -454,42 +454,42 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSur |
textures[i]->setRequestPriority(100 - i); |
// Only upper half should be available. |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
EXPECT_FALSE(validateTexture(textures[0], false)); |
EXPECT_FALSE(validateTexture(textures[3], false)); |
EXPECT_TRUE(validateTexture(textures[4], false)); |
EXPECT_TRUE(validateTexture(textures[7], false)); |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextures()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate) |
+TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLate) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
// Half of the memory is taken by surfaces (with high priority place-holder) |
- scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat); |
renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); |
renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::renderSurfacePriority()); |
// Create textures to fill our memory limit. |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Set equal priorities. |
for (size_t i = 0; i < maxTextures; ++i) |
textures[i]->setRequestPriority(100); |
// The first four to be requested late will be available. |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (unsigned i = 0; i < maxTextures; ++i) |
EXPECT_FALSE(validateTexture(textures[i], false)); |
for (unsigned i = 0; i < maxTextures; i += 2) |
@@ -497,29 +497,29 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate |
for (unsigned i = 1; i < maxTextures; i += 2) |
EXPECT_FALSE(validateTexture(textures[i], true)); |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextures()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvailable) |
+TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvailable) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
// Half of the memory is taken by surfaces (with high priority place-holder) |
- scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat); |
renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4)); |
renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::renderSurfacePriority()); |
// Create textures to fill our memory limit. |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Set 6 visible textures in the root surface, and 2 in a child surface. |
for (size_t i = 0; i < 6; ++i) |
@@ -527,7 +527,7 @@ TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail |
for (size_t i = 6; i < 8; ++i) |
textures[i]->setRequestPriority(PriorityCalculator::visiblePriority(false)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
// Unable to requestLate textures in the child surface. |
EXPECT_FALSE(validateTexture(textures[6], true)); |
@@ -537,47 +537,47 @@ TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail |
for (size_t i = 0; i < 6; ++i) |
EXPECT_TRUE(validateTexture(textures[i], false)); |
- EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes()); |
- EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTextures()); |
- EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes()); |
+ EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryForSelfManagedTextures()); |
+ EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes()); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, requestLateBackingsSorting) |
+TEST_F(PrioritizedResourceTest, requestLateBackingsSorting) |
{ |
const size_t maxTextures = 8; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); |
// Create textures to fill our memory limit. |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Set equal priorities, and allocate backings for all textures. |
for (size_t i = 0; i < maxTextures; ++i) |
textures[i]->setRequestPriority(100); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (unsigned i = 0; i < maxTextures; ++i) |
EXPECT_TRUE(validateTexture(textures[i], false)); |
// Drop the memory limit and prioritize (none will be above the threshold, |
// but they still have backings because reduceMemory hasn't been called). |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures / 2)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures / 2)); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
// Push half of them back over the limit. |
for (size_t i = 0; i < maxTextures; i += 2) |
EXPECT_TRUE(textures[i]->requestLate()); |
// Push the priorities to the backings array and sort the backings array |
- textureManagerUpdateBackingsPriorities(textureManager.get()); |
+ resourceManagerUpdateBackingsPriorities(resourceManager.get()); |
// Assert that the backings list be sorted with the below-limit backings |
// before the above-limit backings. |
- textureManagerAssertInvariants(textureManager.get()); |
+ resourceManagerAssertInvariants(resourceManager.get()); |
// Make sure that we have backings for all of the textures. |
for (size_t i = 0; i < maxTextures; ++i) |
@@ -590,26 +590,26 @@ TEST_F(PrioritizedTextureTest, requestLateBackingsSorting) |
EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get())); |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |
-TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources) |
+TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources) |
{ |
const size_t maxTextures = 4; |
- scoped_ptr<PrioritizedTextureManager> textureManager = |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = |
createManager(maxTextures); |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures)); |
// Create textures to fill our memory limit. |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
// Set equal priorities, and allocate backings for all textures. |
for (size_t i = 0; i < maxTextures; ++i) |
textures[i]->setRequestPriority(100); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
for (unsigned i = 0; i < maxTextures; ++i) |
EXPECT_TRUE(validateTexture(textures[i], false)); |
@@ -628,25 +628,25 @@ TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources) |
queue.clearUploadsToEvictedResources(); |
EXPECT_EQ(4, queue.fullUploadSize()); |
- textureManager->reduceMemoryOnImplThread( |
+ resourceManager->reduceMemoryOnImplThread( |
texturesMemorySize(1), PriorityCalculator::allowEverythingCutoff(), resourceProvider()); |
queue.clearUploadsToEvictedResources(); |
EXPECT_EQ(1, queue.fullUploadSize()); |
- textureManager->reduceMemoryOnImplThread(0, PriorityCalculator::allowEverythingCutoff(), resourceProvider()); |
+ resourceManager->reduceMemoryOnImplThread(0, PriorityCalculator::allowEverythingCutoff(), resourceProvider()); |
queue.clearUploadsToEvictedResources(); |
EXPECT_EQ(0, queue.fullUploadSize()); |
} |
-TEST_F(PrioritizedTextureTest, usageStatistics) |
+TEST_F(PrioritizedResourceTest, usageStatistics) |
{ |
const size_t maxTextures = 5; |
- scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures); |
- scoped_ptr<PrioritizedTexture> textures[maxTextures]; |
+ scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures); |
+ scoped_ptr<PrioritizedResource> textures[maxTextures]; |
for (size_t i = 0; i < maxTextures; ++i) |
- textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat); |
+ textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat); |
textures[0]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1); |
textures[1]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff()); |
@@ -655,8 +655,8 @@ TEST_F(PrioritizedTextureTest, usageStatistics) |
textures[4]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCutoff() + 1); |
// Set max limit to 2 textures. |
- textureManager->setMaxMemoryLimitBytes(texturesMemorySize(2)); |
- prioritizeTexturesAndBackings(textureManager.get()); |
+ resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(2)); |
+ prioritizeTexturesAndBackings(resourceManager.get()); |
// The first two textures should be available, others should not. |
for (size_t i = 0; i < 2; ++i) |
@@ -667,9 +667,9 @@ TEST_F(PrioritizedTextureTest, usageStatistics) |
// Validate the statistics. |
{ |
DebugScopedSetImplThread implThread; |
- EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes()); |
- EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes()); |
- EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyBytes()); |
+ EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); |
+ EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes()); |
+ EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearbyBytes()); |
} |
// Re-prioritize the textures, but do not push the values to backings. |
@@ -678,27 +678,27 @@ TEST_F(PrioritizedTextureTest, usageStatistics) |
textures[2]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1); |
textures[3]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCutoff() - 1); |
textures[4]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCutoff()); |
- textureManager->prioritizeTextures(); |
+ resourceManager->prioritizeTextures(); |
// Verify that we still see the old values. |
{ |
DebugScopedSetImplThread implThread; |
- EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes()); |
- EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes()); |
- EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyBytes()); |
+ EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); |
+ EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes()); |
+ EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearbyBytes()); |
} |
// Push priorities to backings, and verify we see the new values. |
{ |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->pushTexturePrioritiesToBackings(); |
- EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes()); |
- EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes()); |
- EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyBytes()); |
+ resourceManager->pushTexturePrioritiesToBackings(); |
+ EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes()); |
+ EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes()); |
+ EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearbyBytes()); |
} |
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked; |
- textureManager->clearAllMemory(resourceProvider()); |
+ resourceManager->clearAllMemory(resourceProvider()); |
} |