| 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 "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" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | 52 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
| 53 LayerTreeHostImpl::FrameData* frame_data, | 53 LayerTreeHostImpl::FrameData* frame_data, |
| 54 DrawResult draw_result) override { | 54 DrawResult draw_result) override { |
| 55 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 55 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 56 | 56 |
| 57 RenderSurfaceImpl* root_surface = | 57 RenderSurfaceImpl* root_surface = |
| 58 impl->active_tree()->root_layer_for_testing()->render_surface(); | 58 impl->active_tree()->root_layer_for_testing()->render_surface(); |
| 59 gfx::Rect root_damage = | 59 gfx::Rect root_damage = root_surface->damage_tracker()->CurrentDamageRect(); |
| 60 root_surface->damage_tracker()->current_damage_rect(); | |
| 61 | 60 |
| 62 switch (draw_count_) { | 61 switch (draw_count_) { |
| 63 case 0: | 62 case 0: |
| 64 // The first frame has full damage. | 63 // The first frame has full damage. |
| 65 EXPECT_EQ(gfx::Rect(10, 10), root_damage); | 64 EXPECT_EQ(gfx::Rect(10, 10), root_damage); |
| 66 break; | 65 break; |
| 67 case 1: | 66 case 1: |
| 68 // The second frame has full damage. | 67 // The second frame has full damage. |
| 69 EXPECT_EQ(gfx::Rect(10, 10), root_damage); | 68 EXPECT_EQ(gfx::Rect(10, 10), root_damage); |
| 70 EndTest(); | 69 EndTest(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 110 } |
| 112 } | 111 } |
| 113 | 112 |
| 114 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | 113 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
| 115 LayerTreeHostImpl::FrameData* frame_data, | 114 LayerTreeHostImpl::FrameData* frame_data, |
| 116 DrawResult draw_result) override { | 115 DrawResult draw_result) override { |
| 117 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 116 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 118 | 117 |
| 119 RenderSurfaceImpl* root_surface = | 118 RenderSurfaceImpl* root_surface = |
| 120 impl->active_tree()->root_layer_for_testing()->render_surface(); | 119 impl->active_tree()->root_layer_for_testing()->render_surface(); |
| 121 gfx::Rect root_damage = | 120 gfx::Rect root_damage = root_surface->damage_tracker()->CurrentDamageRect(); |
| 122 root_surface->damage_tracker()->current_damage_rect(); | |
| 123 | 121 |
| 124 switch (draw_count_) { | 122 switch (draw_count_) { |
| 125 case 0: | 123 case 0: |
| 126 // The first frame has full damage. | 124 // The first frame has full damage. |
| 127 EXPECT_EQ(gfx::Rect(10, 10), root_damage); | 125 EXPECT_EQ(gfx::Rect(10, 10), root_damage); |
| 128 break; | 126 break; |
| 129 case 1: | 127 case 1: |
| 130 // The second frame has full damage. | 128 // The second frame has full damage. |
| 131 EXPECT_EQ(gfx::Rect(15, 15), root_damage); | 129 EXPECT_EQ(gfx::Rect(15, 15), root_damage); |
| 132 EndTest(); | 130 EndTest(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 client_.set_bounds(root_->bounds()); | 250 client_.set_bounds(root_->bounds()); |
| 253 } | 251 } |
| 254 | 252 |
| 255 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 253 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 256 LayerTreeHostImpl::FrameData* frame_data, | 254 LayerTreeHostImpl::FrameData* frame_data, |
| 257 DrawResult draw_result) override { | 255 DrawResult draw_result) override { |
| 258 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 256 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 259 | 257 |
| 260 RenderSurfaceImpl* root_surface = | 258 RenderSurfaceImpl* root_surface = |
| 261 host_impl->active_tree()->root_layer_for_testing()->render_surface(); | 259 host_impl->active_tree()->root_layer_for_testing()->render_surface(); |
| 262 gfx::Rect root_damage = | 260 gfx::Rect root_damage = root_surface->damage_tracker()->CurrentDamageRect(); |
| 263 root_surface->damage_tracker()->current_damage_rect(); | |
| 264 root_damage.Intersect(root_surface->content_rect()); | 261 root_damage.Intersect(root_surface->content_rect()); |
| 265 | 262 |
| 266 int source_frame = host_impl->active_tree()->source_frame_number(); | 263 int source_frame = host_impl->active_tree()->source_frame_number(); |
| 267 switch (source_frame) { | 264 switch (source_frame) { |
| 268 case 0: | 265 case 0: |
| 269 // The first frame draws and clears any damage. | 266 // The first frame draws and clears any damage. |
| 270 EXPECT_EQ(root_surface->content_rect(), root_damage); | 267 EXPECT_EQ(root_surface->content_rect(), root_damage); |
| 271 EXPECT_FALSE(frame_data->has_no_damage); | 268 EXPECT_FALSE(frame_data->has_no_damage); |
| 272 break; | 269 break; |
| 273 case 1: | 270 case 1: |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 num_draws_ = 0; | 374 num_draws_ = 0; |
| 378 PostSetNeedsCommitToMainThread(); | 375 PostSetNeedsCommitToMainThread(); |
| 379 } | 376 } |
| 380 | 377 |
| 381 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 378 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 382 LayerTreeHostImpl::FrameData* frame_data, | 379 LayerTreeHostImpl::FrameData* frame_data, |
| 383 DrawResult draw_result) override { | 380 DrawResult draw_result) override { |
| 384 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 381 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 385 RenderSurfaceImpl* root_surface = | 382 RenderSurfaceImpl* root_surface = |
| 386 host_impl->active_tree()->root_layer_for_testing()->render_surface(); | 383 host_impl->active_tree()->root_layer_for_testing()->render_surface(); |
| 387 gfx::Rect root_damage = | 384 gfx::Rect root_damage = root_surface->damage_tracker()->CurrentDamageRect(); |
| 388 root_surface->damage_tracker()->current_damage_rect(); | |
| 389 root_damage.Intersect(root_surface->content_rect()); | 385 root_damage.Intersect(root_surface->content_rect()); |
| 390 switch (num_draws_) { | 386 switch (num_draws_) { |
| 391 case 0: | 387 case 0: |
| 392 // The first frame has damage, so we should draw and swap. | 388 // The first frame has damage, so we should draw and swap. |
| 393 break; | 389 break; |
| 394 case 1: | 390 case 1: |
| 395 // The second frame should not damage the scrollbars. | 391 // The second frame should not damage the scrollbars. |
| 396 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); | 392 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); |
| 397 break; | 393 break; |
| 398 case 2: | 394 case 2: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 num_draws_ = 0; | 457 num_draws_ = 0; |
| 462 PostSetNeedsCommitToMainThread(); | 458 PostSetNeedsCommitToMainThread(); |
| 463 } | 459 } |
| 464 | 460 |
| 465 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 461 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 466 LayerTreeHostImpl::FrameData* frame_data, | 462 LayerTreeHostImpl::FrameData* frame_data, |
| 467 DrawResult draw_result) override { | 463 DrawResult draw_result) override { |
| 468 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 464 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 469 RenderSurfaceImpl* root_surface = | 465 RenderSurfaceImpl* root_surface = |
| 470 host_impl->active_tree()->root_layer_for_testing()->render_surface(); | 466 host_impl->active_tree()->root_layer_for_testing()->render_surface(); |
| 471 gfx::Rect root_damage = | 467 gfx::Rect root_damage = root_surface->damage_tracker()->CurrentDamageRect(); |
| 472 root_surface->damage_tracker()->current_damage_rect(); | |
| 473 root_damage.Intersect(root_surface->content_rect()); | 468 root_damage.Intersect(root_surface->content_rect()); |
| 474 int frame = host_impl->active_tree()->source_frame_number(); | 469 int frame = host_impl->active_tree()->source_frame_number(); |
| 475 switch (num_draws_) { | 470 switch (num_draws_) { |
| 476 case 0: | 471 case 0: |
| 477 // The first frame has damage, so we should draw and swap. | 472 // The first frame has damage, so we should draw and swap. |
| 478 EXPECT_EQ(0, frame); | 473 EXPECT_EQ(0, frame); |
| 479 break; | 474 break; |
| 480 case 1: | 475 case 1: |
| 481 // The second frame has scrolled, so the scrollbar should be damaged. | 476 // The second frame has scrolled, so the scrollbar should be damaged. |
| 482 EXPECT_EQ(0, frame); | 477 EXPECT_EQ(0, frame); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 | 516 |
| 522 void AfterTest() override { EXPECT_EQ(3, num_draws_); } | 517 void AfterTest() override { EXPECT_EQ(3, num_draws_); } |
| 523 | 518 |
| 524 int num_draws_; | 519 int num_draws_; |
| 525 }; | 520 }; |
| 526 | 521 |
| 527 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); | 522 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); |
| 528 | 523 |
| 529 } // namespace | 524 } // namespace |
| 530 } // namespace cc | 525 } // namespace cc |
| OLD | NEW |