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

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: Finalize test changes 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 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2199 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height())); 2199 child->SetMaxScrollOffset(gfx::Vector2d(0, child->content_bounds().height()));
2200 scroll_layer->AddChild(child.Pass()); 2200 scroll_layer->AddChild(child.Pass());
2201 2201
2202 gfx::Size surface_size(50, 50); 2202 gfx::Size surface_size(50, 50);
2203 host_impl_->SetViewportSize(surface_size); 2203 host_impl_->SetViewportSize(surface_size);
2204 InitializeRendererAndDrawFrame(); 2204 InitializeRendererAndDrawFrame();
2205 { 2205 {
2206 // Scroll down in screen coordinates with a gesture. 2206 // Scroll down in screen coordinates with a gesture.
2207 gfx::Vector2d gesture_scroll_delta(0, 10); 2207 gfx::Vector2d gesture_scroll_delta(0, 10);
2208 EXPECT_EQ(InputHandler::ScrollStarted, 2208 EXPECT_EQ(InputHandler::ScrollStarted,
2209 host_impl_->ScrollBegin(gfx::Point(), 2209 host_impl_->ScrollBegin(gfx::Point(1, 1),
danakj 2013/09/09 17:57:45 Why is this needed? Can you add a comment explaini
enne (OOO) 2013/09/10 22:32:32 Yeah, when this is floating point the origin no lo
2210 InputHandler::Gesture)); 2210 InputHandler::Gesture));
2211 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); 2211 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta);
2212 host_impl_->ScrollEnd(); 2212 host_impl_->ScrollEnd();
2213 2213
2214 // The child layer should have scrolled down in its local coordinates an 2214 // The child layer should have scrolled down in its local coordinates an
2215 // amount proportional to the angle between it and the input scroll delta. 2215 // amount proportional to the angle between it and the input scroll delta.
2216 gfx::Vector2d expected_scroll_delta( 2216 gfx::Vector2d expected_scroll_delta(
2217 0, 2217 0,
2218 gesture_scroll_delta.y() * 2218 gesture_scroll_delta.y() *
2219 std::cos(MathUtil::Deg2Rad(child_layer_angle))); 2219 std::cos(MathUtil::Deg2Rad(child_layer_angle)));
2220 scoped_ptr<ScrollAndScaleSet> scroll_info = 2220 scoped_ptr<ScrollAndScaleSet> scroll_info =
2221 host_impl_->ProcessScrollDeltas(); 2221 host_impl_->ProcessScrollDeltas();
2222 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); 2222 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta);
2223 2223
2224 // The root scroll layer should not have scrolled, because the input delta 2224 // The root scroll layer should not have scrolled, because the input delta
2225 // was close to the layer's axis of movement. 2225 // was close to the layer's axis of movement.
2226 EXPECT_EQ(scroll_info->scrolls.size(), 1u); 2226 EXPECT_EQ(scroll_info->scrolls.size(), 1u);
2227 } 2227 }
2228 { 2228 {
2229 // Now reset and scroll the same amount horizontally. 2229 // Now reset and scroll the same amount horizontally.
2230 scroll_layer->children()[1]->SetScrollDelta( 2230 scroll_layer->children()[1]->SetScrollDelta(
2231 gfx::Vector2dF()); 2231 gfx::Vector2dF());
2232 gfx::Vector2d gesture_scroll_delta(10, 0); 2232 gfx::Vector2d gesture_scroll_delta(10, 0);
2233 EXPECT_EQ(InputHandler::ScrollStarted, 2233 EXPECT_EQ(InputHandler::ScrollStarted,
2234 host_impl_->ScrollBegin(gfx::Point(), 2234 host_impl_->ScrollBegin(gfx::Point(1, 1),
2235 InputHandler::Gesture)); 2235 InputHandler::Gesture));
2236 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); 2236 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta);
2237 host_impl_->ScrollEnd(); 2237 host_impl_->ScrollEnd();
2238 2238
2239 // The child layer should have scrolled down in its local coordinates an 2239 // The child layer should have scrolled down in its local coordinates an
2240 // amount proportional to the angle between it and the input scroll delta. 2240 // amount proportional to the angle between it and the input scroll delta.
2241 gfx::Vector2d expected_scroll_delta( 2241 gfx::Vector2d expected_scroll_delta(
2242 0, 2242 0,
2243 -gesture_scroll_delta.x() * 2243 -gesture_scroll_delta.x() *
2244 std::sin(MathUtil::Deg2Rad(child_layer_angle))); 2244 std::sin(MathUtil::Deg2Rad(child_layer_angle)));
(...skipping 4131 matching lines...) Expand 10 before | Expand all | Expand 10 after
6376 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id)); 6376 EXPECT_EQ(0u, host_impl_->ResourceIdForUIResource(ui_resource_id));
6377 EXPECT_EQ(0u, context3d->NumTextures()); 6377 EXPECT_EQ(0u, context3d->NumTextures());
6378 6378
6379 // Should not change state for multiple deletion on one UIResourceId 6379 // Should not change state for multiple deletion on one UIResourceId
6380 host_impl_->DeleteUIResource(ui_resource_id); 6380 host_impl_->DeleteUIResource(ui_resource_id);
6381 EXPECT_EQ(0u, context3d->NumTextures()); 6381 EXPECT_EQ(0u, context3d->NumTextures());
6382 } 6382 }
6383 6383
6384 } // namespace 6384 } // namespace
6385 } // namespace cc 6385 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698