OLD | NEW |
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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 scroll_layer_ = layer; | 845 scroll_layer_ = layer; |
846 } else { | 846 } else { |
847 scroll_layer_ = FakeContentLayer::Create(&client_); | 847 scroll_layer_ = FakeContentLayer::Create(&client_); |
848 } | 848 } |
849 | 849 |
850 Layer* root_layer = layer_tree_host()->root_layer(); | 850 Layer* root_layer = layer_tree_host()->root_layer(); |
851 scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 851 scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
852 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 852 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
853 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), | 853 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
854 2 * root_layer->bounds().height())); | 854 2 * root_layer->bounds().height())); |
855 scroll_layer_->SetScrollOffset(gfx::Vector2d()); | 855 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); |
856 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 856 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
857 // This test requires the page_scale and inner viewport layers to be | 857 // This test requires the page_scale and inner viewport layers to be |
858 // identified. | 858 // identified. |
859 layer_tree_host()->RegisterViewportLayers( | 859 layer_tree_host()->RegisterViewportLayers( |
860 root_layer, scroll_layer_.get(), NULL); | 860 root_layer, scroll_layer_.get(), NULL); |
861 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 861 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
862 } | 862 } |
863 | 863 |
864 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 864 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
865 | 865 |
866 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 866 virtual void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
867 float scale, | 867 float scale, |
868 float) OVERRIDE { | 868 float) OVERRIDE { |
869 gfx::Vector2d offset = scroll_layer_->scroll_offset(); | 869 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); |
870 scroll_layer_->SetScrollOffset(offset + scroll_delta); | 870 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, |
| 871 scroll_delta)); |
871 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); | 872 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); |
872 } | 873 } |
873 | 874 |
874 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 875 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
875 // We get one commit before the first draw, and the animation doesn't happen | 876 // We get one commit before the first draw, and the animation doesn't happen |
876 // until the second draw. | 877 // until the second draw. |
877 switch (impl->active_tree()->source_frame_number()) { | 878 switch (impl->active_tree()->source_frame_number()) { |
878 case 0: | 879 case 0: |
879 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); | 880 EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor()); |
880 // We'll start an animation when we get back to the main thread. | 881 // We'll start an animation when we get back to the main thread. |
(...skipping 4218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5099 int activation_count_; | 5100 int activation_count_; |
5100 | 5101 |
5101 FakeContentLayerClient client_; | 5102 FakeContentLayerClient client_; |
5102 scoped_refptr<FakePictureLayer> picture_layer_; | 5103 scoped_refptr<FakePictureLayer> picture_layer_; |
5103 }; | 5104 }; |
5104 | 5105 |
5105 // TODO(vmpstr): Enable with single thread impl-side painting. | 5106 // TODO(vmpstr): Enable with single thread impl-side painting. |
5106 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); | 5107 MULTI_THREAD_TEST_F(LayerTreeHostTestInvisibleDoesntActivate); |
5107 | 5108 |
5108 } // namespace cc | 5109 } // namespace cc |
OLD | NEW |