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

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

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove content_bounds() usage, fix unit test. Created 6 years, 11 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 settings->layer_transforms_should_scale_layer_contents = true; 385 settings->layer_transforms_should_scale_layer_contents = true;
386 } 386 }
387 387
388 virtual void SetupTree() OVERRIDE { 388 virtual void SetupTree() OVERRIDE {
389 root_layer_ = Layer::Create(); 389 root_layer_ = Layer::Create();
390 root_layer_->SetBounds(gfx::Size(10, 20)); 390 root_layer_->SetBounds(gfx::Size(10, 20));
391 391
392 bool paint_scrollbar = true; 392 bool paint_scrollbar = true;
393 bool has_thumb = false; 393 bool has_thumb = false;
394 scrollbar_ = FakePaintedScrollbarLayer::Create( 394 scrollbar_ = FakePaintedScrollbarLayer::Create(
395 paint_scrollbar, has_thumb, root_layer_->id()); 395 paint_scrollbar, has_thumb, root_layer_.get());
396 scrollbar_->SetPosition(gfx::Point(0, 10)); 396 scrollbar_->SetPosition(gfx::Point(0, 10));
397 scrollbar_->SetBounds(gfx::Size(10, 10)); 397 scrollbar_->SetBounds(gfx::Size(10, 10));
398 398
399 root_layer_->AddChild(scrollbar_); 399 root_layer_->AddChild(scrollbar_);
400 400
401 layer_tree_host()->SetRootLayer(root_layer_); 401 layer_tree_host()->SetRootLayer(root_layer_);
402 LayerTreeHostTest::SetupTree(); 402 LayerTreeHostTest::SetupTree();
403 } 403 }
404 404
405 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 405 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1127
1128 if (layer_tree_host()->settings().impl_side_painting) { 1128 if (layer_tree_host()->settings().impl_side_painting) {
1129 scoped_refptr<FakePictureLayer> layer = 1129 scoped_refptr<FakePictureLayer> layer =
1130 FakePictureLayer::Create(&client_); 1130 FakePictureLayer::Create(&client_);
1131 layer->set_always_update_resources(true); 1131 layer->set_always_update_resources(true);
1132 scroll_layer_ = layer; 1132 scroll_layer_ = layer;
1133 } else { 1133 } else {
1134 scroll_layer_ = FakeContentLayer::Create(&client_); 1134 scroll_layer_ = FakeContentLayer::Create(&client_);
1135 } 1135 }
1136 1136
1137 scroll_layer_->SetScrollable(true); 1137 Layer* root_layer = layer_tree_host()->root_layer();
1138 scroll_layer_->SetScrollClipLayer(root_layer);
1139 scroll_layer_->SetIsContainerForFixedPositionLayers(true);
1140 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(),
1141 2 * root_layer->bounds().height()));
1138 scroll_layer_->SetScrollOffset(gfx::Vector2d()); 1142 scroll_layer_->SetScrollOffset(gfx::Vector2d());
1139 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 1143 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
1144 // This test requires the page_scale and inner viewport layers to be
1145 // identified.
1146 layer_tree_host()->RegisterViewportLayers(
1147 root_layer, scroll_layer_.get(), NULL);
1140 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); 1148 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f);
1141 } 1149 }
1142 1150
1143 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 1151 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
1144 1152
1145 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, 1153 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta,
1146 float scale) OVERRIDE { 1154 float scale) OVERRIDE {
1147 gfx::Vector2d offset = scroll_layer_->scroll_offset(); 1155 gfx::Vector2d offset = scroll_layer_->scroll_offset();
1148 scroll_layer_->SetScrollOffset(offset + scroll_delta); 1156 scroll_layer_->SetScrollOffset(offset + scroll_delta);
1149 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); 1157 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; 1446 settings->scrollbar_animator = LayerTreeSettings::NoAnimator;
1439 } 1447 }
1440 1448
1441 virtual void SetupTree() OVERRIDE { 1449 virtual void SetupTree() OVERRIDE {
1442 layer_ = FakeContentLayer::Create(&client_); 1450 layer_ = FakeContentLayer::Create(&client_);
1443 layer_->SetBounds(gfx::Size(10, 20)); 1451 layer_->SetBounds(gfx::Size(10, 20));
1444 1452
1445 bool paint_scrollbar = true; 1453 bool paint_scrollbar = true;
1446 bool has_thumb = false; 1454 bool has_thumb = false;
1447 scrollbar_ = FakePaintedScrollbarLayer::Create( 1455 scrollbar_ = FakePaintedScrollbarLayer::Create(
1448 paint_scrollbar, has_thumb, layer_->id()); 1456 paint_scrollbar, has_thumb, layer_);
1449 scrollbar_->SetPosition(gfx::Point(0, 10)); 1457 scrollbar_->SetPosition(gfx::Point(0, 10));
1450 scrollbar_->SetBounds(gfx::Size(10, 10)); 1458 scrollbar_->SetBounds(gfx::Size(10, 10));
1451 1459
1452 layer_->AddChild(scrollbar_); 1460 layer_->AddChild(scrollbar_);
1453 1461
1454 layer_tree_host()->SetRootLayer(layer_); 1462 layer_tree_host()->SetRootLayer(layer_);
1455 LayerTreeHostTest::SetupTree(); 1463 LayerTreeHostTest::SetupTree();
1456 } 1464 }
1457 1465
1458 virtual void BeginTest() OVERRIDE { 1466 virtual void BeginTest() OVERRIDE {
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3653 protected: 3661 protected:
3654 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3662 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
3655 3663
3656 virtual void SetupTree() OVERRIDE { 3664 virtual void SetupTree() OVERRIDE {
3657 root_ = Layer::Create(); 3665 root_ = Layer::Create();
3658 root_->SetBounds(gfx::Size(1, 1)); 3666 root_->SetBounds(gfx::Size(1, 1));
3659 3667
3660 bool paint_scrollbar = true; 3668 bool paint_scrollbar = true;
3661 bool has_thumb = false; 3669 bool has_thumb = false;
3662 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( 3670 scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
3663 paint_scrollbar, has_thumb, root_->id()); 3671 paint_scrollbar, has_thumb, root_.get());
3664 3672
3665 root_->AddChild(scrollbar_layer_); 3673 root_->AddChild(scrollbar_layer_);
3666 3674
3667 layer_tree_host()->SetRootLayer(root_); 3675 layer_tree_host()->SetRootLayer(root_);
3668 LayerTreeHostTest::SetupTree(); 3676 LayerTreeHostTest::SetupTree();
3669 } 3677 }
3670 3678
3671 virtual void DidCommitAndDrawFrame() OVERRIDE { 3679 virtual void DidCommitAndDrawFrame() OVERRIDE {
3672 switch (layer_tree_host()->source_frame_number()) { 3680 switch (layer_tree_host()->source_frame_number()) {
3673 case 0: 3681 case 0:
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4947 4955
4948 EndTest(); 4956 EndTest();
4949 } 4957 }
4950 4958
4951 virtual void AfterTest() OVERRIDE {} 4959 virtual void AfterTest() OVERRIDE {}
4952 }; 4960 };
4953 4961
4954 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); 4962 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor);
4955 4963
4956 } // namespace cc 4964 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698