| OLD | NEW |
| 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 455 |
| 456 void SetupTree() override { | 456 void SetupTree() override { |
| 457 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 457 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
| 458 | 458 |
| 459 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); | 459 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); |
| 460 root_layer->SetBounds(gfx::Size(10, 10)); | 460 root_layer->SetBounds(gfx::Size(10, 10)); |
| 461 | 461 |
| 462 root_scroll_layer_ = | 462 root_scroll_layer_ = |
| 463 FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_); | 463 FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_); |
| 464 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); | 464 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); |
| 465 root_scroll_layer_->SetPosition(gfx::Point()); | 465 root_scroll_layer_->SetPosition(gfx::PointF()); |
| 466 root_scroll_layer_->SetIsDrawable(true); | 466 root_scroll_layer_->SetIsDrawable(true); |
| 467 | 467 |
| 468 CreateVirtualViewportLayers(root_layer.get(), | 468 CreateVirtualViewportLayers(root_layer.get(), |
| 469 root_scroll_layer_, | 469 root_scroll_layer_, |
| 470 root_layer->bounds(), | 470 root_layer->bounds(), |
| 471 root_layer->bounds(), | 471 root_layer->bounds(), |
| 472 layer_tree_host(), | 472 layer_tree_host(), |
| 473 layer_settings()); | 473 layer_settings()); |
| 474 | 474 |
| 475 | 475 |
| 476 child_layer_ = | 476 child_layer_ = |
| 477 FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_); | 477 FakePictureLayer::Create(layer_settings(), &fake_content_layer_client_); |
| 478 child_layer_->set_did_scroll_callback( | 478 child_layer_->set_did_scroll_callback( |
| 479 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, | 479 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, |
| 480 base::Unretained(this))); | 480 base::Unretained(this))); |
| 481 child_layer_->SetBounds(gfx::Size(110, 110)); | 481 child_layer_->SetBounds(gfx::Size(110, 110)); |
| 482 | 482 |
| 483 if (scroll_child_layer_) { | 483 if (scroll_child_layer_) { |
| 484 // Scrolls on the child layer will happen at 5, 5. If they are treated | 484 // Scrolls on the child layer will happen at 5, 5. If they are treated |
| 485 // like device pixels, and device scale factor is 2, then they will | 485 // like device pixels, and device scale factor is 2, then they will |
| 486 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. | 486 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. |
| 487 child_layer_->SetPosition(gfx::Point(5, 5)); | 487 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); |
| 488 } else { | 488 } else { |
| 489 // Adjust the child layer horizontally so that scrolls will never hit it. | 489 // Adjust the child layer horizontally so that scrolls will never hit it. |
| 490 child_layer_->SetPosition(gfx::Point(60, 5)); | 490 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); |
| 491 } | 491 } |
| 492 | 492 |
| 493 scoped_refptr<Layer> outer_container_layer = | 493 scoped_refptr<Layer> outer_container_layer = |
| 494 layer_tree_host()->outer_viewport_scroll_layer()->parent(); | 494 layer_tree_host()->outer_viewport_scroll_layer()->parent(); |
| 495 | 495 |
| 496 child_layer_->SetIsDrawable(true); | 496 child_layer_->SetIsDrawable(true); |
| 497 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); | 497 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); |
| 498 child_layer_->SetBounds(root_scroll_layer_->bounds()); | 498 child_layer_->SetBounds(root_scroll_layer_->bounds()); |
| 499 root_scroll_layer_->AddChild(child_layer_); | 499 root_scroll_layer_->AddChild(child_layer_); |
| 500 | 500 |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 owner_->DidScroll(layer_); | 1188 owner_->DidScroll(layer_); |
| 1189 } | 1189 } |
| 1190 LayerTreeHostScrollTestLayerStructureChange* owner_; | 1190 LayerTreeHostScrollTestLayerStructureChange* owner_; |
| 1191 Layer* layer_; | 1191 Layer* layer_; |
| 1192 }; | 1192 }; |
| 1193 | 1193 |
| 1194 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { | 1194 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { |
| 1195 scoped_refptr<PictureLayer> scroll_layer = | 1195 scoped_refptr<PictureLayer> scroll_layer = |
| 1196 PictureLayer::Create(layer_settings(), &fake_content_layer_client_); | 1196 PictureLayer::Create(layer_settings(), &fake_content_layer_client_); |
| 1197 scroll_layer->SetBounds(gfx::Size(110, 110)); | 1197 scroll_layer->SetBounds(gfx::Size(110, 110)); |
| 1198 scroll_layer->SetPosition(gfx::Point(0, 0)); | 1198 scroll_layer->SetPosition(gfx::PointF()); |
| 1199 scroll_layer->SetIsDrawable(true); | 1199 scroll_layer->SetIsDrawable(true); |
| 1200 scroll_layer->SetScrollClipLayerId(parent->id()); | 1200 scroll_layer->SetScrollClipLayerId(parent->id()); |
| 1201 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, | 1201 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, |
| 1202 parent->bounds().height() + 100)); | 1202 parent->bounds().height() + 100)); |
| 1203 scroll_layer->set_did_scroll_callback(base::Bind( | 1203 scroll_layer->set_did_scroll_callback(base::Bind( |
| 1204 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); | 1204 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); |
| 1205 client->owner_ = this; | 1205 client->owner_ = this; |
| 1206 client->layer_ = scroll_layer.get(); | 1206 client->layer_ = scroll_layer.get(); |
| 1207 parent->AddChild(scroll_layer); | 1207 parent->AddChild(scroll_layer); |
| 1208 return scroll_layer.get(); | 1208 return scroll_layer.get(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1221 RunTest(true, false); | 1221 RunTest(true, false); |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1224 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
| 1225 scroll_destroy_whole_tree_ = true; | 1225 scroll_destroy_whole_tree_ = true; |
| 1226 RunTest(true, false); | 1226 RunTest(true, false); |
| 1227 } | 1227 } |
| 1228 | 1228 |
| 1229 } // namespace | 1229 } // namespace |
| 1230 } // namespace cc | 1230 } // namespace cc |
| OLD | NEW |