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

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

Issue 23043011: cc: Use SkMScalar instead of doubles everywhere in cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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 | Annotate | Revision Log
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_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 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2214 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())); 2214 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height()));
2215 scroll_layer->AddChild(child.Pass()); 2215 scroll_layer->AddChild(child.Pass());
2216 2216
2217 gfx::Size surface_size(50, 50); 2217 gfx::Size surface_size(50, 50);
2218 host_impl_->SetViewportSize(surface_size); 2218 host_impl_->SetViewportSize(surface_size);
2219 InitializeRendererAndDrawFrame(); 2219 InitializeRendererAndDrawFrame();
2220 { 2220 {
2221 // Scroll down in screen coordinates with a gesture. 2221 // Scroll down in screen coordinates with a gesture.
2222 gfx::Vector2d gesture_scroll_delta(0, 10); 2222 gfx::Vector2d gesture_scroll_delta(0, 10);
2223 EXPECT_EQ(InputHandler::ScrollStarted, 2223 EXPECT_EQ(InputHandler::ScrollStarted,
2224 host_impl_->ScrollBegin(gfx::Point(), 2224 host_impl_->ScrollBegin(gfx::Point(1, 1),
2225 InputHandler::Gesture)); 2225 InputHandler::Gesture));
2226 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); 2226 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta);
2227 host_impl_->ScrollEnd(); 2227 host_impl_->ScrollEnd();
2228 2228
2229 // The child layer should have scrolled down in its local coordinates an 2229 // The child layer should have scrolled down in its local coordinates an
2230 // amount proportional to the angle between it and the input scroll delta. 2230 // amount proportional to the angle between it and the input scroll delta.
2231 gfx::Vector2d expected_scroll_delta( 2231 gfx::Vector2d expected_scroll_delta(
2232 0, 2232 0,
2233 gesture_scroll_delta.y() * 2233 gesture_scroll_delta.y() *
2234 std::cos(MathUtil::Deg2Rad(child_layer_angle))); 2234 std::cos(MathUtil::Deg2Rad(child_layer_angle)));
2235 scoped_ptr<ScrollAndScaleSet> scroll_info = 2235 scoped_ptr<ScrollAndScaleSet> scroll_info =
2236 host_impl_->ProcessScrollDeltas(); 2236 host_impl_->ProcessScrollDeltas();
2237 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); 2237 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta);
2238 2238
2239 // The root scroll layer should not have scrolled, because the input delta 2239 // The root scroll layer should not have scrolled, because the input delta
2240 // was close to the layer's axis of movement. 2240 // was close to the layer's axis of movement.
2241 EXPECT_EQ(scroll_info->scrolls.size(), 1u); 2241 EXPECT_EQ(scroll_info->scrolls.size(), 1u);
2242 } 2242 }
2243 { 2243 {
2244 // Now reset and scroll the same amount horizontally. 2244 // Now reset and scroll the same amount horizontally.
2245 scroll_layer->children()[1]->SetScrollDelta( 2245 scroll_layer->children()[1]->SetScrollDelta(
2246 gfx::Vector2dF()); 2246 gfx::Vector2dF());
2247 gfx::Vector2d gesture_scroll_delta(10, 0); 2247 gfx::Vector2d gesture_scroll_delta(10, 0);
2248 EXPECT_EQ(InputHandler::ScrollStarted, 2248 EXPECT_EQ(InputHandler::ScrollStarted,
2249 host_impl_->ScrollBegin(gfx::Point(), 2249 host_impl_->ScrollBegin(gfx::Point(1, 1),
2250 InputHandler::Gesture)); 2250 InputHandler::Gesture));
2251 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); 2251 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta);
2252 host_impl_->ScrollEnd(); 2252 host_impl_->ScrollEnd();
2253 2253
2254 // The child layer should have scrolled down in its local coordinates an 2254 // The child layer should have scrolled down in its local coordinates an
2255 // amount proportional to the angle between it and the input scroll delta. 2255 // amount proportional to the angle between it and the input scroll delta.
2256 gfx::Vector2d expected_scroll_delta( 2256 gfx::Vector2d expected_scroll_delta(
2257 0, 2257 0,
2258 -gesture_scroll_delta.x() * 2258 -gesture_scroll_delta.x() *
2259 std::sin(MathUtil::Deg2Rad(child_layer_angle))); 2259 std::sin(MathUtil::Deg2Rad(child_layer_angle)));
(...skipping 4312 matching lines...) Expand 10 before | Expand all | Expand 10 after
6572 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6572 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6573 EXPECT_EQ(0u, context3d->NumTextures()); 6573 EXPECT_EQ(0u, context3d->NumTextures());
6574 6574
6575 // Should not change state for multiple deletion on one UIResourceId 6575 // Should not change state for multiple deletion on one UIResourceId
6576 host_impl_->DeleteUIResource(ui_resource_id); 6576 host_impl_->DeleteUIResource(ui_resource_id);
6577 EXPECT_EQ(0u, context3d->NumTextures()); 6577 EXPECT_EQ(0u, context3d->NumTextures());
6578 } 6578 }
6579 6579
6580 } // namespace 6580 } // namespace
6581 } // namespace cc 6581 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698