| 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..5c6bc5aff0fab29f34d0514dbaec26f2ae22ed82 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->IsSolidColor());
|
| }
|
| }
|
|
|
| @@ -99,5 +101,71 @@ TEST(PictureLayerTest, RecordingModes) {
|
| EXPECT_EQ(Picture::RECORD_WITH_SKRECORD, layer->RecordingMode());
|
| }
|
|
|
| +TEST(PictureLayerTest, SolidColorAnalysisForPictureLayer) {
|
| + FakeContentLayerClient client;
|
| + scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
|
| + scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
|
| + host->SetRootLayer(layer);
|
| + PicturePile* pile = layer->GetPicturePileForTesting();
|
| + pile->SetMinContentsScale(0.125);
|
| + pile->SetTileGridSize(gfx::Size(1000, 1000));
|
| + 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->IsSolidColor());
|
| + layer->PushPropertiesTo(layer_impl.get());
|
| + EXPECT_TRUE(layer_impl->IsSolidColor());
|
| +
|
| + // 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->IsSolidColor());
|
| + layer->PushPropertiesTo(layer_impl.get());
|
| + EXPECT_FALSE(layer_impl->IsSolidColor());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|