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

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

Issue 2118773002: Respect main thread scrolling reasons for fallback to root layer scrolling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer comments. Created 4 years, 5 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 6252 matching lines...) Expand 10 before | Expand all | Expand 10 after
6263 scroll_result = host_impl_->ScrollBy( 6263 scroll_result = host_impl_->ScrollBy(
6264 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get()); 6264 UpdateState(gfx::Point(), gfx::Vector2dF(-0.12f, 0.1f)).get());
6265 EXPECT_FALSE(scroll_result.did_scroll); 6265 EXPECT_FALSE(scroll_result.did_scroll);
6266 EXPECT_FALSE(scroll_result.did_overscroll_root); 6266 EXPECT_FALSE(scroll_result.did_overscroll_root);
6267 EXPECT_EQ(gfx::Vector2dF().ToString(), 6267 EXPECT_EQ(gfx::Vector2dF().ToString(),
6268 host_impl_->accumulated_root_overscroll().ToString()); 6268 host_impl_->accumulated_root_overscroll().ToString());
6269 host_impl_->ScrollEnd(EndState().get()); 6269 host_impl_->ScrollEnd(EndState().get());
6270 } 6270 }
6271 } 6271 }
6272 6272
6273 TEST_F(LayerTreeHostImplTest, OverscrollOnMainThread) {
6274 InputHandlerScrollResult scroll_result;
6275 LayerTreeSettings settings = DefaultSettings();
6276 CreateHostImpl(settings, CreateOutputSurface());
6277
6278 const gfx::Size content_size(50, 50);
6279 const gfx::Size viewport_size(50, 50);
6280 CreateBasicVirtualViewportLayers(viewport_size, content_size);
6281
6282 LayerImpl* scroll_layer =
6283 host_impl_->active_tree()->InnerViewportScrollLayer();
6284 scroll_layer->set_main_thread_scrolling_reasons(
6285 MainThreadScrollingReason::kThreadedScrollingDisabled);
6286 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6287
6288 DrawFrame();
6289
6290 // Overscroll initiated outside layers will be handled by the main thread.
6291 EXPECT_EQ(nullptr, host_impl_->active_tree()->FindLayerThatIsHitByPoint(
6292 gfx::PointF(0, 60)));
6293 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD,
6294 host_impl_
6295 ->ScrollBegin(BeginState(gfx::Point(0, 60)).get(),
6296 InputHandler::WHEEL)
6297 .thread);
6298
6299 // Overscroll initiated inside layers will be handled by the main thread.
6300 EXPECT_NE(nullptr, host_impl_->active_tree()->FindLayerThatIsHitByPoint(
6301 gfx::PointF(0, 0)));
6302 EXPECT_EQ(
6303 InputHandler::SCROLL_ON_MAIN_THREAD,
6304 host_impl_
6305 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), InputHandler::WHEEL)
6306 .thread);
6307 }
6308
6309 TEST_F(LayerTreeHostImplTest, OverscrollOnImplThread) {
6310 InputHandlerScrollResult scroll_result;
6311 LayerTreeSettings settings = DefaultSettings();
6312 CreateHostImpl(settings, CreateOutputSurface());
6313
6314 const gfx::Size content_size(50, 50);
6315 const gfx::Size viewport_size(50, 50);
6316 CreateBasicVirtualViewportLayers(viewport_size, content_size);
6317
6318 // By default, no main thread scrolling reasons should exist.
6319 LayerImpl* scroll_layer =
6320 host_impl_->active_tree()->InnerViewportScrollLayer();
6321 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain,
6322 scroll_layer->main_thread_scrolling_reasons());
6323
6324 DrawFrame();
6325
6326 // Overscroll initiated outside layers will be handled by the impl thread.
6327 EXPECT_EQ(nullptr, host_impl_->active_tree()->FindLayerThatIsHitByPoint(
6328 gfx::PointF(0, 60)));
6329 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD,
6330 host_impl_
6331 ->ScrollBegin(BeginState(gfx::Point(0, 60)).get(),
6332 InputHandler::WHEEL)
6333 .thread);
6334
6335 // Overscroll initiated inside layers will be handled by the impl thread.
6336 EXPECT_NE(nullptr, host_impl_->active_tree()->FindLayerThatIsHitByPoint(
6337 gfx::PointF(0, 0)));
6338 EXPECT_EQ(
6339 InputHandler::SCROLL_ON_IMPL_THREAD,
6340 host_impl_
6341 ->ScrollBegin(BeginState(gfx::Point(0, 0)).get(), InputHandler::WHEEL)
6342 .thread);
6343 }
6344
6273 class BlendStateCheckLayer : public LayerImpl { 6345 class BlendStateCheckLayer : public LayerImpl {
6274 public: 6346 public:
6275 static std::unique_ptr<LayerImpl> Create( 6347 static std::unique_ptr<LayerImpl> Create(
6276 LayerTreeImpl* tree_impl, 6348 LayerTreeImpl* tree_impl,
6277 int id, 6349 int id,
6278 ResourceProvider* resource_provider) { 6350 ResourceProvider* resource_provider) {
6279 return base::WrapUnique( 6351 return base::WrapUnique(
6280 new BlendStateCheckLayer(tree_impl, id, resource_provider)); 6352 new BlendStateCheckLayer(tree_impl, id, resource_provider));
6281 } 6353 }
6282 6354
(...skipping 4669 matching lines...) Expand 10 before | Expand all | Expand 10 after
10952 11024
10953 // Re-initialize with a software output surface. 11025 // Re-initialize with a software output surface.
10954 output_surface_ = FakeOutputSurface::CreateSoftware( 11026 output_surface_ = FakeOutputSurface::CreateSoftware(
10955 base::WrapUnique(new SoftwareOutputDevice)); 11027 base::WrapUnique(new SoftwareOutputDevice));
10956 host_impl_->InitializeRenderer(output_surface_.get()); 11028 host_impl_->InitializeRenderer(output_surface_.get());
10957 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 11029 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10958 } 11030 }
10959 11031
10960 } // namespace 11032 } // namespace
10961 } // namespace cc 11033 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | third_party/WebKit/Source/core/page/scrolling/ScrollingCoordinator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698