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

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

Issue 2860293002: Change cc::ElementId to be a uint64_t (Closed)
Patch Set: none Created 3 years, 7 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/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 scroll_amount_(2, -1), 562 scroll_amount_(2, -1),
563 num_scrolls_(0) {} 563 num_scrolls_(0) {}
564 564
565 void SetupTree() override { 565 void SetupTree() override {
566 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); 566 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
567 567
568 scoped_refptr<Layer> root_layer = Layer::Create(); 568 scoped_refptr<Layer> root_layer = Layer::Create();
569 root_layer->SetBounds(gfx::Size(10, 10)); 569 root_layer->SetBounds(gfx::Size(10, 10));
570 570
571 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); 571 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
572 root_scroll_layer_->SetElementId( 572 ElementId element_id;
573 LayerIdToElementIdForTesting(root_scroll_layer_->id())); 573 element_id.id = root_scroll_layer_->id();
574 root_scroll_layer_->SetElementId(element_id);
574 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); 575 root_scroll_layer_->SetBounds(gfx::Size(110, 110));
575 root_scroll_layer_->SetPosition(gfx::PointF()); 576 root_scroll_layer_->SetPosition(gfx::PointF());
576 root_scroll_layer_->SetIsDrawable(true); 577 root_scroll_layer_->SetIsDrawable(true);
577 578
578 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_, 579 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_,
579 root_layer->bounds(), root_layer->bounds(), 580 root_layer->bounds(), root_layer->bounds(),
580 layer_tree_host()); 581 layer_tree_host());
581 582
582 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); 583 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_);
583 child_layer_->set_did_scroll_callback( 584 child_layer_->set_did_scroll_callback(
584 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, 585 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll,
585 base::Unretained(this))); 586 base::Unretained(this)));
586 child_layer_->SetElementId( 587 element_id.id = child_layer_->id();
587 LayerIdToElementIdForTesting(child_layer_->id())); 588 child_layer_->SetElementId(element_id);
588 child_layer_->SetBounds(gfx::Size(110, 110)); 589 child_layer_->SetBounds(gfx::Size(110, 110));
589 590
590 if (scroll_child_layer_) { 591 if (scroll_child_layer_) {
591 // Scrolls on the child layer will happen at 5, 5. If they are treated 592 // Scrolls on the child layer will happen at 5, 5. If they are treated
592 // like device pixels, and device scale factor is 2, then they will 593 // like device pixels, and device scale factor is 2, then they will
593 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. 594 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer.
594 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); 595 child_layer_->SetPosition(gfx::PointF(5.f, 5.f));
595 } else { 596 } else {
596 // Adjust the child layer horizontally so that scrolls will never hit it. 597 // Adjust the child layer horizontally so that scrolls will never hit it.
597 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); 598 child_layer_->SetPosition(gfx::PointF(60.f, 5.f));
598 } 599 }
599 600
600 scoped_refptr<Layer> outer_container_layer = 601 scoped_refptr<Layer> outer_container_layer =
601 layer_tree_host()->outer_viewport_scroll_layer()->parent(); 602 layer_tree_host()->outer_viewport_scroll_layer()->parent();
602 603
603 child_layer_->SetIsDrawable(true); 604 child_layer_->SetIsDrawable(true);
604 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); 605 child_layer_->SetScrollClipLayerId(outer_container_layer->id());
605 child_layer_->SetElementId( 606 element_id.id = child_layer_->id();
606 LayerIdToElementIdForTesting(child_layer_->id())); 607 child_layer_->SetElementId(element_id);
607 child_layer_->SetBounds(root_scroll_layer_->bounds()); 608 child_layer_->SetBounds(root_scroll_layer_->bounds());
608 root_scroll_layer_->AddChild(child_layer_); 609 root_scroll_layer_->AddChild(child_layer_);
609 610
610 if (scroll_child_layer_) { 611 if (scroll_child_layer_) {
611 expected_scroll_layer_ = child_layer_; 612 expected_scroll_layer_ = child_layer_;
612 expected_no_scroll_layer_ = root_scroll_layer_; 613 expected_no_scroll_layer_ = root_scroll_layer_;
613 } else { 614 } else {
614 expected_scroll_layer_ = root_scroll_layer_; 615 expected_scroll_layer_ = root_scroll_layer_;
615 expected_no_scroll_layer_ = child_layer_; 616 expected_no_scroll_layer_ = child_layer_;
616 } 617 }
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 Layer* layer_; 1434 Layer* layer_;
1434 }; 1435 };
1435 1436
1436 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { 1437 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
1437 scoped_refptr<PictureLayer> scroll_layer = 1438 scoped_refptr<PictureLayer> scroll_layer =
1438 PictureLayer::Create(&fake_content_layer_client_); 1439 PictureLayer::Create(&fake_content_layer_client_);
1439 scroll_layer->SetBounds(gfx::Size(110, 110)); 1440 scroll_layer->SetBounds(gfx::Size(110, 110));
1440 scroll_layer->SetPosition(gfx::PointF()); 1441 scroll_layer->SetPosition(gfx::PointF());
1441 scroll_layer->SetIsDrawable(true); 1442 scroll_layer->SetIsDrawable(true);
1442 scroll_layer->SetScrollClipLayerId(parent->id()); 1443 scroll_layer->SetScrollClipLayerId(parent->id());
1443 scroll_layer->SetElementId( 1444 ElementId element_id;
1444 LayerIdToElementIdForTesting(scroll_layer->id())); 1445 element_id.id = scroll_layer->id();
1446 scroll_layer->SetElementId(element_id);
1445 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, 1447 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100,
1446 parent->bounds().height() + 100)); 1448 parent->bounds().height() + 100));
1447 scroll_layer->set_did_scroll_callback(base::Bind( 1449 scroll_layer->set_did_scroll_callback(base::Bind(
1448 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); 1450 &FakeLayerScrollClient::DidScroll, base::Unretained(client)));
1449 client->owner_ = this; 1451 client->owner_ = this;
1450 client->layer_ = scroll_layer.get(); 1452 client->layer_ = scroll_layer.get();
1451 parent->AddChild(scroll_layer); 1453 parent->AddChild(scroll_layer);
1452 return scroll_layer.get(); 1454 return scroll_layer.get();
1453 } 1455 }
1454 1456
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
2260 CompletionEvent* impl_side_invalidation_event_ = nullptr; 2262 CompletionEvent* impl_side_invalidation_event_ = nullptr;
2261 2263
2262 // Main thread. 2264 // Main thread.
2263 int num_of_deltas_ = 0; 2265 int num_of_deltas_ = 0;
2264 }; 2266 };
2265 2267
2266 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplSideInvalidation); 2268 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplSideInvalidation);
2267 2269
2268 } // namespace 2270 } // namespace
2269 } // namespace cc 2271 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698