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/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "cc/layers/content_layer.h" | |
9 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
10 #include "cc/layers/layer_impl.h" | 9 #include "cc/layers/layer_impl.h" |
11 #include "cc/test/fake_content_layer_client.h" | 10 #include "cc/test/fake_content_layer_client.h" |
12 #include "cc/test/fake_layer_tree_host_client.h" | 11 #include "cc/test/fake_layer_tree_host_client.h" |
12 #include "cc/test/fake_picture_layer.h" | |
13 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" |
14 #include "cc/test/layer_tree_test.h" | 14 #include "cc/test/layer_tree_test.h" |
15 #include "cc/test/test_shared_bitmap_manager.h" | 15 #include "cc/test/test_shared_bitmap_manager.h" |
16 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
17 #include "ui/gfx/point_conversions.h" | 17 #include "ui/gfx/point_conversions.h" |
18 #include "ui/gfx/size_conversions.h" | 18 #include "ui/gfx/size_conversions.h" |
19 #include "ui/gfx/vector2d_conversions.h" | 19 #include "ui/gfx/vector2d_conversions.h" |
20 | 20 |
21 namespace cc { | 21 namespace cc { |
22 namespace { | 22 namespace { |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 javascript_scroll_(40, 5), | 442 javascript_scroll_(40, 5), |
443 scroll_amount_(2, -1), | 443 scroll_amount_(2, -1), |
444 num_scrolls_(0) {} | 444 num_scrolls_(0) {} |
445 | 445 |
446 virtual void SetupTree() OVERRIDE { | 446 virtual void SetupTree() OVERRIDE { |
447 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 447 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
448 | 448 |
449 scoped_refptr<Layer> root_layer = Layer::Create(); | 449 scoped_refptr<Layer> root_layer = Layer::Create(); |
450 root_layer->SetBounds(gfx::Size(10, 10)); | 450 root_layer->SetBounds(gfx::Size(10, 10)); |
451 | 451 |
452 root_scroll_layer_ = ContentLayer::Create(&fake_content_layer_client_); | 452 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); |
danakj
2014/08/11 14:12:46
Looks like we don't use anything that FakePictureL
sohanjg
2014/08/11 14:26:42
Done.
| |
453 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); | 453 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); |
454 | 454 |
455 root_scroll_layer_->SetPosition(gfx::Point()); | 455 root_scroll_layer_->SetPosition(gfx::Point()); |
456 | 456 |
457 root_scroll_layer_->SetIsDrawable(true); | 457 root_scroll_layer_->SetIsDrawable(true); |
458 root_scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 458 root_scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
459 root_scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 459 root_scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
460 root_layer->AddChild(root_scroll_layer_); | 460 root_layer->AddChild(root_scroll_layer_); |
461 | 461 |
462 child_layer_ = ContentLayer::Create(&fake_content_layer_client_); | 462 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); |
463 child_layer_->set_did_scroll_callback( | 463 child_layer_->set_did_scroll_callback( |
464 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, | 464 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, |
465 base::Unretained(this))); | 465 base::Unretained(this))); |
466 child_layer_->SetBounds(gfx::Size(110, 110)); | 466 child_layer_->SetBounds(gfx::Size(110, 110)); |
467 | 467 |
468 if (scroll_child_layer_) { | 468 if (scroll_child_layer_) { |
469 // Scrolls on the child layer will happen at 5, 5. If they are treated | 469 // Scrolls on the child layer will happen at 5, 5. If they are treated |
470 // like device pixels, and device scale factor is 2, then they will | 470 // like device pixels, and device scale factor is 2, then they will |
471 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. | 471 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. |
472 child_layer_->SetPosition(gfx::Point(5, 5)); | 472 child_layer_->SetPosition(gfx::Point(5, 5)); |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 class FakeLayerScrollClient { | 1197 class FakeLayerScrollClient { |
1198 public: | 1198 public: |
1199 void DidScroll() { | 1199 void DidScroll() { |
1200 owner_->DidScroll(layer_); | 1200 owner_->DidScroll(layer_); |
1201 } | 1201 } |
1202 LayerTreeHostScrollTestLayerStructureChange* owner_; | 1202 LayerTreeHostScrollTestLayerStructureChange* owner_; |
1203 Layer* layer_; | 1203 Layer* layer_; |
1204 }; | 1204 }; |
1205 | 1205 |
1206 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { | 1206 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { |
1207 scoped_refptr<Layer> scroll_layer = | 1207 scoped_refptr<FakePictureLayer> scroll_layer = |
1208 ContentLayer::Create(&fake_content_layer_client_); | 1208 FakePictureLayer::Create(&fake_content_layer_client_); |
1209 scroll_layer->SetBounds(gfx::Size(110, 110)); | 1209 scroll_layer->SetBounds(gfx::Size(110, 110)); |
1210 scroll_layer->SetPosition(gfx::Point(0, 0)); | 1210 scroll_layer->SetPosition(gfx::Point(0, 0)); |
1211 scroll_layer->SetIsDrawable(true); | 1211 scroll_layer->SetIsDrawable(true); |
1212 scroll_layer->SetScrollClipLayerId(parent->id()); | 1212 scroll_layer->SetScrollClipLayerId(parent->id()); |
1213 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, | 1213 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, |
1214 parent->bounds().height() + 100)); | 1214 parent->bounds().height() + 100)); |
1215 scroll_layer->set_did_scroll_callback(base::Bind( | 1215 scroll_layer->set_did_scroll_callback(base::Bind( |
1216 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); | 1216 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); |
1217 client->owner_ = this; | 1217 client->owner_ = this; |
1218 client->layer_ = scroll_layer.get(); | 1218 client->layer_ = scroll_layer.get(); |
1219 parent->AddChild(scroll_layer); | 1219 parent->AddChild(scroll_layer); |
1220 return scroll_layer.get(); | 1220 return scroll_layer.get(); |
1221 } | 1221 } |
1222 | 1222 |
1223 FakeLayerScrollClient root_scroll_layer_client_; | 1223 FakeLayerScrollClient root_scroll_layer_client_; |
1224 FakeLayerScrollClient sibling_scroll_layer_client_; | 1224 FakeLayerScrollClient sibling_scroll_layer_client_; |
1225 FakeLayerScrollClient child_scroll_layer_client_; | 1225 FakeLayerScrollClient child_scroll_layer_client_; |
1226 | 1226 |
1227 FakeContentLayerClient fake_content_layer_client_; | 1227 FakeContentLayerClient fake_content_layer_client_; |
1228 | 1228 |
1229 bool scroll_destroy_whole_tree_; | 1229 bool scroll_destroy_whole_tree_; |
1230 }; | 1230 }; |
1231 | 1231 |
1232 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyLayer) { | 1232 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyLayer) { |
1233 RunTest(true, false, false); | 1233 RunTest(true, false, true); |
1234 } | 1234 } |
1235 | 1235 |
1236 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { | 1236 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { |
1237 scroll_destroy_whole_tree_ = true; | 1237 scroll_destroy_whole_tree_ = true; |
1238 RunTest(true, false, false); | 1238 RunTest(true, false, true); |
1239 } | 1239 } |
1240 | 1240 |
1241 } // namespace | 1241 } // namespace |
1242 } // namespace cc | 1242 } // namespace cc |
OLD | NEW |