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

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

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 years, 9 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
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/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/layers/solid_color_layer.h" 11 #include "cc/layers/solid_color_layer.h"
12 #include "cc/test/fake_content_layer_client.h" 12 #include "cc/test/fake_content_layer_client.h"
13 #include "cc/test/fake_painted_scrollbar_layer.h" 13 #include "cc/test/fake_painted_scrollbar_layer.h"
14 #include "cc/test/fake_picture_layer.h" 14 #include "cc/test/fake_picture_layer.h"
15 #include "cc/test/layer_tree_test.h" 15 #include "cc/test/layer_tree_test.h"
16 #include "cc/trees/damage_tracker.h" 16 #include "cc/trees/damage_tracker.h"
17 #include "cc/trees/layer_tree_impl.h" 17 #include "cc/trees/layer_tree_impl.h"
18 18
19 namespace cc { 19 namespace cc {
20 namespace { 20 namespace {
21 21
22 // These tests deal with damage tracking. 22 // These tests deal with damage tracking.
23 class LayerTreeHostDamageTest : public LayerTreeTest {}; 23 class LayerTreeHostDamageTest : public LayerTreeTest {};
24 24
25 // LayerTreeHost::SetNeedsRedraw should damage the whole viewport. 25 // LayerTreeHost::SetNeedsRedraw should damage the whole viewport.
26 class LayerTreeHostDamageTestSetNeedsRedraw 26 class LayerTreeHostDamageTestSetNeedsRedraw
27 : public LayerTreeHostDamageTest { 27 : public LayerTreeHostDamageTest {
28 void SetupTree() override { 28 void SetupTree() override {
29 // Viewport is 10x10. 29 // Viewport is 10x10.
30 scoped_refptr<FakePictureLayer> root = 30 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_);
31 FakePictureLayer::Create(layer_settings(), &client_);
32 root->SetBounds(gfx::Size(10, 10)); 31 root->SetBounds(gfx::Size(10, 10));
33 32
34 layer_tree_host()->SetRootLayer(root); 33 layer_tree_host()->SetRootLayer(root);
35 LayerTreeHostDamageTest::SetupTree(); 34 LayerTreeHostDamageTest::SetupTree();
36 client_.set_bounds(root->bounds()); 35 client_.set_bounds(root->bounds());
37 } 36 }
38 37
39 void BeginTest() override { 38 void BeginTest() override {
40 draw_count_ = 0; 39 draw_count_ = 0;
41 PostSetNeedsCommitToMainThread(); 40 PostSetNeedsCommitToMainThread();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 FakeContentLayerClient client_; 82 FakeContentLayerClient client_;
84 }; 83 };
85 84
86 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetNeedsRedraw); 85 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestSetNeedsRedraw);
87 86
88 // LayerTreeHost::SetViewportSize should damage the whole viewport. 87 // LayerTreeHost::SetViewportSize should damage the whole viewport.
89 class LayerTreeHostDamageTestSetViewportSize 88 class LayerTreeHostDamageTestSetViewportSize
90 : public LayerTreeHostDamageTest { 89 : public LayerTreeHostDamageTest {
91 void SetupTree() override { 90 void SetupTree() override {
92 // Viewport is 10x10. 91 // Viewport is 10x10.
93 scoped_refptr<FakePictureLayer> root = 92 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_);
94 FakePictureLayer::Create(layer_settings(), &client_);
95 root->SetBounds(gfx::Size(10, 10)); 93 root->SetBounds(gfx::Size(10, 10));
96 94
97 layer_tree_host()->SetRootLayer(root); 95 layer_tree_host()->SetRootLayer(root);
98 LayerTreeHostDamageTest::SetupTree(); 96 LayerTreeHostDamageTest::SetupTree();
99 client_.set_bounds(root->bounds()); 97 client_.set_bounds(root->bounds());
100 } 98 }
101 99
102 void BeginTest() override { 100 void BeginTest() override {
103 draw_count_ = 0; 101 draw_count_ = 0;
104 PostSetNeedsCommitToMainThread(); 102 PostSetNeedsCommitToMainThread();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 class LayerTreeHostDamageTestNoDamageDoesNotSwap 149 class LayerTreeHostDamageTestNoDamageDoesNotSwap
152 : public LayerTreeHostDamageTest { 150 : public LayerTreeHostDamageTest {
153 void BeginTest() override { 151 void BeginTest() override {
154 expect_swap_and_succeed_ = 0; 152 expect_swap_and_succeed_ = 0;
155 did_swaps_ = 0; 153 did_swaps_ = 0;
156 did_swap_and_succeed_ = 0; 154 did_swap_and_succeed_ = 0;
157 PostSetNeedsCommitToMainThread(); 155 PostSetNeedsCommitToMainThread();
158 } 156 }
159 157
160 void SetupTree() override { 158 void SetupTree() override {
161 scoped_refptr<FakePictureLayer> root = 159 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_);
162 FakePictureLayer::Create(layer_settings(), &client_);
163 root->SetBounds(gfx::Size(10, 10)); 160 root->SetBounds(gfx::Size(10, 10));
164 161
165 // Most of the layer isn't visible. 162 // Most of the layer isn't visible.
166 content_ = FakePictureLayer::Create(layer_settings(), &client_); 163 content_ = FakePictureLayer::Create(&client_);
167 content_->SetBounds(gfx::Size(2000, 100)); 164 content_->SetBounds(gfx::Size(2000, 100));
168 root->AddChild(content_); 165 root->AddChild(content_);
169 166
170 layer_tree_host()->SetRootLayer(root); 167 layer_tree_host()->SetRootLayer(root);
171 LayerTreeHostDamageTest::SetupTree(); 168 LayerTreeHostDamageTest::SetupTree();
172 client_.set_bounds(root->bounds()); 169 client_.set_bounds(root->bounds());
173 } 170 }
174 171
175 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, 172 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl,
176 LayerTreeHostImpl::FrameData* frame_data, 173 LayerTreeHostImpl::FrameData* frame_data,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 int did_swaps_; 234 int did_swaps_;
238 int did_swap_and_succeed_; 235 int did_swap_and_succeed_;
239 }; 236 };
240 237
241 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageDoesNotSwap); 238 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageDoesNotSwap);
242 239
243 class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest { 240 class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest {
244 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 241 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
245 242
246 void SetupTree() override { 243 void SetupTree() override {
247 root_ = FakePictureLayer::Create(layer_settings(), &client_); 244 root_ = FakePictureLayer::Create(&client_);
248 child_ = FakePictureLayer::Create(layer_settings(), &client_); 245 child_ = FakePictureLayer::Create(&client_);
249 246
250 root_->SetBounds(gfx::Size(500, 500)); 247 root_->SetBounds(gfx::Size(500, 500));
251 child_->SetPosition(gfx::PointF(100.f, 100.f)); 248 child_->SetPosition(gfx::PointF(100.f, 100.f));
252 child_->SetBounds(gfx::Size(30, 30)); 249 child_->SetBounds(gfx::Size(30, 30));
253 250
254 root_->AddChild(child_); 251 root_->AddChild(child_);
255 layer_tree_host()->SetRootLayer(root_); 252 layer_tree_host()->SetRootLayer(root_);
256 LayerTreeHostDamageTest::SetupTree(); 253 LayerTreeHostDamageTest::SetupTree();
257 client_.set_bounds(root_->bounds()); 254 client_.set_bounds(root_->bounds());
258 } 255 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 FakeContentLayerClient client_; 325 FakeContentLayerClient client_;
329 scoped_refptr<FakePictureLayer> root_; 326 scoped_refptr<FakePictureLayer> root_;
330 scoped_refptr<FakePictureLayer> child_; 327 scoped_refptr<FakePictureLayer> child_;
331 gfx::Rect child_damage_rect_; 328 gfx::Rect child_damage_rect_;
332 }; 329 };
333 330
334 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestForcedFullDamage); 331 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestForcedFullDamage);
335 332
336 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { 333 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest {
337 void SetupTree() override { 334 void SetupTree() override {
338 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); 335 scoped_refptr<Layer> root_layer = Layer::Create();
339 root_layer->SetBounds(gfx::Size(400, 400)); 336 root_layer->SetBounds(gfx::Size(400, 400));
340 root_layer->SetMasksToBounds(true); 337 root_layer->SetMasksToBounds(true);
341 layer_tree_host()->SetRootLayer(root_layer); 338 layer_tree_host()->SetRootLayer(root_layer);
342 339
343 scoped_refptr<Layer> scroll_clip_layer = Layer::Create(layer_settings()); 340 scoped_refptr<Layer> scroll_clip_layer = Layer::Create();
344 scoped_refptr<Layer> content_layer = 341 scoped_refptr<Layer> content_layer = FakePictureLayer::Create(&client_);
345 FakePictureLayer::Create(layer_settings(), &client_);
346 content_layer->SetScrollClipLayerId(scroll_clip_layer->id()); 342 content_layer->SetScrollClipLayerId(scroll_clip_layer->id());
347 content_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); 343 content_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
348 content_layer->SetBounds(gfx::Size(100, 200)); 344 content_layer->SetBounds(gfx::Size(100, 200));
349 content_layer->SetIsDrawable(true); 345 content_layer->SetIsDrawable(true);
350 scroll_clip_layer->SetBounds( 346 scroll_clip_layer->SetBounds(
351 gfx::Size(content_layer->bounds().width() - 30, 347 gfx::Size(content_layer->bounds().width() - 30,
352 content_layer->bounds().height() - 50)); 348 content_layer->bounds().height() - 50));
353 scroll_clip_layer->AddChild(content_layer); 349 scroll_clip_layer->AddChild(content_layer);
354 root_layer->AddChild(scroll_clip_layer); 350 root_layer->AddChild(scroll_clip_layer);
355 351
356 scoped_refptr<Layer> scrollbar_layer = FakePaintedScrollbarLayer::Create( 352 scoped_refptr<Layer> scrollbar_layer =
357 layer_settings(), false, true, content_layer->id()); 353 FakePaintedScrollbarLayer::Create(false, true, content_layer->id());
358 scrollbar_layer->SetPosition(gfx::PointF(300.f, 300.f)); 354 scrollbar_layer->SetPosition(gfx::PointF(300.f, 300.f));
359 scrollbar_layer->SetBounds(gfx::Size(10, 100)); 355 scrollbar_layer->SetBounds(gfx::Size(10, 100));
360 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(content_layer->id()); 356 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(content_layer->id());
361 root_layer->AddChild(scrollbar_layer); 357 root_layer->AddChild(scrollbar_layer);
362 358
363 gfx::RectF content_rect(content_layer->position(), 359 gfx::RectF content_rect(content_layer->position(),
364 gfx::SizeF(content_layer->bounds())); 360 gfx::SizeF(content_layer->bounds()));
365 gfx::RectF scrollbar_rect(scrollbar_layer->position(), 361 gfx::RectF scrollbar_rect(scrollbar_layer->position(),
366 gfx::SizeF(scrollbar_layer->bounds())); 362 gfx::SizeF(scrollbar_layer->bounds()));
367 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); 363 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect));
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 529
534 void AfterTest() override { EXPECT_EQ(3, did_swaps_); } 530 void AfterTest() override { EXPECT_EQ(3, did_swaps_); }
535 531
536 int did_swaps_; 532 int did_swaps_;
537 }; 533 };
538 534
539 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); 535 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage);
540 536
541 } // namespace 537 } // namespace
542 } // namespace cc 538 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698