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

Unified Diff: cc/tiled_layer_unittest.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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
« no previous file with comments | « cc/tiled_layer_impl_unittest.cc ('k') | cc/tree_synchronizer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiled_layer_unittest.cc
diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc
index 44f1bd94b4d4afb104ad65e88a10460c6983b543..d23df5f5c83286a7b41ef7af4c69656dbb4bedae 100644
--- a/cc/tiled_layer_unittest.cc
+++ b/cc/tiled_layer_unittest.cc
@@ -12,6 +12,7 @@
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
#include "cc/test/animation_test_common.h"
#include "cc/test/fake_layer_tree_host_client.h"
+#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_proxy.h"
#include "cc/test/geometry_test_utils.h"
@@ -62,6 +63,7 @@ public:
m_layerTreeHost->initializeRendererIfNeeded();
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
+ m_hostImpl = make_scoped_ptr(new FakeLayerTreeHostImpl(m_proxy));
}
virtual ~TiledLayerTest()
@@ -69,13 +71,14 @@ public:
resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.get());
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
m_resourceProvider.reset();
+ m_hostImpl.reset();
}
class ScopedFakeTiledLayerImpl {
public:
- ScopedFakeTiledLayerImpl(int id)
+ ScopedFakeTiledLayerImpl(LayerTreeHostImpl* hostImpl, int id)
{
- m_layerImpl = new FakeTiledLayerImpl(id);
+ m_layerImpl = new FakeTiledLayerImpl(hostImpl, id);
}
~ScopedFakeTiledLayerImpl()
{
@@ -171,6 +174,7 @@ public:
PriorityCalculator m_priorityCalculator;
FakeLayerImplTreeHostClient m_fakeLayerImplTreeHostClient;
scoped_ptr<LayerTreeHost> m_layerTreeHost;
+ scoped_ptr<FakeLayerTreeHostImpl> m_hostImpl;
scoped_ptr<PrioritizedResourceManager> m_resourceManager;
TestOcclusionTracker* m_occlusion;
};
@@ -178,7 +182,7 @@ public:
TEST_F(TiledLayerTest, pushDirtyTiles)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(gfx::Size(100, 200));
@@ -204,7 +208,7 @@ TEST_F(TiledLayerTest, pushDirtyTiles)
TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
TestOcclusionTracker occluded;
m_occlusion = &occluded;
@@ -241,7 +245,7 @@ TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
TEST_F(TiledLayerTest, pushDeletedTiles)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(gfx::Size(100, 200));
@@ -276,7 +280,7 @@ TEST_F(TiledLayerTest, pushDeletedTiles)
TEST_F(TiledLayerTest, pushIdlePaintTiles)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center.
// This paints 1 visible of the 25 invalid tiles.
@@ -312,7 +316,7 @@ TEST_F(TiledLayerTest, pushIdlePaintTiles)
TEST_F(TiledLayerTest, predictivePainting)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// Prepainting should occur in the scroll direction first, and the
// visible rect should be extruded only along the dominant axis.
@@ -386,9 +390,9 @@ TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
// Start with 2mb of memory, but the test is going to try to use just more than 1mb, so we reduce to 1mb later.
m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024);
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl1(1);
+ ScopedFakeTiledLayerImpl layerImpl1(m_hostImpl.get(), 1);
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl2(2);
+ ScopedFakeTiledLayerImpl layerImpl2(m_hostImpl.get(), 2);
// For this test we have two layers. layer1 exhausts most texture memory, leaving room for 2 more tiles from
// layer2, but not all three tiles. First we paint layer1, and one tile from layer2. Then when we idle paint
@@ -438,7 +442,7 @@ TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
TestOcclusionTracker occluded;
m_occlusion = &occluded;
@@ -457,7 +461,7 @@ TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// The tile size is 100x100, so this invalidates and then paints two tiles.
// However, during the paint, we invalidate one of the tiles. This should
@@ -476,8 +480,8 @@ TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
{
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layer1Impl(1);
- ScopedFakeTiledLayerImpl layer2Impl(2);
+ ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl.get(), 1);
+ ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl.get(), 2);
// Invalidate a tile on layer1, during update of layer 2.
layer2->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), layer1.get());
@@ -499,8 +503,8 @@ TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer)
{
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layer1Impl(1);
- ScopedFakeTiledLayerImpl layer2Impl(2);
+ ScopedFakeTiledLayerImpl layer1Impl(m_hostImpl.get(), 1);
+ ScopedFakeTiledLayerImpl layer2Impl(m_hostImpl.get(), 2);
layer1->fakeLayerUpdater()->setRectToInvalidate(gfx::Rect(0, 50, 100, 50), layer2.get());
layer1->setBounds(gfx::Size(100, 200));
@@ -541,7 +545,7 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer);
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// Full size layer with half being visible.
gfx::Size contentBounds(layerWidth, layerHeight);
@@ -583,7 +587,7 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
TEST_F(TiledLayerTest, idlePaintOutOfMemory)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// We have enough memory for only the visible rect, so we will run out of memory in first idle paint.
int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
@@ -606,7 +610,7 @@ TEST_F(TiledLayerTest, idlePaintOutOfMemory)
TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
bool animating[2] = {false, true};
for (int i = 0; i < 2; i++) {
@@ -633,7 +637,7 @@ TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// Alternate between not visible and visible.
gfx::Rect v(0, 0, 100, 100);
@@ -663,7 +667,7 @@ TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
TEST_F(TiledLayerTest, invalidateFromPrepare)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// The tile size is 100x100, so this invalidates and then paints two tiles.
layer->setBounds(gfx::Size(100, 200));
@@ -736,7 +740,7 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled)
TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
{
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
// Create a layer with one tile.
layer->setBounds(gfx::Size(100, 100));
@@ -888,7 +892,7 @@ TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
m_layerTreeHost->updateLayers(
*m_queue.get(), std::numeric_limits<size_t>::max());
{
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
EXPECT_EQ(6, m_queue->fullUploadSize());
EXPECT_EQ(0, m_queue->partialUploadSize());
updateTextures();
@@ -903,7 +907,7 @@ TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
layer->invalidateContentRect(gfx::Rect(0, 0, 300, 150));
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
{
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
EXPECT_EQ(3, m_queue->fullUploadSize());
EXPECT_EQ(3, m_queue->partialUploadSize());
updateTextures();
@@ -917,7 +921,7 @@ TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
// Partial update of 6 tiles.
layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
{
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
EXPECT_EQ(2, m_queue->fullUploadSize());
EXPECT_EQ(4, m_queue->partialUploadSize());
@@ -932,7 +936,7 @@ TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
// Checkerboard all tiles.
layer->invalidateContentRect(gfx::Rect(0, 0, 300, 200));
{
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
layerPushPropertiesTo(layer.get(), layerImpl.get());
}
m_layerTreeHost->commitComplete();
@@ -940,7 +944,7 @@ TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
// Partial update of 6 checkerboard tiles.
layer->invalidateContentRect(gfx::Rect(50, 50, 200, 100));
{
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
EXPECT_EQ(6, m_queue->fullUploadSize());
EXPECT_EQ(0, m_queue->partialUploadSize());
@@ -955,7 +959,7 @@ TEST_F(TiledLayerPartialUpdateTest, partialUpdates)
// Partial update of 4 tiles.
layer->invalidateContentRect(gfx::Rect(50, 50, 100, 100));
{
- ScopedFakeTiledLayerImpl layerImpl(1);
+ ScopedFakeTiledLayerImpl layerImpl(m_hostImpl.get(), 1);
m_layerTreeHost->updateLayers(*m_queue.get(), std::numeric_limits<size_t>::max());
EXPECT_EQ(0, m_queue->fullUploadSize());
EXPECT_EQ(4, m_queue->partialUploadSize());
@@ -1435,9 +1439,9 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
child->fakeLayerUpdater()->clearUpdateCount();
child2->fakeLayerUpdater()->clearUpdateCount();
- ScopedFakeTiledLayerImpl rootImpl(root->id());
- ScopedFakeTiledLayerImpl childImpl(child->id());
- ScopedFakeTiledLayerImpl child2Impl(child2->id());
+ ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id());
+ ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id());
+ ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id());
layerPushPropertiesTo(root.get(), rootImpl.get());
layerPushPropertiesTo(child.get(), childImpl.get());
layerPushPropertiesTo(child2.get(), child2Impl.get());
@@ -1470,9 +1474,9 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
child->fakeLayerUpdater()->clearUpdateCount();
child2->fakeLayerUpdater()->clearUpdateCount();
- ScopedFakeTiledLayerImpl rootImpl(root->id());
- ScopedFakeTiledLayerImpl childImpl(child->id());
- ScopedFakeTiledLayerImpl child2Impl(child2->id());
+ ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id());
+ ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id());
+ ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id());
layerPushPropertiesTo(root.get(), rootImpl.get());
layerPushPropertiesTo(child.get(), childImpl.get());
layerPushPropertiesTo(child2.get(), child2Impl.get());
@@ -1506,9 +1510,9 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
child->fakeLayerUpdater()->clearUpdateCount();
child2->fakeLayerUpdater()->clearUpdateCount();
- ScopedFakeTiledLayerImpl rootImpl(root->id());
- ScopedFakeTiledLayerImpl childImpl(child->id());
- ScopedFakeTiledLayerImpl child2Impl(child2->id());
+ ScopedFakeTiledLayerImpl rootImpl(m_hostImpl.get(), root->id());
+ ScopedFakeTiledLayerImpl childImpl(m_hostImpl.get(), child->id());
+ ScopedFakeTiledLayerImpl child2Impl(m_hostImpl.get(), child2->id());
layerPushPropertiesTo(root.get(), rootImpl.get());
layerPushPropertiesTo(child.get(), childImpl.get());
layerPushPropertiesTo(child2.get(), child2Impl.get());
« no previous file with comments | « cc/tiled_layer_impl_unittest.cc ('k') | cc/tree_synchronizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698