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

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

Issue 295193002: Get rid of graphics layer anchor points, and replace with transform origin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 6 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 | Annotate | Revision Log
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" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/layers/layer_impl.h" 10 #include "cc/layers/layer_impl.h"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_ = ContentLayer::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 root_scroll_layer_->SetAnchorPoint(gfx::PointF()); 456 root_scroll_layer_->SetTransformOrigin(gfx::Point3F());
457 457
458 root_scroll_layer_->SetIsDrawable(true); 458 root_scroll_layer_->SetIsDrawable(true);
459 root_scroll_layer_->SetScrollClipLayerId(root_layer->id()); 459 root_scroll_layer_->SetScrollClipLayerId(root_layer->id());
460 root_scroll_layer_->SetIsContainerForFixedPositionLayers(true); 460 root_scroll_layer_->SetIsContainerForFixedPositionLayers(true);
461 root_layer->AddChild(root_scroll_layer_); 461 root_layer->AddChild(root_scroll_layer_);
462 462
463 child_layer_ = ContentLayer::Create(&fake_content_layer_client_); 463 child_layer_ = ContentLayer::Create(&fake_content_layer_client_);
464 child_layer_->set_did_scroll_callback( 464 child_layer_->set_did_scroll_callback(
465 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, 465 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll,
466 base::Unretained(this))); 466 base::Unretained(this)));
467 child_layer_->SetBounds(gfx::Size(110, 110)); 467 child_layer_->SetBounds(gfx::Size(110, 110));
468 468
469 if (scroll_child_layer_) { 469 if (scroll_child_layer_) {
470 // Scrolls on the child layer will happen at 5, 5. If they are treated 470 // Scrolls on the child layer will happen at 5, 5. If they are treated
471 // like device pixels, and device scale factor is 2, then they will 471 // like device pixels, and device scale factor is 2, then they will
472 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. 472 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer.
473 child_layer_->SetPosition(gfx::Point(5, 5)); 473 child_layer_->SetPosition(gfx::Point(5, 5));
474 } else { 474 } else {
475 // Adjust the child layer horizontally so that scrolls will never hit it. 475 // Adjust the child layer horizontally so that scrolls will never hit it.
476 child_layer_->SetPosition(gfx::Point(60, 5)); 476 child_layer_->SetPosition(gfx::Point(60, 5));
477 } 477 }
478 child_layer_->SetAnchorPoint(gfx::PointF()); 478 child_layer_->SetTransformOrigin(gfx::Point3F());
479 479
480 child_layer_->SetIsDrawable(true); 480 child_layer_->SetIsDrawable(true);
481 child_layer_->SetScrollClipLayerId(root_layer->id()); 481 child_layer_->SetScrollClipLayerId(root_layer->id());
482 child_layer_->SetBounds(root_scroll_layer_->bounds()); 482 child_layer_->SetBounds(root_scroll_layer_->bounds());
483 root_scroll_layer_->AddChild(child_layer_); 483 root_scroll_layer_->AddChild(child_layer_);
484 484
485 if (scroll_child_layer_) { 485 if (scroll_child_layer_) {
486 expected_scroll_layer_ = child_layer_; 486 expected_scroll_layer_ = child_layer_;
487 expected_no_scroll_layer_ = root_scroll_layer_; 487 expected_no_scroll_layer_ = root_scroll_layer_;
488 } else { 488 } else {
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1202 }
1203 LayerTreeHostScrollTestLayerStructureChange* owner_; 1203 LayerTreeHostScrollTestLayerStructureChange* owner_;
1204 Layer* layer_; 1204 Layer* layer_;
1205 }; 1205 };
1206 1206
1207 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { 1207 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
1208 scoped_refptr<Layer> scroll_layer = 1208 scoped_refptr<Layer> scroll_layer =
1209 ContentLayer::Create(&fake_content_layer_client_); 1209 ContentLayer::Create(&fake_content_layer_client_);
1210 scroll_layer->SetBounds(gfx::Size(110, 110)); 1210 scroll_layer->SetBounds(gfx::Size(110, 110));
1211 scroll_layer->SetPosition(gfx::Point(0, 0)); 1211 scroll_layer->SetPosition(gfx::Point(0, 0));
1212 scroll_layer->SetAnchorPoint(gfx::PointF()); 1212 scroll_layer->SetTransformOrigin(gfx::Point3F());
1213 scroll_layer->SetIsDrawable(true); 1213 scroll_layer->SetIsDrawable(true);
1214 scroll_layer->SetScrollClipLayerId(parent->id()); 1214 scroll_layer->SetScrollClipLayerId(parent->id());
1215 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, 1215 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100,
1216 parent->bounds().height() + 100)); 1216 parent->bounds().height() + 100));
1217 scroll_layer->set_did_scroll_callback(base::Bind( 1217 scroll_layer->set_did_scroll_callback(base::Bind(
1218 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); 1218 &FakeLayerScrollClient::DidScroll, base::Unretained(client)));
1219 client->owner_ = this; 1219 client->owner_ = this;
1220 client->layer_ = scroll_layer.get(); 1220 client->layer_ = scroll_layer.get();
1221 parent->AddChild(scroll_layer); 1221 parent->AddChild(scroll_layer);
1222 return scroll_layer.get(); 1222 return scroll_layer.get();
(...skipping 12 matching lines...) Expand all
1235 RunTest(true, false, false); 1235 RunTest(true, false, false);
1236 } 1236 }
1237 1237
1238 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) { 1238 TEST_F(LayerTreeHostScrollTestLayerStructureChange, ScrollDestroyWholeTree) {
1239 scroll_destroy_whole_tree_ = true; 1239 scroll_destroy_whole_tree_ = true;
1240 RunTest(true, false, false); 1240 RunTest(true, false, false);
1241 } 1241 }
1242 1242
1243 } // namespace 1243 } // namespace
1244 } // namespace cc 1244 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698