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

Unified Diff: cc/layers/picture_layer_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: remove unused variable 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
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..42283535f794632b0f2111deb3bc13e7d80d6dfc 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());
}
}
@@ -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));
vmpstr 2014/09/15 15:45:07 Is this and the previous line required? I'd prefer
hendrikw 2014/09/15 16:59:40 Acknowledged.
+ 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());
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698