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

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 877173002: Fixed position layer counter-scroll with main thread scroll offset fractional part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ready for review Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <tuple>
9 10
10 #include "cc/animation/layer_animation_controller.h" 11 #include "cc/animation/layer_animation_controller.h"
11 #include "cc/animation/transform_operations.h" 12 #include "cc/animation/transform_operations.h"
12 #include "cc/base/math_util.h" 13 #include "cc/base/math_util.h"
13 #include "cc/layers/content_layer.h" 14 #include "cc/layers/content_layer.h"
14 #include "cc/layers/content_layer_client.h" 15 #include "cc/layers/content_layer_client.h"
15 #include "cc/layers/layer.h" 16 #include "cc/layers/layer.h"
16 #include "cc/layers/layer_client.h" 17 #include "cc/layers/layer_client.h"
17 #include "cc/layers/layer_impl.h" 18 #include "cc/layers/layer_impl.h"
18 #include "cc/layers/layer_iterator.h" 19 #include "cc/layers/layer_iterator.h"
19 #include "cc/layers/render_surface.h" 20 #include "cc/layers/render_surface.h"
20 #include "cc/layers/render_surface_impl.h" 21 #include "cc/layers/render_surface_impl.h"
21 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
22 #include "cc/output/copy_output_result.h" 23 #include "cc/output/copy_output_result.h"
23 #include "cc/test/animation_test_common.h" 24 #include "cc/test/animation_test_common.h"
24 #include "cc/test/fake_impl_proxy.h" 25 #include "cc/test/fake_impl_proxy.h"
25 #include "cc/test/fake_layer_tree_host.h" 26 #include "cc/test/fake_layer_tree_host.h"
26 #include "cc/test/fake_layer_tree_host_impl.h" 27 #include "cc/test/fake_layer_tree_host_impl.h"
27 #include "cc/test/fake_picture_layer.h" 28 #include "cc/test/fake_picture_layer.h"
28 #include "cc/test/fake_picture_layer_impl.h" 29 #include "cc/test/fake_picture_layer_impl.h"
29 #include "cc/test/geometry_test_utils.h" 30 #include "cc/test/geometry_test_utils.h"
30 #include "cc/test/layer_tree_host_common_test.h" 31 #include "cc/test/layer_tree_host_common_test.h"
31 #include "cc/trees/layer_tree_impl.h" 32 #include "cc/trees/layer_tree_impl.h"
32 #include "cc/trees/proxy.h" 33 #include "cc/trees/proxy.h"
33 #include "cc/trees/single_thread_proxy.h" 34 #include "cc/trees/single_thread_proxy.h"
34 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 #include "ui/gfx/geometry/quad_f.h" 37 #include "ui/gfx/geometry/quad_f.h"
38 #include "ui/gfx/geometry/vector2d_conversions.h"
37 #include "ui/gfx/transform.h" 39 #include "ui/gfx/transform.h"
38 40
39 namespace cc { 41 namespace cc {
40 namespace { 42 namespace {
41 43
42 class LayerWithForcedDrawsContent : public Layer { 44 class LayerWithForcedDrawsContent : public Layer {
43 public: 45 public:
44 LayerWithForcedDrawsContent() {} 46 LayerWithForcedDrawsContent() {}
45 47
46 bool DrawsContent() const override; 48 bool DrawsContent() const override;
(...skipping 7709 matching lines...) Expand 10 before | Expand all | Expand 10 after
7756 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 7758 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7757 7759
7758 EXPECT_VECTOR_EQ( 7760 EXPECT_VECTOR_EQ(
7759 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), 7761 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7760 container_offset); 7762 container_offset);
7761 7763
7762 scroll_layer->SetTransform(identity_transform); 7764 scroll_layer->SetTransform(identity_transform);
7763 } 7765 }
7764 } 7766 }
7765 7767
7768 TEST_F(LayerTreeHostCommonTest,
7769 ScrollCompensationMainScrollOffsetFractionalPart) {
7770 // This test verifies that a scrolling layer that has fractional scroll offset
7771 // from main doesn't move a fixed position child.
7772 //
7773 // + root
7774 // + container
7775 // + scroller
7776 // + fixed
7777 //
7778 FakeImplProxy proxy;
7779 TestSharedBitmapManager shared_bitmap_manager;
7780 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
7781 host_impl.CreatePendingTree();
7782 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1);
7783 scoped_ptr<LayerImpl> container =
7784 LayerImpl::Create(host_impl.active_tree(), 2);
7785 LayerImpl* container_layer = container.get();
7786 scoped_ptr<LayerImpl> scroller =
7787 LayerImpl::Create(host_impl.active_tree(), 3);
7788 LayerImpl* scroll_layer = scroller.get();
7789 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4);
7790 LayerImpl* fixed_layer = fixed.get();
7791
7792 container->SetIsContainerForFixedPositionLayers(true);
7793
7794 LayerPositionConstraint constraint;
7795 constraint.set_is_fixed_position(true);
7796 fixed->SetPositionConstraint(constraint);
7797
7798 scroller->SetScrollClipLayer(container->id());
7799
7800 gfx::Transform identity_transform;
7801 gfx::Transform container_transform;
7802 container_transform.Translate3d(10.0, 20.0, 0.0);
7803 gfx::Vector2dF container_offset = container_transform.To2dTranslation();
7804
7805 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(),
7806 gfx::PointF(), gfx::Size(50, 50), true, false,
7807 true);
7808 SetLayerPropertiesForTesting(container.get(), container_transform,
7809 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40),
7810 true, false, false);
7811 SetLayerPropertiesForTesting(scroller.get(), identity_transform,
7812 gfx::Point3F(), gfx::PointF(0.0, 0.0),
7813 gfx::Size(30, 30), true, false, false);
7814
7815 gfx::ScrollOffset scroll_offset(3.3, 4.2);
7816 gfx::Vector2dF main_scroll_fractional_part(0.3, 0.2);
7817 gfx::Vector2dF scroll_delta(0.1, 0.4);
7818 // Blink only uses the integer part of the scroll_offset for fixed
7819 // position layer.
7820 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(),
7821 gfx::PointF(3.0, 4.0), gfx::Size(50, 50), true,
7822 false, false);
7823 scroll_layer->SetScrollOffsetAndDelta(scroll_offset, scroll_delta);
7824 scroll_layer->SetMainScrollOffsetFractionalPart(main_scroll_fractional_part);
7825
7826 scroller->AddChild(fixed.Pass());
7827 container->AddChild(scroller.Pass());
7828 root->AddChild(container.Pass());
7829
7830 LayerImplList render_surface_layer_list;
7831 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
7832 root.get(), root->bounds(), &render_surface_layer_list);
7833 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
7834
7835 EXPECT_TRANSFORMATION_MATRIX_EQ(
7836 container_layer->draw_properties().screen_space_transform,
7837 fixed_layer->draw_properties().screen_space_transform);
7838 EXPECT_VECTOR_EQ(
7839 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(),
7840 container_offset);
7841
7842 gfx::ScrollOffset effective_scroll_offset =
7843 ScrollOffsetWithDelta(scroll_offset, scroll_delta);
7844 gfx::Vector2d rounded_effective_scroll_offset =
7845 ToRoundedVector2d(ScrollOffsetToVector2dF(effective_scroll_offset));
7846 EXPECT_VECTOR_EQ(
7847 scroll_layer->draw_properties().screen_space_transform.To2dTranslation(),
7848 container_offset - rounded_effective_scroll_offset);
7849 }
7850
7766 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { 7851 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl {
7767 public: 7852 public:
7768 static scoped_ptr<AnimationScaleFactorTrackingLayerImpl> Create( 7853 static scoped_ptr<AnimationScaleFactorTrackingLayerImpl> Create(
7769 LayerTreeImpl* tree_impl, 7854 LayerTreeImpl* tree_impl,
7770 int id) { 7855 int id) {
7771 return make_scoped_ptr( 7856 return make_scoped_ptr(
7772 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id)); 7857 new AnimationScaleFactorTrackingLayerImpl(tree_impl, id));
7773 } 7858 }
7774 7859
7775 ~AnimationScaleFactorTrackingLayerImpl() override {} 7860 ~AnimationScaleFactorTrackingLayerImpl() override {}
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
8582 8667
8583 LayerTreeHostCommon::CalculateDrawProperties(&inputs); 8668 LayerTreeHostCommon::CalculateDrawProperties(&inputs);
8584 8669
8585 gfx::Rect affected_by_delta(0, 0, root_size.width(), 8670 gfx::Rect affected_by_delta(0, 0, root_size.width(),
8586 root_size.height() + 50); 8671 root_size.height() + 50);
8587 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect()); 8672 EXPECT_EQ(affected_by_delta, sublayer->visible_content_rect());
8588 } 8673 }
8589 8674
8590 } // namespace 8675 } // namespace
8591 } // namespace cc 8676 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_common.cc ('K') | « cc/trees/layer_tree_host_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698