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

Unified 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: Address code review comments and fix all cc_unittests Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: cc/prioritized_texture_unittest.cc
diff --git a/cc/prioritized_texture_unittest.cc b/cc/prioritized_texture_unittest.cc
index c223870061e1f51fd6896b8df523c43884391ac8..87f29ef813ba6909bed9414c7f749c46766b9898 100644
--- a/cc/prioritized_texture_unittest.cc
+++ b/cc/prioritized_texture_unittest.cc
@@ -9,6 +9,7 @@
#include "cc/prioritized_texture_manager.h"
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
#include "cc/test/fake_graphics_context.h"
+#include "cc/test/fake_proxy.h"
#include "cc/test/tiled_layer_test_common.h"
#include "cc/test/web_compositor_initializer.h"
#include "cc/texture.h"
@@ -22,18 +23,19 @@ namespace cc {
class PrioritizedTextureTest : public testing::Test {
public:
PrioritizedTextureTest()
- : m_textureSize(256, 256)
+ : m_proxy(0)
+ , m_textureSize(256, 256)
, m_textureFormat(GL_RGBA)
, m_compositorInitializer(0)
, m_context(WebKit::createFakeGraphicsContext())
{
- DebugScopedSetImplThread implThread;
+ DebugScopedSetImplThread implThread(&m_proxy);
m_resourceProvider = ResourceProvider::create(m_context.get());
}
virtual ~PrioritizedTextureTest()
{
- DebugScopedSetImplThread implThread;
+ DebugScopedSetImplThread implThread(&m_proxy);
m_resourceProvider.reset();
}
@@ -44,7 +46,7 @@ public:
scoped_ptr<PrioritizedTextureManager> createManager(size_t maxTextures)
{
- return PrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0);
+ return PrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0, &m_proxy);
}
bool validateTexture(scoped_ptr<PrioritizedTexture>& texture, bool requestLate)
@@ -53,7 +55,7 @@ public:
if (requestLate)
texture->requestLate();
textureManagerAssertInvariants(texture->textureManager());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
bool success = texture->canAcquireBackingTexture();
if (success)
texture->acquireBackingTexture(resourceProvider());
@@ -68,7 +70,7 @@ public:
void textureManagerUpdateBackingsPriorities(PrioritizedTextureManager* textureManager)
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->pushTexturePrioritiesToBackings();
}
@@ -80,7 +82,7 @@ public:
void textureManagerAssertInvariants(PrioritizedTextureManager* textureManager)
{
#ifndef NDEBUG
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->assertInvariants();
#endif
}
@@ -91,6 +93,7 @@ public:
}
protected:
+ FakeProxy m_proxy;
const IntSize m_textureSize;
const GLenum m_textureFormat;
WebCompositorInitializer m_compositorInitializer;
@@ -138,7 +141,7 @@ TEST_F(PrioritizedTextureTest, requestTextureExceedingMaxLimit)
EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoffBytes());
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -159,7 +162,7 @@ TEST_F(PrioritizedTextureTest, changeMemoryLimits)
for (size_t i = 0; i < maxTextures; ++i)
validateTexture(textures[i], false);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemory(resourceProvider());
}
@@ -172,7 +175,7 @@ TEST_F(PrioritizedTextureTest, changeMemoryLimits)
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], false), i < 5);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemory(resourceProvider());
}
@@ -185,14 +188,14 @@ TEST_F(PrioritizedTextureTest, changeMemoryLimits)
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemory(resourceProvider());
}
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -216,7 +219,7 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], true), i < 6);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemory(resourceProvider());
}
EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
@@ -228,7 +231,7 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemory(resourceProvider());
}
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
@@ -236,7 +239,7 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
// Do a one-time eviction for one more texture based on priority cutoff
PrioritizedTextureManager::BackingList evictedBackings;
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider());
textureManager->getEvictedBackings(evictedBackings);
EXPECT_EQ(0, evictedBackings.size());
@@ -252,12 +255,12 @@ TEST_F(PrioritizedTextureTest, changePriorityCutoff)
for (size_t i = 0; i < maxTextures; ++i)
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->reduceMemory(resourceProvider());
}
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -317,7 +320,7 @@ TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures)
EXPECT_FALSE(textures[2]->haveBackingTexture());
EXPECT_FALSE(textures[3]->haveBackingTexture());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -357,7 +360,7 @@ TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual)
EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -377,7 +380,7 @@ TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst)
EXPECT_TRUE(texture->haveBackingTexture());
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
textureManager.reset();
@@ -405,7 +408,7 @@ TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
texture->setTextureManager(0);
{
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManagerOne->clearAllMemory(resourceProvider());
}
textureManagerOne.reset();
@@ -421,7 +424,7 @@ TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
EXPECT_TRUE(texture->canAcquireBackingTexture());
EXPECT_TRUE(texture->haveBackingTexture());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManagerTwo->clearAllMemory(resourceProvider());
}
@@ -467,7 +470,7 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSur
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures());
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -504,7 +507,7 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures());
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -544,7 +547,7 @@ TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTextures());
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -592,7 +595,7 @@ TEST_F(PrioritizedTextureTest, requestLateBackingsSorting)
for (size_t i = 1; i < maxTextures; i += 2)
EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
textureManager->clearAllMemory(resourceProvider());
}
@@ -617,7 +620,7 @@ TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources)
EXPECT_TRUE(validateTexture(textures[i], false));
TextureUpdateQueue queue;
- DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
+ DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(&m_proxy);
for (size_t i = 0; i < maxTextures; ++i) {
const ResourceUpdate upload = ResourceUpdate::Create(
textures[i].get(), NULL, IntRect(), IntRect(), IntSize());

Powered by Google App Engine
This is Rietveld 408576698