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 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())); | 2216 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())); |
2217 scroll_layer->AddChild(child.Pass()); | 2217 scroll_layer->AddChild(child.Pass()); |
2218 | 2218 |
2219 gfx::Size surface_size(50, 50); | 2219 gfx::Size surface_size(50, 50); |
2220 host_impl_->SetViewportSize(surface_size); | 2220 host_impl_->SetViewportSize(surface_size); |
2221 InitializeRendererAndDrawFrame(); | 2221 InitializeRendererAndDrawFrame(); |
2222 { | 2222 { |
2223 // Scroll down in screen coordinates with a gesture. | 2223 // Scroll down in screen coordinates with a gesture. |
2224 gfx::Vector2d gesture_scroll_delta(0, 10); | 2224 gfx::Vector2d gesture_scroll_delta(0, 10); |
2225 EXPECT_EQ(InputHandler::ScrollStarted, | 2225 EXPECT_EQ(InputHandler::ScrollStarted, |
2226 host_impl_->ScrollBegin(gfx::Point(), | 2226 host_impl_->ScrollBegin(gfx::Point(1, 1), |
2227 InputHandler::Gesture)); | 2227 InputHandler::Gesture)); |
2228 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 2228 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
2229 host_impl_->ScrollEnd(); | 2229 host_impl_->ScrollEnd(); |
2230 | 2230 |
2231 // The child layer should have scrolled down in its local coordinates an | 2231 // The child layer should have scrolled down in its local coordinates an |
2232 // amount proportional to the angle between it and the input scroll delta. | 2232 // amount proportional to the angle between it and the input scroll delta. |
2233 gfx::Vector2d expected_scroll_delta( | 2233 gfx::Vector2d expected_scroll_delta( |
2234 0, | 2234 0, |
2235 gesture_scroll_delta.y() * | 2235 gesture_scroll_delta.y() * |
2236 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | 2236 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
2237 scoped_ptr<ScrollAndScaleSet> scroll_info = | 2237 scoped_ptr<ScrollAndScaleSet> scroll_info = |
2238 host_impl_->ProcessScrollDeltas(); | 2238 host_impl_->ProcessScrollDeltas(); |
2239 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 2239 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
2240 | 2240 |
2241 // The root scroll layer should not have scrolled, because the input delta | 2241 // The root scroll layer should not have scrolled, because the input delta |
2242 // was close to the layer's axis of movement. | 2242 // was close to the layer's axis of movement. |
2243 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 2243 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
2244 } | 2244 } |
2245 { | 2245 { |
2246 // Now reset and scroll the same amount horizontally. | 2246 // Now reset and scroll the same amount horizontally. |
2247 scroll_layer->children()[1]->SetScrollDelta( | 2247 scroll_layer->children()[1]->SetScrollDelta( |
2248 gfx::Vector2dF()); | 2248 gfx::Vector2dF()); |
2249 gfx::Vector2d gesture_scroll_delta(10, 0); | 2249 gfx::Vector2d gesture_scroll_delta(10, 0); |
2250 EXPECT_EQ(InputHandler::ScrollStarted, | 2250 EXPECT_EQ(InputHandler::ScrollStarted, |
2251 host_impl_->ScrollBegin(gfx::Point(), | 2251 host_impl_->ScrollBegin(gfx::Point(1, 1), |
2252 InputHandler::Gesture)); | 2252 InputHandler::Gesture)); |
2253 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 2253 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
2254 host_impl_->ScrollEnd(); | 2254 host_impl_->ScrollEnd(); |
2255 | 2255 |
2256 // The child layer should have scrolled down in its local coordinates an | 2256 // The child layer should have scrolled down in its local coordinates an |
2257 // amount proportional to the angle between it and the input scroll delta. | 2257 // amount proportional to the angle between it and the input scroll delta. |
2258 gfx::Vector2d expected_scroll_delta( | 2258 gfx::Vector2d expected_scroll_delta( |
2259 0, | 2259 0, |
2260 -gesture_scroll_delta.x() * | 2260 -gesture_scroll_delta.x() * |
2261 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | 2261 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
(...skipping 4354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6616 host_impl_.reset(); | 6616 host_impl_.reset(); |
6617 | 6617 |
6618 // The CopyOutputResult's callback was cancelled, the CopyOutputResult | 6618 // The CopyOutputResult's callback was cancelled, the CopyOutputResult |
6619 // released, and the texture deleted. | 6619 // released, and the texture deleted. |
6620 EXPECT_TRUE(context_provider->HasOneRef()); | 6620 EXPECT_TRUE(context_provider->HasOneRef()); |
6621 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); | 6621 EXPECT_EQ(0u, context_provider->TestContext3d()->NumTextures()); |
6622 } | 6622 } |
6623 | 6623 |
6624 } // namespace | 6624 } // namespace |
6625 } // namespace cc | 6625 } // namespace cc |
OLD | NEW |