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

Unified Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 1979273002: cc: Use to_screen transform for scroll offset snapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor change in unit test Created 4 years, 7 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 | « no previous file | 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_unittest_scroll.cc
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index ddc5507a27cc4ae93c917f86121e17be8206a6b0..ab4fab8c95bd62335caeb4a741ecf0ec32eb94bc 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -497,6 +497,63 @@ class LayerTreeHostScrollTestFractionalScroll : public LayerTreeHostScrollTest {
MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll);
+class LayerTreeHostScrollTestScrollSnapping : public LayerTreeHostScrollTest {
+ public:
+ LayerTreeHostScrollTestScrollSnapping() : scroll_amount_(1.75, 0) {}
+
+ void SetupTree() override {
+ LayerTreeHostScrollTest::SetupTree();
+ layer_tree_host()
+ ->outer_viewport_scroll_layer()
+ ->scroll_clip_layer()
+ ->SetForceRenderSurfaceForTesting(true);
+ gfx::Transform translate;
+ translate.Translate(0.25f, 0.f);
+ layer_tree_host()
+ ->outer_viewport_scroll_layer()
+ ->scroll_clip_layer()
+ ->SetTransform(translate);
+ layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f);
+ }
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
+ LayerImpl* scroll_layer = impl->OuterViewportScrollLayer();
+ gfx::Transform translate;
+
+ // Check that screen space transform of the scrollable layer is correctly
+ // snapped to integers.
+ switch (impl->active_tree()->source_frame_number()) {
+ case 0:
+ EXPECT_EQ(gfx::Transform(),
+ scroll_layer->draw_properties().screen_space_transform);
+ PostSetNeedsCommitToMainThread();
+ break;
+ case 1:
+ translate.Translate(-2, 0);
+ EXPECT_EQ(translate,
+ scroll_layer->draw_properties().screen_space_transform);
+ PostSetNeedsCommitToMainThread();
+ break;
+ case 2:
+ translate.Translate(-3, 0);
+ EXPECT_EQ(translate,
+ scroll_layer->draw_properties().screen_space_transform);
+ EndTest();
+ break;
+ }
+ scroll_layer->ScrollBy(scroll_amount_);
+ }
+
+ void AfterTest() override {}
+
+ private:
+ gfx::Vector2dF scroll_amount_;
+};
+
+MULTI_THREAD_TEST_F(LayerTreeHostScrollTestScrollSnapping);
+
class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
public:
LayerTreeHostScrollTestCaseWithChild()
« no previous file with comments | « no previous file | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698