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

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

Issue 1736073002: cc: Move SyncedScrollOffset to scroll tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve comments Created 4 years, 9 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 scoped_ptr<ScrollAndScaleSet> scroll_info = 2026 scoped_ptr<ScrollAndScaleSet> scroll_info =
2027 host_impl_->ProcessScrollDeltas(); 2027 host_impl_->ProcessScrollDeltas();
2028 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale); 2028 EXPECT_EQ(scroll_info->page_scale_delta, max_page_scale);
2029 } 2029 }
2030 2030
2031 // Zoom-out clamping 2031 // Zoom-out clamping
2032 { 2032 {
2033 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2033 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2034 max_page_scale); 2034 max_page_scale);
2035 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2035 scroll_layer->SetScrollDelta(gfx::Vector2d());
2036 scroll_layer->PullDeltaForMainThread(); 2036 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2037 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 2037 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
2038 2038
2039 float page_scale_delta = 0.1f; 2039 float page_scale_delta = 0.1f;
2040 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), 2040 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(),
2041 InputHandler::GESTURE); 2041 InputHandler::GESTURE);
2042 host_impl_->PinchGestureBegin(); 2042 host_impl_->PinchGestureBegin();
2043 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point()); 2043 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point());
2044 host_impl_->PinchGestureEnd(); 2044 host_impl_->PinchGestureEnd();
2045 host_impl_->ScrollEnd(EndState().get()); 2045 host_impl_->ScrollEnd(EndState().get());
2046 2046
2047 scoped_ptr<ScrollAndScaleSet> scroll_info = 2047 scoped_ptr<ScrollAndScaleSet> scroll_info =
2048 host_impl_->ProcessScrollDeltas(); 2048 host_impl_->ProcessScrollDeltas();
2049 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); 2049 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
2050 2050
2051 EXPECT_TRUE(scroll_info->scrolls.empty()); 2051 EXPECT_TRUE(scroll_info->scrolls.empty());
2052 } 2052 }
2053 2053
2054 // Two-finger panning should not happen based on pinch events only 2054 // Two-finger panning should not happen based on pinch events only
2055 { 2055 {
2056 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2056 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2057 max_page_scale); 2057 max_page_scale);
2058 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2058 scroll_layer->SetScrollDelta(gfx::Vector2d());
2059 scroll_layer->PullDeltaForMainThread(); 2059 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2060 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); 2060 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20));
2061 2061
2062 float page_scale_delta = 1.f; 2062 float page_scale_delta = 1.f;
2063 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 2063 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
2064 InputHandler::GESTURE); 2064 InputHandler::GESTURE);
2065 host_impl_->PinchGestureBegin(); 2065 host_impl_->PinchGestureBegin();
2066 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 2066 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
2067 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 2067 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
2068 host_impl_->PinchGestureEnd(); 2068 host_impl_->PinchGestureEnd();
2069 host_impl_->ScrollEnd(EndState().get()); 2069 host_impl_->ScrollEnd(EndState().get());
2070 2070
2071 scoped_ptr<ScrollAndScaleSet> scroll_info = 2071 scoped_ptr<ScrollAndScaleSet> scroll_info =
2072 host_impl_->ProcessScrollDeltas(); 2072 host_impl_->ProcessScrollDeltas();
2073 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2073 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2074 EXPECT_TRUE(scroll_info->scrolls.empty()); 2074 EXPECT_TRUE(scroll_info->scrolls.empty());
2075 } 2075 }
2076 2076
2077 // Two-finger panning should work with interleaved scroll events 2077 // Two-finger panning should work with interleaved scroll events
2078 { 2078 {
2079 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 2079 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
2080 max_page_scale); 2080 max_page_scale);
2081 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2081 scroll_layer->SetScrollDelta(gfx::Vector2d());
2082 scroll_layer->PullDeltaForMainThread(); 2082 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2083 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20)); 2083 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(20, 20));
2084 2084
2085 float page_scale_delta = 1.f; 2085 float page_scale_delta = 1.f;
2086 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(), 2086 host_impl_->ScrollBegin(BeginState(gfx::Point(10, 10)).get(),
2087 InputHandler::GESTURE); 2087 InputHandler::GESTURE);
2088 host_impl_->PinchGestureBegin(); 2088 host_impl_->PinchGestureBegin();
2089 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10)); 2089 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(10, 10));
2090 host_impl_->ScrollBy( 2090 host_impl_->ScrollBy(
2091 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get()); 2091 UpdateState(gfx::Point(10, 10), gfx::Vector2d(-10, -10)).get());
2092 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20)); 2092 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(20, 20));
2093 host_impl_->PinchGestureEnd(); 2093 host_impl_->PinchGestureEnd();
2094 host_impl_->ScrollEnd(EndState().get()); 2094 host_impl_->ScrollEnd(EndState().get());
2095 2095
2096 scoped_ptr<ScrollAndScaleSet> scroll_info = 2096 scoped_ptr<ScrollAndScaleSet> scroll_info =
2097 host_impl_->ProcessScrollDeltas(); 2097 host_impl_->ProcessScrollDeltas();
2098 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 2098 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
2099 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 2099 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
2100 gfx::Vector2d(-10, -10))); 2100 gfx::Vector2d(-10, -10)));
2101 } 2101 }
2102 2102
2103 // Two-finger panning should work when starting fully zoomed out. 2103 // Two-finger panning should work when starting fully zoomed out.
2104 { 2104 {
2105 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f); 2105 host_impl_->active_tree()->PushPageScaleFromMainThread(0.5f, 0.5f, 4.f);
2106 scroll_layer->SetScrollDelta(gfx::Vector2d()); 2106 scroll_layer->SetScrollDelta(gfx::Vector2d());
2107 scroll_layer->PullDeltaForMainThread(); 2107 scroll_layer->synced_scroll_offset()->PullDeltaForMainThread();
2108 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0)); 2108 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 0));
2109 2109
2110 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), 2110 host_impl_->ScrollBegin(BeginState(gfx::Point(0, 0)).get(),
2111 InputHandler::GESTURE); 2111 InputHandler::GESTURE);
2112 host_impl_->PinchGestureBegin(); 2112 host_impl_->PinchGestureBegin();
2113 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0)); 2113 host_impl_->PinchGestureUpdate(2.f, gfx::Point(0, 0));
2114 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0)); 2114 host_impl_->PinchGestureUpdate(1.f, gfx::Point(0, 0));
2115 2115
2116 // Needed so layer transform includes page scale. 2116 // Needed so layer transform includes page scale.
2117 DrawFrame(); 2117 DrawFrame();
(...skipping 8085 matching lines...) Expand 10 before | Expand all | Expand 10 after
10203 // There should not be any jitter measured till we hit the fixed point hits 10203 // There should not be any jitter measured till we hit the fixed point hits
10204 // threshold. 10204 // threshold.
10205 float expected_jitter = 10205 float expected_jitter =
10206 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0; 10206 (i == pending_tree->kFixedPointHitsThreshold) ? 500 : 0;
10207 EXPECT_EQ(jitter, expected_jitter); 10207 EXPECT_EQ(jitter, expected_jitter);
10208 } 10208 }
10209 } 10209 }
10210 10210
10211 } // namespace 10211 } // namespace
10212 } // namespace cc 10212 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698