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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 12662021: cc: Don't draw and swap if the frame will not change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add perf test Created 7 years, 9 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/trees/layer_tree_host_unittest.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 5c9c2dac823a360b28e841f372a8465e3c394f74..3a5018e332c3d5bf0853ad02fc61a3e6db203c90 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -142,21 +142,23 @@ public:
virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
- if (impl->active_tree()->source_frame_number() == 0)
- PostSetNeedsCommitToMainThread();
- else if (impl->active_tree()->source_frame_number() == 1)
- EndTest();
+ ++m_numDraws;
}
- virtual void CommitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
{
m_numCommits++;
+
+ if (impl->active_tree()->source_frame_number() == 0)
+ PostSetNeedsCommitToMainThread();
+ else if (impl->active_tree()->source_frame_number() == 1)
+ EndTest();
}
virtual void AfterTest() OVERRIDE
{
EXPECT_EQ(2, m_numCommits);
- EXPECT_GE(2, m_numDraws);
+ EXPECT_EQ(1, m_numDraws);
}
private:
@@ -840,7 +842,7 @@ public:
// Compute all the layer transforms for the frame.
LayerTreeHostImpl::FrameData frameData;
- impl->PrepareToDraw(&frameData);
+ impl->PrepareToDraw(&frameData, gfx::Rect());
impl->DidDrawAllLayers(frameData);
const LayerTreeHostImpl::LayerList& renderSurfaceLayerList =
@@ -1288,11 +1290,11 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackCleanup)
class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit : public LayerTreeHostTest {
public:
LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit()
- : m_rootLayer(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate))
- , m_surfaceLayer1(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate))
- , m_replicaLayer1(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate))
- , m_surfaceLayer2(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate))
- , m_replicaLayer2(ContentLayerWithUpdateTracking::Create(&m_fakeDelegate))
+ : m_rootLayer(FakeContentLayer::Create(&m_client))
+ , m_surfaceLayer1(FakeContentLayer::Create(&m_client))
+ , m_replicaLayer1(FakeContentLayer::Create(&m_client))
+ , m_surfaceLayer2(FakeContentLayer::Create(&m_client))
+ , m_replicaLayer2(FakeContentLayer::Create(&m_client))
{
}
@@ -1306,12 +1308,15 @@ public:
layer_tree_host()->SetViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
m_rootLayer->SetBounds(gfx::Size(100, 100));
+ m_rootLayer->SetIsDrawable(true);
m_surfaceLayer1->SetBounds(gfx::Size(100, 100));
m_surfaceLayer1->SetForceRenderSurface(true);
m_surfaceLayer1->SetOpacity(0.5);
+ m_surfaceLayer1->SetIsDrawable(true);
m_surfaceLayer2->SetBounds(gfx::Size(100, 100));
m_surfaceLayer2->SetForceRenderSurface(true);
m_surfaceLayer2->SetOpacity(0.5);
+ m_surfaceLayer2->SetIsDrawable(true);
m_surfaceLayer1->SetReplicaLayer(m_replicaLayer1.get());
m_surfaceLayer2->SetReplicaLayer(m_replicaLayer2.get());
@@ -1329,7 +1334,8 @@ public:
RenderPass::Id surface1RenderPassId = hostImpl->active_tree()->root_layer()->children()[0]->render_surface()->RenderPassId();
RenderPass::Id surface2RenderPassId = hostImpl->active_tree()->root_layer()->children()[0]->children()[0]->render_surface()->RenderPassId();
- switch (hostImpl->active_tree()->source_frame_number()) {
+ int source_frame = hostImpl->active_tree()->source_frame_number();
+ switch (source_frame) {
case 0:
EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(surface1RenderPassId));
EXPECT_TRUE(renderer->HaveCachedResourcesForRenderPassId(surface2RenderPassId));
@@ -1347,27 +1353,25 @@ public:
}
}
+ virtual void DidCommitAndDrawFrame() OVERRIDE {
+ if (!TestEnded())
+ m_rootLayer->SetNeedsDisplay();
+ }
+
virtual void AfterTest() OVERRIDE
{
- EXPECT_EQ(2, m_rootLayer->paintContentsCount());
- EXPECT_EQ(2, m_surfaceLayer1->paintContentsCount());
- EXPECT_EQ(2, m_surfaceLayer2->paintContentsCount());
-
- // Clear layer references so LayerTreeHost dies.
- m_rootLayer = NULL;
- m_surfaceLayer1 = NULL;
- m_replicaLayer1 = NULL;
- m_surfaceLayer2 = NULL;
- m_replicaLayer2 = NULL;
+ EXPECT_EQ(3, m_rootLayer->update_count());
+ EXPECT_EQ(3, m_surfaceLayer1->update_count());
+ EXPECT_EQ(3, m_surfaceLayer2->update_count());
}
private:
- FakeContentLayerClient m_fakeDelegate;
- scoped_refptr<ContentLayerWithUpdateTracking> m_rootLayer;
- scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer1;
- scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer1;
- scoped_refptr<ContentLayerWithUpdateTracking> m_surfaceLayer2;
- scoped_refptr<ContentLayerWithUpdateTracking> m_replicaLayer2;
+ FakeContentLayerClient m_client;
+ scoped_refptr<FakeContentLayer> m_rootLayer;
+ scoped_refptr<FakeContentLayer> m_surfaceLayer1;
+ scoped_refptr<FakeContentLayer> m_replicaLayer1;
+ scoped_refptr<FakeContentLayer> m_surfaceLayer2;
+ scoped_refptr<FakeContentLayer> m_replicaLayer2;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit)
@@ -1515,7 +1519,7 @@ public:
// the beginFrame/commit pair.
// Commits 5+6 test the path where an eviction happens during the eviction
// recovery path.
- virtual void DidCommitAndDrawFrame() OVERRIDE
+ virtual void DidCommit() OVERRIDE
{
switch (m_numCommits) {
case 1:
@@ -1610,7 +1614,7 @@ public:
{
if (m_numDrawLayers == 2)
return;
- PostSetNeedsCommitToMainThread();
+ layer_tree_host()->root_layer()->SetNeedsDisplay();
}
virtual void CommitCompleteOnThread(LayerTreeHostImpl*) OVERRIDE

Powered by Google App Engine
This is Rietveld 408576698