| 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 "cc/test/fake_content_layer.h" | 7 #include "cc/test/fake_content_layer.h" |
| 8 #include "cc/test/fake_content_layer_client.h" | 8 #include "cc/test/fake_content_layer_client.h" |
| 9 #include "cc/test/fake_scrollbar_layer.h" | 9 #include "cc/test/fake_scrollbar_layer.h" |
| 10 #include "cc/test/layer_tree_test.h" | 10 #include "cc/test/layer_tree_test.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 break; | 92 break; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void AfterTest() OVERRIDE { | 96 virtual void AfterTest() OVERRIDE { |
| 97 EXPECT_EQ(4, did_swaps_); | 97 EXPECT_EQ(4, did_swaps_); |
| 98 EXPECT_EQ(2, expect_swap_and_succeed_); | 98 EXPECT_EQ(2, expect_swap_and_succeed_); |
| 99 EXPECT_EQ(expect_swap_and_succeed_, did_swap_and_succeed_); | 99 EXPECT_EQ(expect_swap_and_succeed_, did_swap_and_succeed_); |
| 100 } | 100 } |
| 101 | 101 |
| 102 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 103 settings->max_bytes_pending_upload = 16 * 1024 * 1024; |
| 104 } |
| 105 |
| 102 FakeContentLayerClient client_; | 106 FakeContentLayerClient client_; |
| 103 scoped_refptr<FakeContentLayer> content_; | 107 scoped_refptr<FakeContentLayer> content_; |
| 104 int expect_swap_and_succeed_; | 108 int expect_swap_and_succeed_; |
| 105 int did_swaps_; | 109 int did_swaps_; |
| 106 int did_swap_and_succeed_; | 110 int did_swap_and_succeed_; |
| 107 }; | 111 }; |
| 108 | 112 |
| 109 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageDoesNotSwap); | 113 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageDoesNotSwap); |
| 110 | 114 |
| 111 class LayerTreeHostDamageTestNoDamageReadbackDoesDraw | 115 class LayerTreeHostDamageTestNoDamageReadbackDoesDraw |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 layer_tree_host()->CompositeAndReadback(static_cast<void*>(&pixels), | 170 layer_tree_host()->CompositeAndReadback(static_cast<void*>(&pixels), |
| 167 gfx::Rect(3, 3, 1, 1)); | 171 gfx::Rect(3, 3, 1, 1)); |
| 168 EndTest(); | 172 EndTest(); |
| 169 break; | 173 break; |
| 170 } | 174 } |
| 171 } | 175 } |
| 172 } | 176 } |
| 173 | 177 |
| 174 virtual void AfterTest() OVERRIDE {} | 178 virtual void AfterTest() OVERRIDE {} |
| 175 | 179 |
| 180 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 181 settings->max_bytes_pending_upload = 16 * 1024 * 1024; |
| 182 } |
| 183 |
| 176 FakeContentLayerClient client_; | 184 FakeContentLayerClient client_; |
| 177 scoped_refptr<FakeContentLayer> content_; | 185 scoped_refptr<FakeContentLayer> content_; |
| 178 }; | 186 }; |
| 179 | 187 |
| 180 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageReadbackDoesDraw); | 188 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestNoDamageReadbackDoesDraw); |
| 181 | 189 |
| 182 class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest { | 190 class LayerTreeHostDamageTestForcedFullDamage : public LayerTreeHostDamageTest { |
| 183 virtual void BeginTest() OVERRIDE { | 191 virtual void BeginTest() OVERRIDE { |
| 184 PostSetNeedsCommitToMainThread(); | 192 PostSetNeedsCommitToMainThread(); |
| 185 } | 193 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 layer_tree_host()->SetNeedsCommit(); | 279 layer_tree_host()->SetNeedsCommit(); |
| 272 | 280 |
| 273 if (!child_damage_rect_.IsEmpty()) { | 281 if (!child_damage_rect_.IsEmpty()) { |
| 274 child_->SetNeedsDisplayRect(child_damage_rect_); | 282 child_->SetNeedsDisplayRect(child_damage_rect_); |
| 275 child_damage_rect_ = gfx::RectF(); | 283 child_damage_rect_ = gfx::RectF(); |
| 276 } | 284 } |
| 277 } | 285 } |
| 278 | 286 |
| 279 virtual void AfterTest() OVERRIDE {} | 287 virtual void AfterTest() OVERRIDE {} |
| 280 | 288 |
| 289 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 290 settings->max_bytes_pending_upload = 16 * 1024 * 1024; |
| 291 } |
| 292 |
| 281 FakeContentLayerClient client_; | 293 FakeContentLayerClient client_; |
| 282 scoped_refptr<FakeContentLayer> root_; | 294 scoped_refptr<FakeContentLayer> root_; |
| 283 scoped_refptr<FakeContentLayer> child_; | 295 scoped_refptr<FakeContentLayer> child_; |
| 284 gfx::RectF child_damage_rect_; | 296 gfx::RectF child_damage_rect_; |
| 285 }; | 297 }; |
| 286 | 298 |
| 287 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestForcedFullDamage); | 299 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostDamageTestForcedFullDamage); |
| 288 | 300 |
| 289 class LayerTreeHostDamageTestScrollbarDoesDamage | 301 class LayerTreeHostDamageTestScrollbarDoesDamage |
| 290 : public LayerTreeHostDamageTest { | 302 : public LayerTreeHostDamageTest { |
| 291 virtual void BeginTest() OVERRIDE { | 303 virtual void BeginTest() OVERRIDE { |
| 292 did_swaps_ = 0; | 304 did_swaps_ = 0; |
| 293 PostSetNeedsCommitToMainThread(); | 305 PostSetNeedsCommitToMainThread(); |
| 294 } | 306 } |
| 295 | 307 |
| 296 virtual void SetupTree() OVERRIDE { | 308 virtual void SetupTree() OVERRIDE { |
| 297 scoped_refptr<Layer> root_layer = Layer::Create(); | 309 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 298 root_layer->SetBounds(gfx::Size(400,400)); | 310 root_layer->SetBounds(gfx::Size(400, 400)); |
| 299 layer_tree_host()->SetRootLayer(root_layer); | 311 layer_tree_host()->SetRootLayer(root_layer); |
| 300 | 312 |
| 301 scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_); | 313 scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_); |
| 302 content_layer->SetScrollable(true); | 314 content_layer->SetScrollable(true); |
| 303 content_layer->SetScrollOffset(gfx::Vector2d(10, 20)); | 315 content_layer->SetScrollOffset(gfx::Vector2d(10, 20)); |
| 304 content_layer->SetMaxScrollOffset(gfx::Vector2d(30, 50)); | 316 content_layer->SetMaxScrollOffset(gfx::Vector2d(30, 50)); |
| 305 content_layer->SetBounds(gfx::Size(100, 200)); | 317 content_layer->SetBounds(gfx::Size(100, 200)); |
| 306 root_layer->AddChild(content_layer); | 318 root_layer->AddChild(content_layer); |
| 307 | 319 |
| 308 scoped_refptr<Layer> scrollbar_layer = | 320 scoped_refptr<Layer> scrollbar_layer = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 ++did_swaps_; | 367 ++did_swaps_; |
| 356 EXPECT_TRUE(result); | 368 EXPECT_TRUE(result); |
| 357 LayerImpl* root = host_impl->active_tree()->root_layer(); | 369 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 358 LayerImpl* scroll_layer = root->children()[0]; | 370 LayerImpl* scroll_layer = root->children()[0]; |
| 359 switch (did_swaps_) { | 371 switch (did_swaps_) { |
| 360 case 1: | 372 case 1: |
| 361 // Test that modifying the position of the content layer (not | 373 // Test that modifying the position of the content layer (not |
| 362 // scrolling) won't damage the scrollbar. Do this before the other | 374 // scrolling) won't damage the scrollbar. Do this before the other |
| 363 // tests, as they can cause commits that will later damage the | 375 // tests, as they can cause commits that will later damage the |
| 364 // scrollbar. http://crbug.com/276657 | 376 // scrollbar. http://crbug.com/276657 |
| 365 scroll_layer->SetPosition(gfx::Point(1,1)); | 377 scroll_layer->SetPosition(gfx::Point(1, 1)); |
| 366 scroll_layer->SetScrollOffset(scroll_layer->scroll_offset()); | 378 scroll_layer->SetScrollOffset(scroll_layer->scroll_offset()); |
| 367 host_impl->SetNeedsRedraw(); | 379 host_impl->SetNeedsRedraw(); |
| 368 break; | 380 break; |
| 369 case 2: | 381 case 2: |
| 370 host_impl->ScrollBegin(gfx::Point(1,1), InputHandler::Wheel); | 382 host_impl->ScrollBegin(gfx::Point(1, 1), InputHandler::Wheel); |
| 371 EXPECT_TRUE(host_impl->ScrollBy(gfx::Point(), | 383 EXPECT_TRUE(host_impl->ScrollBy(gfx::Point(), |
| 372 gfx::Vector2dF(10.0, 10.0))); | 384 gfx::Vector2dF(10.0, 10.0))); |
| 373 break; | 385 break; |
| 374 case 3: | 386 case 3: |
| 375 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(60, 100)); | 387 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(60, 100)); |
| 376 host_impl->SetNeedsRedraw(); | 388 host_impl->SetNeedsRedraw(); |
| 377 break; | 389 break; |
| 378 } | 390 } |
| 379 | |
| 380 } | 391 } |
| 381 | 392 |
| 382 virtual void AfterTest() OVERRIDE { | 393 virtual void AfterTest() OVERRIDE { |
| 383 EXPECT_EQ(4, did_swaps_); | 394 EXPECT_EQ(4, did_swaps_); |
| 384 } | 395 } |
| 385 | 396 |
| 397 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 398 settings->max_bytes_pending_upload = 16 * 1024 * 1024; |
| 399 } |
| 400 |
| 386 FakeContentLayerClient client_; | 401 FakeContentLayerClient client_; |
| 387 int did_swaps_; | 402 int did_swaps_; |
| 388 }; | 403 }; |
| 389 | 404 |
| 390 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarDoesDamage); | 405 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarDoesDamage); |
| 391 | 406 |
| 392 } // namespace | 407 } // namespace |
| 393 } // namespace cc | 408 } // namespace cc |
| OLD | NEW |