Chromium Code Reviews| Index: cc/layers/picture_layer_unittest.cc |
| diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc |
| index a253347ebcadb2b6b2db23e103c184973b691aa2..575185dfef73d7322df245e9c69dd9fd33b4e68a 100644 |
| --- a/cc/layers/picture_layer_unittest.cc |
| +++ b/cc/layers/picture_layer_unittest.cc |
| @@ -7,6 +7,7 @@ |
| #include "cc/layers/content_layer_client.h" |
| #include "cc/layers/picture_layer_impl.h" |
| #include "cc/resources/resource_update_queue.h" |
| +#include "cc/test/fake_content_layer_client.h" |
| #include "cc/test/fake_layer_tree_host.h" |
| #include "cc/test/fake_picture_layer_impl.h" |
| #include "cc/test/fake_proxy.h" |
| @@ -66,6 +67,7 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { |
| EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0)); |
| EXPECT_EQ(gfx::Size(), layer_impl->pile()->tiling_size()); |
| EXPECT_FALSE(layer_impl->pile()->HasRecordings()); |
| + EXPECT_TRUE(layer_impl->pile()->is_solid_color()); |
|
danakj
2014/09/19 20:44:28
do we care if it's solid color when it's empty? is
hendrikw
2014/09/19 22:27:13
Acknowledged.
|
| } |
| } |
| @@ -99,5 +101,89 @@ TEST(PictureLayerTest, RecordingModes) { |
| EXPECT_EQ(Picture::RECORD_WITH_SKRECORD, layer->RecordingMode()); |
| } |
| +TEST(PictureLayerTest, SolidColorAnalysisForPictureLayer) { |
|
danakj
2014/09/19 20:44:28
should this test move to picture_pile_unittest.cc?
hendrikw
2014/09/19 22:27:13
It was testing that the solid state was being tran
|
| + FakeContentLayerClient client; |
| + scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client); |
| + scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(); |
| + host->SetRootLayer(layer); |
| + PicturePile* pile = layer->GetPicturePileForTesting(); |
| + pile->tiling().SetTilingSize(pile->tiling().max_texture_size()); |
| + |
| + FakeProxy proxy; |
| + DebugScopedSetImplThread impl_thread(&proxy); |
| + |
| + TestSharedBitmapManager shared_bitmap_manager; |
| + FakeLayerTreeHostImpl host_impl( |
| + ImplSidePaintingSettings(), &proxy, &shared_bitmap_manager); |
| + host_impl.CreatePendingTree(); |
| + scoped_ptr<FakePictureLayerImpl> layer_impl = |
| + FakePictureLayerImpl::Create(host_impl.pending_tree(), 1); |
| + |
| + gfx::Size tiling_size = pile->tiling_size(); |
| + gfx::Rect tiling_rect = gfx::Rect(tiling_size); |
| + int frame_number = 0; |
| + FakeRenderingStatsInstrumentation stats_instrumentation; |
| + |
| + Region invalidation1(tiling_rect); |
| + pile->UpdateAndExpandInvalidation(&client, |
| + &invalidation1, |
| + SK_ColorWHITE, |
| + false, |
| + false, |
| + tiling_size, |
| + tiling_rect, |
| + frame_number++, |
| + Picture::RECORD_NORMALLY, |
| + &stats_instrumentation); |
| + |
| + // We haven't drawn anything yet, so it should be solid. |
| + EXPECT_TRUE(pile->is_solid_color()); |
| + layer->PushPropertiesTo(layer_impl.get()); |
| + EXPECT_TRUE(layer_impl->pile()->is_solid_color()); |
| + |
| + // Draw a rectangle that doesn't cover the viewport. |
| + gfx::Rect smallRect = tiling_rect; |
| + smallRect.Inset(10, 10, 10, 10); |
| + SkPaint paint; |
| + paint.setColor(SK_ColorCYAN); |
| + client.add_draw_rect(smallRect, paint); |
| + Region invalidation2(tiling_rect); |
| + pile->UpdateAndExpandInvalidation(&client, |
| + &invalidation2, |
| + SK_ColorWHITE, |
| + false, |
| + false, |
| + tiling_size, |
| + tiling_rect, |
| + frame_number++, |
| + Picture::RECORD_NORMALLY, |
| + &stats_instrumentation); |
| + |
| + // Since the rectangle doesn't cover the entire layer, we should no be solid |
| + EXPECT_FALSE(pile->is_solid_color()); |
| + layer->PushPropertiesTo(layer_impl.get()); |
| + EXPECT_FALSE(layer_impl->pile()->is_solid_color()); |
|
danakj
2014/09/19 20:44:28
you could just CreateFrom() another pile and verif
|
| + |
| + // Draw a rectangle that covers the viewport. |
| + client.add_draw_rect(tiling_rect, paint); |
| + Region invalidation3(tiling_rect); |
| + pile->UpdateAndExpandInvalidation(&client, |
| + &invalidation3, |
| + SK_ColorWHITE, |
| + false, |
| + false, |
| + tiling_size, |
| + tiling_rect, |
| + frame_number++, |
| + Picture::RECORD_NORMALLY, |
| + &stats_instrumentation); |
| + |
| + // Since the rectangle doesn't cover the entire layer, we should no be solid |
| + EXPECT_TRUE(pile->is_solid_color()); |
| + layer->PushPropertiesTo(layer_impl.get()); |
| + // EXPECT_EQ(0, layer->Tiling) |
| + // EXPECT_TRUE(layer_impl->pile()->is_solid_color()); |
|
danakj
2014/09/19 20:44:28
leftovers
|
| +} |
| + |
| } // namespace |
| } // namespace cc |