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

Unified Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 519583003: Use the solid color detection to create solid layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final merge Created 6 years, 3 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
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/solid_color_layer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_impl_unittest.cc
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 4f18d23c8b4da46e0cdcf0213eb586b31ebd32f7..537d4758ba2c005972aba4c6a42d8ad5b5340973 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -270,6 +270,8 @@ class PictureLayerImplTest : public testing::Test {
}
}
+ void TestQuadsForSolidColor(bool test_for_solid);
+
FakeImplProxy proxy_;
TestSharedBitmapManager shared_bitmap_manager_;
FakeLayerTreeHostImpl host_impl_;
@@ -4222,5 +4224,151 @@ TEST_F(PictureLayerImplTest, RecycledTwinLayer) {
EXPECT_FALSE(active_layer_->GetRecycledTwinLayer());
}
+void PictureLayerImplTest::TestQuadsForSolidColor(bool test_for_solid) {
+ base::TimeTicks time_ticks;
+ time_ticks += base::TimeDelta::FromMilliseconds(1);
+ host_impl_.SetCurrentBeginFrameArgs(
+ CreateBeginFrameArgsForTesting(time_ticks));
+
+ gfx::Size tile_size(100, 100);
+ gfx::Size layer_bounds(200, 200);
+ gfx::Rect layer_rect(layer_bounds);
+
+ FakeContentLayerClient client;
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
+ scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
+ host->SetRootLayer(layer);
+ PicturePile* pile = layer->GetPicturePileForTesting();
+
+ host_impl_.SetViewportSize(layer_bounds);
+
+ int frame_number = 0;
+ FakeRenderingStatsInstrumentation stats_instrumentation;
+
+ client.set_fill_with_nonsolid_color(!test_for_solid);
+
+ Region invalidation(layer_rect);
+ pile->UpdateAndExpandInvalidation(&client,
+ &invalidation,
+ SK_ColorWHITE,
+ false,
+ false,
+ layer_bounds,
+ layer_rect,
+ frame_number++,
+ Picture::RECORD_NORMALLY,
+ &stats_instrumentation);
+
+ scoped_refptr<PicturePileImpl> pending_pile =
+ PicturePileImpl::CreateFromOther(pile);
+
+ SetupPendingTree(pending_pile);
+ ActivateTree();
+
+ if (test_for_solid) {
+ EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
+ } else {
+ ASSERT_TRUE(active_layer_->tilings());
+ active_layer_->set_fixed_tile_size(tile_size);
+ host_impl_.active_tree()->UpdateDrawProperties();
+ ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u);
+ std::vector<Tile*> tiles =
+ active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
+ EXPECT_FALSE(tiles.empty());
+ host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
+ }
+
+ MockOcclusionTracker<LayerImpl> occlusion_tracker;
+ scoped_ptr<RenderPass> render_pass = RenderPass::Create();
+ AppendQuadsData data;
+ active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL);
+ active_layer_->AppendQuads(render_pass.get(), occlusion_tracker, &data);
+ active_layer_->DidDraw(NULL);
+
+ DrawQuad::Material expected = test_for_solid
+ ? DrawQuad::Material::SOLID_COLOR
+ : DrawQuad::Material::TILED_CONTENT;
+ EXPECT_EQ(expected, render_pass->quad_list.front()->material);
+}
+
+TEST_F(PictureLayerImplTest, DrawSolidQuads) {
+ TestQuadsForSolidColor(true);
+}
+
+TEST_F(PictureLayerImplTest, DrawNonSolidQuads) {
+ TestQuadsForSolidColor(false);
+}
+
+TEST_F(PictureLayerImplTest, NonSolidToSolidNoTilings) {
+ base::TimeTicks time_ticks;
+ time_ticks += base::TimeDelta::FromMilliseconds(1);
+ host_impl_.SetCurrentBeginFrameArgs(
+ CreateBeginFrameArgsForTesting(time_ticks));
+
+ gfx::Size tile_size(100, 100);
+ gfx::Size layer_bounds(200, 200);
+ gfx::Rect layer_rect(layer_bounds);
+
+ FakeContentLayerClient client;
+ scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
+ scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
+ host->SetRootLayer(layer);
+ PicturePile* pile = layer->GetPicturePileForTesting();
+
+ host_impl_.SetViewportSize(layer_bounds);
+
+ int frame_number = 0;
+ FakeRenderingStatsInstrumentation stats_instrumentation;
+
+ client.set_fill_with_nonsolid_color(true);
+
+ Region invalidation1(layer_rect);
+ pile->UpdateAndExpandInvalidation(&client,
+ &invalidation1,
+ SK_ColorWHITE,
+ false,
+ false,
+ layer_bounds,
+ layer_rect,
+ frame_number++,
+ Picture::RECORD_NORMALLY,
+ &stats_instrumentation);
+
+ scoped_refptr<PicturePileImpl> pending_pile1 =
+ PicturePileImpl::CreateFromOther(pile);
+
+ SetupPendingTree(pending_pile1);
+ ActivateTree();
+ host_impl_.active_tree()->UpdateDrawProperties();
+
+ // We've started with a solid layer that contains some tilings.
+ ASSERT_TRUE(active_layer_->tilings());
+ EXPECT_NE(0u, active_layer_->tilings()->num_tilings());
+
+ client.set_fill_with_nonsolid_color(false);
+
+ Region invalidation2(layer_rect);
+ pile->UpdateAndExpandInvalidation(&client,
+ &invalidation2,
+ SK_ColorWHITE,
+ false,
+ false,
+ layer_bounds,
+ layer_rect,
+ frame_number++,
+ Picture::RECORD_NORMALLY,
+ &stats_instrumentation);
+
+ scoped_refptr<PicturePileImpl> pending_pile2 =
+ PicturePileImpl::CreateFromOther(pile);
+
+ SetupPendingTree(pending_pile2);
+ ActivateTree();
+
+ // We've switched to a solid color, so we should end up with no tilings.
+ ASSERT_TRUE(active_layer_->tilings());
+ EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/layers/solid_color_layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698