| 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 3170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3181 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 3181 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
| 3182 | 3182 |
| 3183 // Even though the layer can't scroll the overscroll still happens. | 3183 // Even though the layer can't scroll the overscroll still happens. |
| 3184 EXPECT_EQ(InputHandler::ScrollStarted, | 3184 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3185 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 3185 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 3186 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); | 3186 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2d(0, 10)); |
| 3187 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); | 3187 EXPECT_EQ(gfx::Vector2dF(0, 10), host_impl_->accumulated_root_overscroll()); |
| 3188 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); | 3188 EXPECT_EQ(gfx::Vector2dF(), host_impl_->current_fling_velocity()); |
| 3189 } | 3189 } |
| 3190 | 3190 |
| 3191 TEST_F(LayerTreeHostImplTest, UnnecessaryGlowEffectCallsWhileScrollingUp) { | 3191 TEST_F(LayerTreeHostImplTest, NoOverscrollWhenNotAtEdge) { |
| 3192 // Edge glow effect should be applicable only upon reaching Edges | |
| 3193 // of the content. unnecessary glow effect calls shouldn't be | |
| 3194 // called while scrolling up without reaching the edge of the content. | |
| 3195 gfx::Size surface_size(100, 100); | 3192 gfx::Size surface_size(100, 100); |
| 3196 gfx::Size content_size(200, 200); | 3193 gfx::Size content_size(200, 200); |
| 3197 scoped_ptr<LayerImpl> root_clip = | 3194 scoped_ptr<LayerImpl> root_clip = |
| 3198 LayerImpl::Create(host_impl_->active_tree(), 3); | 3195 LayerImpl::Create(host_impl_->active_tree(), 3); |
| 3199 scoped_ptr<LayerImpl> root = | 3196 scoped_ptr<LayerImpl> root = |
| 3200 CreateScrollableLayer(1, content_size, root_clip.get()); | 3197 CreateScrollableLayer(1, content_size, root_clip.get()); |
| 3201 root->SetIsContainerForFixedPositionLayers(true); | 3198 root->SetIsContainerForFixedPositionLayers(true); |
| 3202 scoped_ptr<LayerImpl> child = | 3199 scoped_ptr<LayerImpl> child = |
| 3203 CreateScrollableLayer(2, content_size, root_clip.get()); | 3200 CreateScrollableLayer(2, content_size, root_clip.get()); |
| 3204 | 3201 |
| 3205 child->SetScrollClipLayer(Layer::INVALID_ID); | 3202 child->SetScrollClipLayer(Layer::INVALID_ID); |
| 3206 root->AddChild(child.Pass()); | 3203 root->AddChild(child.Pass()); |
| 3207 root_clip->AddChild(root.Pass()); | 3204 root_clip->AddChild(root.Pass()); |
| 3208 | 3205 |
| 3209 host_impl_->SetViewportSize(surface_size); | 3206 host_impl_->SetViewportSize(surface_size); |
| 3210 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); | 3207 host_impl_->active_tree()->SetRootLayer(root_clip.Pass()); |
| 3211 host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); | 3208 host_impl_->active_tree()->SetViewportLayersFromIds(3, 1, Layer::INVALID_ID); |
| 3212 host_impl_->active_tree()->DidBecomeActive(); | 3209 host_impl_->active_tree()->DidBecomeActive(); |
| 3213 DrawFrame(); | 3210 DrawFrame(); |
| 3214 { | 3211 { |
| 3212 // Edge glow effect should be applicable only upon reaching Edges |
| 3213 // of the content. unnecessary glow effect calls shouldn't be |
| 3214 // called while scrolling up without reaching the edge of the content. |
| 3215 EXPECT_EQ(InputHandler::ScrollStarted, | 3215 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3216 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); | 3216 host_impl_->ScrollBegin(gfx::Point(0, 0), InputHandler::Wheel)); |
| 3217 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); | 3217 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 100)); |
| 3218 EXPECT_EQ(gfx::Vector2dF().ToString(), | 3218 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 3219 host_impl_->accumulated_root_overscroll().ToString()); | 3219 host_impl_->accumulated_root_overscroll().ToString()); |
| 3220 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); | 3220 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, -2.30f)); |
| 3221 EXPECT_EQ(gfx::Vector2dF().ToString(), | 3221 EXPECT_EQ(gfx::Vector2dF().ToString(), |
| 3222 host_impl_->accumulated_root_overscroll().ToString()); | 3222 host_impl_->accumulated_root_overscroll().ToString()); |
| 3223 host_impl_->ScrollEnd(); | 3223 host_impl_->ScrollEnd(); |
| 3224 // unusedrootDelta should be subtracted from applied delta so that |
| 3225 // unwanted glow effect calls are not called. |
| 3226 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3227 host_impl_->ScrollBegin(gfx::Point(0, 0), |
| 3228 InputHandler::NonBubblingGesture)); |
| 3229 EXPECT_EQ(InputHandler::ScrollStarted, host_impl_->FlingScrollBegin()); |
| 3230 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 20)); |
| 3231 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), |
| 3232 host_impl_->accumulated_root_overscroll().ToString()); |
| 3233 |
| 3234 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0.02f, -0.01f)); |
| 3235 EXPECT_EQ(gfx::Vector2dF(0.000000f, 17.699997f).ToString(), |
| 3236 host_impl_->accumulated_root_overscroll().ToString()); |
| 3237 host_impl_->ScrollEnd(); |
| 3224 } | 3238 } |
| 3225 } | 3239 } |
| 3226 | 3240 |
| 3227 class BlendStateCheckLayer : public LayerImpl { | 3241 class BlendStateCheckLayer : public LayerImpl { |
| 3228 public: | 3242 public: |
| 3229 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, | 3243 static scoped_ptr<LayerImpl> Create(LayerTreeImpl* tree_impl, |
| 3230 int id, | 3244 int id, |
| 3231 ResourceProvider* resource_provider) { | 3245 ResourceProvider* resource_provider) { |
| 3232 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, | 3246 return scoped_ptr<LayerImpl>(new BlendStateCheckLayer(tree_impl, |
| 3233 id, | 3247 id, |
| (...skipping 3033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6267 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6281 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
| 6268 300u * 1024u * 1024u); | 6282 300u * 1024u * 1024u); |
| 6269 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6283 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
| 6270 150u * 1024u * 1024u); | 6284 150u * 1024u * 1024u); |
| 6271 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, | 6285 EXPECT_EQ(host_impl_->global_tile_state().unused_memory_limit_in_bytes, |
| 6272 75u * 1024u * 1024u); | 6286 75u * 1024u * 1024u); |
| 6273 } | 6287 } |
| 6274 | 6288 |
| 6275 } // namespace | 6289 } // namespace |
| 6276 } // namespace cc | 6290 } // namespace cc |
| OLD | NEW |