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

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

Issue 458153002: cc: Use impl-side painting code in LTH scroll layer test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use PictureLayer instead of Fake. Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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"
10 #include "cc/layers/picture_layer.h"
11 #include "cc/test/fake_content_layer_client.h" 11 #include "cc/test/fake_content_layer_client.h"
12 #include "cc/test/fake_layer_tree_host_client.h" 12 #include "cc/test/fake_layer_tree_host_client.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
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_ = PictureLayer::Create(&fake_content_layer_client_);
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_ = PictureLayer::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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 554 }
555 555
556 EXPECT_VECTOR_EQ(gfx::Vector2d(), root_impl->ScrollDelta()); 556 EXPECT_VECTOR_EQ(gfx::Vector2d(), root_impl->ScrollDelta());
557 EXPECT_VECTOR_EQ(gfx::Vector2d(), 557 EXPECT_VECTOR_EQ(gfx::Vector2d(),
558 expected_no_scroll_layer_impl->ScrollDelta()); 558 expected_no_scroll_layer_impl->ScrollDelta());
559 559
560 // Ensure device scale factor is affecting the layers. 560 // Ensure device scale factor is affecting the layers.
561 gfx::Size expected_content_bounds = gfx::ToCeiledSize( 561 gfx::Size expected_content_bounds = gfx::ToCeiledSize(
562 gfx::ScaleSize(root_scroll_layer_impl->bounds(), device_scale_factor_)); 562 gfx::ScaleSize(root_scroll_layer_impl->bounds(), device_scale_factor_));
563 EXPECT_SIZE_EQ(expected_content_bounds, 563 EXPECT_SIZE_EQ(expected_content_bounds,
564 root_scroll_layer_->content_bounds()); 564 root_scroll_layer_->content_bounds());
danakj 2014/08/11 16:22:34 Picture layer's content bounds don't change like T
sohanjg 2014/08/12 10:57:30 I hope u mean to make root_scroll_layer_impl a Fak
565 565
566 expected_content_bounds = gfx::ToCeiledSize( 566 expected_content_bounds = gfx::ToCeiledSize(
567 gfx::ScaleSize(child_layer_impl->bounds(), device_scale_factor_)); 567 gfx::ScaleSize(child_layer_impl->bounds(), device_scale_factor_));
568 EXPECT_SIZE_EQ(expected_content_bounds, child_layer_->content_bounds()); 568 EXPECT_SIZE_EQ(expected_content_bounds, child_layer_->content_bounds());
569 569
570 switch (impl->active_tree()->source_frame_number()) { 570 switch (impl->active_tree()->source_frame_number()) {
571 case 0: { 571 case 0: {
572 // Gesture scroll on impl thread. 572 // Gesture scroll on impl thread.
573 InputHandler::ScrollStatus status = impl->ScrollBegin( 573 InputHandler::ScrollStatus status = impl->ScrollBegin(
574 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() - 574 gfx::ToCeiledPoint(expected_scroll_layer_impl->position() -
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<PictureLayer> scroll_layer =
1208 ContentLayer::Create(&fake_content_layer_client_); 1208 PictureLayer::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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698