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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 3144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3155 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 3155 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
3156 | 3156 |
3157 // Even though the layer can't scroll the overscroll still happens. | 3157 // Even though the layer can't scroll the overscroll still happens. |
3158 EXPECT_EQ(InputHandler::ScrollStarted, | 3158 EXPECT_EQ(InputHandler::ScrollStarted, |
3159 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 3159 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
3160 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3160 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
3161 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 3161 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
3162 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 3162 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
3163 } | 3163 } |
3164 | 3164 |
3165 TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) { | 3165 TEST_F(LayerTreeHostImplTest, RedundantGlowEffectCalls) { |
aelias_OOO_until_Jul13
2014/04/01 19:30:33
nit: "Redundant" is not the right word for this be
| |
3166 // Edge glow effect should be applicable only upon reaching Edges | |
3167 // of the content. unnecessary glow effect calls shouldn't be | |
3168 // called while scrolling up without reaching the edge of the content. | |
3169 gfx::Size surface_size(100, 100); | 3166 gfx::Size surface_size(100, 100); |
3170 gfx::Size content_size(200, 200); | 3167 gfx::Size content_size(200, 200); |
3171 scoped_ptr<LayerImpl> root_clip = | 3168 scoped_ptr<LayerImpl> root_clip = |
3172 LayerImpl::Create(host_impl_->active_tree(), 3); | 3169 LayerImpl::Create(host_impl_->active_tree(), 3); |
3173 scoped_ptr<LayerImpl> root = | 3170 scoped_ptr<LayerImpl> root = |
3174 CreateScrollableLayer(1, content_size, root_clip.get()); | 3171 CreateScrollableLayer(1, content_size, root_clip.get()); |
3175 root->SetIsContainerForFixedPositionLayers(true); | 3172 root->SetIsContainerForFixedPositionLayers(true); |
3176 scoped_ptr<LayerImpl> child = | 3173 scoped_ptr<LayerImpl> child = |
3177 CreateScrollableLayer(2, content_size, root_clip.get()); | 3174 CreateScrollableLayer(2, content_size, root_clip.get()); |
3178 | 3175 |
3179 child->SetScrollClipLayer(Layer::INVALID_ID); | 3176 child->SetScrollClipLayer(Layer::INVALID_ID); |
3180 root->AddChild(child.Pass()); | 3177 root->AddChild(child.Pass()); |
3181 root_clip->AddChild(root.Pass()); | 3178 root_clip->AddChild(root.Pass()); |
3182 | 3179 |
3183 host_impl_->SetViewportSize(surface_size); | 3180 host_impl_->SetViewportSize(surface_size); |
3184 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3181 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
3185 host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); | 3182 host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); |
3186 host_impl_->active_tree()->DidBecomeActive(); | 3183 host_impl_->active_tree()->DidBecomeActive(); |
3187 DrawFrame(); | 3184 DrawFrame(); |
3188 { | 3185 { |
3186 // Edge glow effect should be applicable only upon reaching Edges | |
3187 // of the content. unnecessary glow effect calls shouldn't be | |
3188 // called while scrolling up without reaching the edge of the content. | |
3189 EXPECT_EQ(InputHandler::ScrollStarted, | 3189 EXPECT_EQ(InputHandler::ScrollStarted, |
3190 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); | 3190 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |
3191 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); | 3191 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); |
3192 EXPECT_EQ(gfx::Vector2dF().ToString(), | 3192 EXPECT_EQ(gfx::Vector2dF().ToString(), |
3193 host_impl_->accumulated_root_overscroll().ToString()); | 3193 host_impl_->accumulated_root_overscroll().ToString()); |
3194 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); | 3194 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); |
3195 EXPECT_EQ(gfx::Vector2dF().ToString(), | 3195 EXPECT_EQ(gfx::Vector2dF().ToString(), |
3196 host_impl_->accumulated_root_overscroll().ToString()); | 3196 host_impl_->accumulated_root_overscroll().ToString()); |
3197 // unusedrootDelta should be subtracted from applied delta so that | |
3198 // unwanted glow effect calls are not called. | |
3199 EXPECT_EQ(InputHandler::ScrollStarted, | |
3200 host_impl_->ScrollBegin(gfx::Point(0, 0), | |
3201 InputHandler::NonBubblingGesture)); | |
3202 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); | |
3203 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20)); | |
3204 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), | |
3205 host_impl_->accumulated_root_overscroll().ToString()); | |
3206 | |
3207 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)); | |
3208 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), | |
3209 host_impl_->accumulated_root_overscroll().ToString()); | |
3210 | |
3197 host_impl_->ScrollEnd(); | 3211 host_impl_->ScrollEnd(); |
3198 } | 3212 } |
3199 } | 3213 } |
3200 | 3214 |
3201 class BlendStateCheckLayer : public LayerImpl { | 3215 class BlendStateCheckLayer : public LayerImpl { |
3202 public: | 3216 public: |
3203 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 3217 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
3204 int id, | 3218 int id, |
3205 ResourceProvider* resource_provider) { | 3219 ResourceProvider* resource_provider) { |
3206 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, | 3220 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, |
(...skipping 3034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6241 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6255 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
6242 300u * 1024u * 1024u); | 6256 300u * 1024u * 1024u); |
6243 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6257 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
6244 150u * 1024u * 1024u); | 6258 150u * 1024u * 1024u); |
6245 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, | 6259 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, |
6246 75u * 1024u * 1024u); | 6260 75u * 1024u * 1024u); |
6247 } | 6261 } |
6248 | 6262 |
6249 } // namespace | 6263 } // namespace |
6250 } // namespace cc | 6264 } // namespace cc |
OLD | NEW |