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

Unified Diff: cc/layers/ui_resource_layer_impl_unittest.cc

Issue 203463015: cc: Apply occlusion before creating quads in UIResourceLayerImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « cc/layers/ui_resource_layer_impl.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/ui_resource_layer_impl_unittest.cc
diff --git a/cc/layers/ui_resource_layer_impl_unittest.cc b/cc/layers/ui_resource_layer_impl_unittest.cc
index 596cb3bc8a97c4ac3a0b21d6bf9d9e6f18795e7a..01c7c40f4aae095c7bd5cfe316344fde88b6f381 100644
--- a/cc/layers/ui_resource_layer_impl_unittest.cc
+++ b/cc/layers/ui_resource_layer_impl_unittest.cc
@@ -148,5 +148,64 @@ TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) {
OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds);
}
+TEST(UIResourceLayerImplTest, Occlusion) {
+ gfx::Size layer_size(1000, 1000);
+ gfx::Size viewport_size(1000, 1000);
+
+ LayerTestCommon::LayerImplTest impl;
+
+ SkBitmap sk_bitmap;
+ sk_bitmap.allocN32Pixels(10, 10);
+ sk_bitmap.setImmutable();
+ UIResourceId uid = 5;
+ UIResourceBitmap bitmap(sk_bitmap);
+ impl.host_impl()->CreateUIResource(uid, bitmap);
+
+ UIResourceLayerImpl* ui_resource_layer_impl =
+ impl.AddChildToRoot<UIResourceLayerImpl>();
+ ui_resource_layer_impl->SetAnchorPoint(gfx::PointF());
+ ui_resource_layer_impl->SetBounds(layer_size);
+ ui_resource_layer_impl->SetContentBounds(layer_size);
+ ui_resource_layer_impl->SetDrawsContent(true);
+ ui_resource_layer_impl->SetUIResourceId(uid);
+
+ impl.CalcDrawProps(viewport_size);
+
+ {
+ SCOPED_TRACE("No occlusion");
+ gfx::Rect occluded;
+ impl.AppendQuadsWithOcclusion(ui_resource_layer_impl, occluded);
+
+ LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
+ gfx::Rect(layer_size));
+ EXPECT_EQ(1u, impl.quad_list().size());
+ }
+
+ {
+ SCOPED_TRACE("Full occlusion");
+ gfx::Rect occluded(ui_resource_layer_impl->visible_content_rect());
+ impl.AppendQuadsWithOcclusion(ui_resource_layer_impl, occluded);
+
+ LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect());
+ EXPECT_EQ(impl.quad_list().size(), 0u);
+ }
+
+ {
+ SCOPED_TRACE("Partial occlusion");
+ gfx::Rect occluded(200, 0, 800, 1000);
+ impl.AppendQuadsWithOcclusion(ui_resource_layer_impl, occluded);
+
+ size_t partially_occluded_count = 0;
+ LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
+ impl.quad_list(),
+ gfx::Rect(layer_size),
+ occluded,
+ &partially_occluded_count);
+ // The layer outputs one quad, which is partially occluded.
+ EXPECT_EQ(1u, impl.quad_list().size());
+ EXPECT_EQ(1u, partially_occluded_count);
+ }
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layers/ui_resource_layer_impl.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698