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

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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1328 : public LayerTreeHostScrollTest { 1319 : public LayerTreeHostScrollTest {
1329 public: 1320 public:
1330 LayerTreeHostScrollTestLayerStructureChange() 1321 LayerTreeHostScrollTestLayerStructureChange()
1331 : scroll_destroy_whole_tree_(false) {} 1322 : scroll_destroy_whole_tree_(false) {}
1332 1323
1333 void SetupTree() override { 1324 void SetupTree() override {
1334 LayerTreeTest::SetupTree(); 1325 LayerTreeTest::SetupTree();
1335 Layer* root_layer = layer_tree_host()->root_layer(); 1326 Layer* root_layer = layer_tree_host()->root_layer();
1336 root_layer->SetBounds(gfx::Size(10, 10)); 1327 root_layer->SetBounds(gfx::Size(10, 10));
1337 1328
1338 CreateVirtualViewportLayers(root_layer, 1329 CreateVirtualViewportLayers(root_layer, root_layer->bounds(),
1339 root_layer->bounds(), 1330 root_layer->bounds(), root_layer->bounds(),
1340 root_layer->bounds(), 1331 layer_tree_host());
1341 root_layer->bounds(),
1342 layer_tree_host(),
1343 layer_settings());
1344 1332
1345 Layer* outer_scroll_layer = 1333 Layer* outer_scroll_layer =
1346 layer_tree_host()->outer_viewport_scroll_layer(); 1334 layer_tree_host()->outer_viewport_scroll_layer();
1347 1335
1348 Layer* root_scroll_layer = 1336 Layer* root_scroll_layer =
1349 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_); 1337 CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_);
1350 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_); 1338 CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_);
1351 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); 1339 CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_);
1352 fake_content_layer_client_.set_bounds(root_layer->bounds()); 1340 fake_content_layer_client_.set_bounds(root_layer->bounds());
1353 } 1341 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 public: 1375 public:
1388 void DidScroll() { 1376 void DidScroll() {
1389 owner_->DidScroll(layer_); 1377 owner_->DidScroll(layer_);
1390 } 1378 }
1391 LayerTreeHostScrollTestLayerStructureChange* owner_; 1379 LayerTreeHostScrollTestLayerStructureChange* owner_;
1392 Layer* layer_; 1380 Layer* layer_;
1393 }; 1381 };
1394 1382
1395 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { 1383 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
1396 scoped_refptr<PictureLayer> scroll_layer = 1384 scoped_refptr<PictureLayer> scroll_layer =
1397 PictureLayer::Create(layer_settings(), &fake_content_layer_client_); 1385 PictureLayer::Create(&fake_content_layer_client_);
1398 scroll_layer->SetBounds(gfx::Size(110, 110)); 1386 scroll_layer->SetBounds(gfx::Size(110, 110));
1399 scroll_layer->SetPosition(gfx::PointF()); 1387 scroll_layer->SetPosition(gfx::PointF());
1400 scroll_layer->SetIsDrawable(true); 1388 scroll_layer->SetIsDrawable(true);
1401 scroll_layer->SetScrollClipLayerId(parent->id()); 1389 scroll_layer->SetScrollClipLayerId(parent->id());
1402 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, 1390 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100,
1403 parent->bounds().height() + 100)); 1391 parent->bounds().height() + 100));
1404 scroll_layer->set_did_scroll_callback(base::Bind( 1392 scroll_layer->set_did_scroll_callback(base::Bind(
1405 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); 1393 &FakeLayerScrollClient::DidScroll, base::Unretained(client)));
1406 client->owner_ = this; 1394 client->owner_ = this;
1407 client->layer_ = scroll_layer.get(); 1395 client->layer_ = scroll_layer.get();
(...skipping 21 matching lines...) Expand all
1429 RunTest(CompositorMode::THREADED, false); 1417 RunTest(CompositorMode::THREADED, false);
1430 } 1418 }
1431 1419
1432 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1420 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1433 scroll_destroy_whole_tree_ = true; 1421 scroll_destroy_whole_tree_ = true;
1434 RunTest(CompositorMode::THREADED, false); 1422 RunTest(CompositorMode::THREADED, false);
1435 } 1423 }
1436 1424
1437 } // namespace 1425 } // namespace
1438 } // namespace cc 1426 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_proxy.cc ('k') | cc/trees/layer_tree_host_unittest_serialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698