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

Unified Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2451273003: cc : Snap texture layers to pixel boundary (Closed)
Patch Set: comments Created 4 years, 2 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/proto/property_tree.proto ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_common_unittest.cc
diff --git a/cc/trees/layer_tree_host_common_unittest.cc b/cc/trees/layer_tree_host_common_unittest.cc
index 287f3a9b286f737a59ef03bef7289f19ba414b5a..3188781ed3e70ea9800b23c3ea72d4c8c7f825c7 100644
--- a/cc/trees/layer_tree_host_common_unittest.cc
+++ b/cc/trees/layer_tree_host_common_unittest.cc
@@ -3524,6 +3524,49 @@ TEST_F(LayerTreeHostCommonTest, OcclusionBySiblingOfTarget) {
EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion));
}
+TEST_F(LayerTreeHostCommonTest, TextureLayerSnapping) {
+ FakeImplTaskRunnerProvider task_runner_provider;
+ TestSharedBitmapManager shared_bitmap_manager;
+ TestTaskGraphRunner task_graph_runner;
+ std::unique_ptr<CompositorFrameSink> compositor_frame_sink =
+ FakeCompositorFrameSink::Create3d();
+ FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager,
+ &task_graph_runner);
+
+ std::unique_ptr<LayerImpl> root =
+ LayerImpl::Create(host_impl.active_tree(), 1);
+ std::unique_ptr<TextureLayerImpl> child =
+ TextureLayerImpl::Create(host_impl.active_tree(), 2);
+
+ LayerImpl* child_ptr = child.get();
+
+ root->SetBounds(gfx::Size(100, 100));
+ child->SetBounds(gfx::Size(100, 100));
+ child->SetDrawsContent(true);
+ gfx::Transform fractional_translate;
+ fractional_translate.Translate(10.5f, 20.3f);
+ child->test_properties()->transform = fractional_translate;
+
+ host_impl.SetViewportSize(root->bounds());
+
+ root->test_properties()->AddChild(std::move(child));
+ host_impl.active_tree()->SetRootLayerForTesting(std::move(root));
+ host_impl.SetVisible(true);
+ host_impl.InitializeRenderer(compositor_frame_sink.get());
+ host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting();
+ bool update_lcd_text = false;
+ host_impl.active_tree()->UpdateDrawProperties(update_lcd_text);
+
+ EXPECT_NE(child_ptr->ScreenSpaceTransform(), fractional_translate);
+ fractional_translate.RoundTranslationComponents();
+ EXPECT_TRANSFORMATION_MATRIX_EQ(child_ptr->ScreenSpaceTransform(),
+ fractional_translate);
+ gfx::RectF layer_bounds_in_screen_space =
+ MathUtil::MapClippedRect(child_ptr->ScreenSpaceTransform(),
+ gfx::RectF(gfx::SizeF(child_ptr->bounds())));
+ EXPECT_EQ(layer_bounds_in_screen_space, gfx::RectF(11.f, 20.f, 100.f, 100.f));
+}
+
TEST_F(LayerTreeHostCommonTest,
OcclusionForLayerWithUninvertibleDrawTransform) {
FakeImplTaskRunnerProvider task_runner_provider;
« no previous file with comments | « cc/proto/property_tree.proto ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698