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

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

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 class LayerTreeHostScrollTest : public LayerTreeTest { 63 class LayerTreeHostScrollTest : public LayerTreeTest {
64 protected: 64 protected:
65 void SetupTree() override { 65 void SetupTree() override {
66 LayerTreeTest::SetupTree(); 66 LayerTreeTest::SetupTree();
67 Layer* root_layer = layer_tree_host()->root_layer(); 67 Layer* root_layer = layer_tree_host()->root_layer();
68 68
69 // Create an effective max_scroll_offset of (100, 100). 69 // Create an effective max_scroll_offset of (100, 100).
70 gfx::Size scroll_layer_bounds(root_layer->bounds().width() + 100, 70 gfx::Size scroll_layer_bounds(root_layer->bounds().width() + 100,
71 root_layer->bounds().height() + 100); 71 root_layer->bounds().height() + 100);
72 72
73 CreateVirtualViewportLayers(root_layer, 73 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
74 root_layer->bounds(), 74 root_layer->bounds(), scroll_layer_bounds,
75 root_layer->bounds(), 75 layer_tree_host());
76 scroll_layer_bounds,
77 layer_tree_host(),
78 layer_settings());
79 } 76 }
80 }; 77 };
81 78
82 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { 79 class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest {
83 public: 80 public:
84 LayerTreeHostScrollTestScrollSimple() 81 LayerTreeHostScrollTestScrollSimple()
85 : initial_scroll_(10, 20), 82 : initial_scroll_(10, 20),
86 second_scroll_(40, 5), 83 second_scroll_(40, 5),
87 scroll_amount_(2, -1), 84 scroll_amount_(2, -1),
88 num_scrolls_(0) {} 85 num_scrolls_(0) {}
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 public: 496 public:
500 LayerTreeHostScrollTestCaseWithChild() 497 LayerTreeHostScrollTestCaseWithChild()
501 : initial_offset_(10, 20), 498 : initial_offset_(10, 20),
502 javascript_scroll_(40, 5), 499 javascript_scroll_(40, 5),
503 scroll_amount_(2, -1), 500 scroll_amount_(2, -1),
504 num_scrolls_(0) {} 501 num_scrolls_(0) {}
505 502
506 void SetupTree() override { 503 void SetupTree() override {
507 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); 504 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
508 505
509 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); 506 scoped_refptr<Layer> root_layer = Layer::Create();
510 root_layer->SetBounds(gfx::Size(10, 10)); 507 root_layer->SetBounds(gfx::Size(10, 10));
511 508
512 root_scroll_layer_ = 509 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
513 FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_);
514 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); 510 root_scroll_layer_->SetBounds(gfx::Size(110, 110));
515 root_scroll_layer_->SetPosition(gfx::PointF()); 511 root_scroll_layer_->SetPosition(gfx::PointF());
516 root_scroll_layer_->SetIsDrawable(true); 512 root_scroll_layer_->SetIsDrawable(true);
517 513
518 CreateVirtualViewportLayers(root_layer.get(), 514 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_,
519 root_scroll_layer_, 515 root_layer->bounds(), root_layer->bounds(),
520 root_layer->bounds(), 516 layer_tree_host());
521 root_layer->bounds(),
522 layer_tree_host(),
523 layer_settings());
524 517
525 518 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
526 child_layer_ =
527 FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_);
528 child_layer_->set_did_scroll_callback( 519 child_layer_->set_did_scroll_callback(
529 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, 520 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll,
530 base::Unretained(this))); 521 base::Unretained(this)));
531 child_layer_->SetBounds(gfx::Size(110, 110)); 522 child_layer_->SetBounds(gfx::Size(110, 110));
532 523
533 if (scroll_child_layer_) { 524 if (scroll_child_layer_) {
534 // Scrolls on the child layer will happen at 5, 5. If they are treated 525 // Scrolls on the child layer will happen at 5, 5. If they are treated
535 // like device pixels, and device scale factor is 2, then they will 526 // like device pixels, and device scale factor is 2, then they will
536 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. 527 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer.
537 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); 528 child_layer_->SetPosition(gfx::PointF(5.f, 5.f));
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 : public LayerTreeHostScrollTest { 1318 : public LayerTreeHostScrollTest {
1328 public: 1319 public:
1329 LayerTreeHostScrollTestLayerStructureChange() 1320 LayerTreeHostScrollTestLayerStructureChange()
1330 : scroll_destroy_whole_tree_(false) {} 1321 : scroll_destroy_whole_tree_(false) {}
1331 1322
1332 void SetupTree() override { 1323 void SetupTree() override {
1333 LayerTreeTest::SetupTree(); 1324 LayerTreeTest::SetupTree();
1334 Layer* root_layer = layer_tree_host()->root_layer(); 1325 Layer* root_layer = layer_tree_host()->root_layer();
1335 root_layer->SetBounds(gfx::Size(10, 10)); 1326 root_layer->SetBounds(gfx::Size(10, 10));
1336 1327
1337 CreateVirtualViewportLayers(root_layer, 1328 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
1338 root_layer->bounds(), 1329 root_layer->bounds(), root_layer->bounds(),
1339 root_layer->bounds(), 1330 layer_tree_host());
1340 root_layer->bounds(),
1341 layer_tree_host(),
1342 layer_settings());
1343 1331
1344 Layer* outer_scroll_layer = 1332 Layer* outer_scroll_layer =
1345 layer_tree_host()->outer_viewport_scroll_layer(); 1333 layer_tree_host()->outer_viewport_scroll_layer();
1346 1334
1347 Layer* root_scroll_layer = 1335 Layer* root_scroll_layer =
1348 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_); 1336 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_);
1349 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_); 1337 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_);
1350 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); 1338 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_);
1351 fake_content_layer_client_.set_bounds(root_layer->bounds()); 1339 fake_content_layer_client_.set_bounds(root_layer->bounds());
1352 } 1340 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 public: 1374 public:
1387 void DidScroll() { 1375 void DidScroll() {
1388 owner_->DidScroll(layer_); 1376 owner_->DidScroll(layer_);
1389 } 1377 }
1390 LayerTreeHostScrollTestLayerStructureChange* owner_; 1378 LayerTreeHostScrollTestLayerStructureChange* owner_;
1391 Layer* layer_; 1379 Layer* layer_;
1392 }; 1380 };
1393 1381
1394 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { 1382 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
1395 scoped_refptr<PictureLayer> scroll_layer = 1383 scoped_refptr<PictureLayer> scroll_layer =
1396 PictureLayer::Create(layer_settings(), &fake_content_layer_client_); 1384 PictureLayer::Create(&fake_content_layer_client_);
1397 scroll_layer->SetBounds(gfx::Size(110, 110)); 1385 scroll_layer->SetBounds(gfx::Size(110, 110));
1398 scroll_layer->SetPosition(gfx::PointF()); 1386 scroll_layer->SetPosition(gfx::PointF());
1399 scroll_layer->SetIsDrawable(true); 1387 scroll_layer->SetIsDrawable(true);
1400 scroll_layer->SetScrollClipLayerId(parent->id()); 1388 scroll_layer->SetScrollClipLayerId(parent->id());
1401 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, 1389 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100,
1402 parent->bounds().height() + 100)); 1390 parent->bounds().height() + 100));
1403 scroll_layer->set_did_scroll_callback(base::Bind( 1391 scroll_layer->set_did_scroll_callback(base::Bind(
1404 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); 1392 &FakeLayerScrollClient::DidScroll, base::Unretained(client)));
1405 client->owner_ = this; 1393 client->owner_ = this;
1406 client->layer_ = scroll_layer.get(); 1394 client->layer_ = scroll_layer.get();
(...skipping 21 matching lines...) Expand all
1428 RunTest(CompositorMode::THREADED, false); 1416 RunTest(CompositorMode::THREADED, false);
1429 } 1417 }
1430 1418
1431 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1419 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1432 scroll_destroy_whole_tree_ = true; 1420 scroll_destroy_whole_tree_ = true;
1433 RunTest(CompositorMode::THREADED, false); 1421 RunTest(CompositorMode::THREADED, false);
1434 } 1422 }
1435 1423
1436 } // namespace 1424 } // namespace
1437 } // namespace cc 1425 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698