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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 break; | 47 break; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | 51 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
52 LayerTreeHostImpl::FrameData* frame_data, | 52 LayerTreeHostImpl::FrameData* frame_data, |
53 DrawResult draw_result) override { | 53 DrawResult draw_result) override { |
54 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 54 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
55 | 55 |
56 RenderSurfaceImpl* root_surface = | 56 RenderSurfaceImpl* root_surface = |
57 impl->active_tree()->root_layer()->render_surface(); | 57 impl->active_tree()->root_layer_for_testing()->render_surface(); |
58 gfx::Rect root_damage = | 58 gfx::Rect root_damage = |
59 root_surface->damage_tracker()->current_damage_rect(); | 59 root_surface->damage_tracker()->current_damage_rect(); |
60 | 60 |
61 switch (draw_count_) { | 61 switch (draw_count_) { |
62 case 0: | 62 case 0: |
63 // The first frame has full damage. | 63 // The first frame has full damage. |
64 EXPECT_EQ(gfx::Rect(10, 10), root_damage); | 64 EXPECT_EQ(gfx::Rect(10, 10), root_damage); |
65 break; | 65 break; |
66 case 1: | 66 case 1: |
67 // The second frame has full damage. | 67 // The second frame has full damage. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 break; | 109 break; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | 113 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
114 LayerTreeHostImpl::FrameData* frame_data, | 114 LayerTreeHostImpl::FrameData* frame_data, |
115 DrawResult draw_result) override { | 115 DrawResult draw_result) override { |
116 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 116 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
117 | 117 |
118 RenderSurfaceImpl* root_surface = | 118 RenderSurfaceImpl* root_surface = |
119 impl->active_tree()->root_layer()->render_surface(); | 119 impl->active_tree()->root_layer_for_testing()->render_surface(); |
120 gfx::Rect root_damage = | 120 gfx::Rect root_damage = |
121 root_surface->damage_tracker()->current_damage_rect(); | 121 root_surface->damage_tracker()->current_damage_rect(); |
122 | 122 |
123 switch (draw_count_) { | 123 switch (draw_count_) { |
124 case 0: | 124 case 0: |
125 // The first frame has full damage. | 125 // The first frame has full damage. |
126 EXPECT_EQ(gfx::Rect(10, 10), root_damage); | 126 EXPECT_EQ(gfx::Rect(10, 10), root_damage); |
127 break; | 127 break; |
128 case 1: | 128 case 1: |
129 // The second frame has full damage. | 129 // The second frame has full damage. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 LayerTreeHostDamageTest::SetupTree(); | 253 LayerTreeHostDamageTest::SetupTree(); |
254 client_.set_bounds(root_->bounds()); | 254 client_.set_bounds(root_->bounds()); |
255 } | 255 } |
256 | 256 |
257 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 257 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
258 LayerTreeHostImpl::FrameData* frame_data, | 258 LayerTreeHostImpl::FrameData* frame_data, |
259 DrawResult draw_result) override { | 259 DrawResult draw_result) override { |
260 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 260 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
261 | 261 |
262 RenderSurfaceImpl* root_surface = | 262 RenderSurfaceImpl* root_surface = |
263 host_impl->active_tree()->root_layer()->render_surface(); | 263 host_impl->active_tree()->root_layer_for_testing()->render_surface(); |
264 gfx::Rect root_damage = | 264 gfx::Rect root_damage = |
265 root_surface->damage_tracker()->current_damage_rect(); | 265 root_surface->damage_tracker()->current_damage_rect(); |
266 root_damage.Intersect(root_surface->content_rect()); | 266 root_damage.Intersect(root_surface->content_rect()); |
267 | 267 |
268 int source_frame = host_impl->active_tree()->source_frame_number(); | 268 int source_frame = host_impl->active_tree()->source_frame_number(); |
269 switch (source_frame) { | 269 switch (source_frame) { |
270 case 0: | 270 case 0: |
271 // The first frame draws and clears any damage. | 271 // The first frame draws and clears any damage. |
272 EXPECT_EQ(root_surface->content_rect(), root_damage); | 272 EXPECT_EQ(root_surface->content_rect(), root_damage); |
273 EXPECT_FALSE(frame_data->has_no_damage); | 273 EXPECT_FALSE(frame_data->has_no_damage); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 void BeginTest() override { | 378 void BeginTest() override { |
379 did_swaps_ = 0; | 379 did_swaps_ = 0; |
380 PostSetNeedsCommitToMainThread(); | 380 PostSetNeedsCommitToMainThread(); |
381 } | 381 } |
382 | 382 |
383 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 383 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
384 LayerTreeHostImpl::FrameData* frame_data, | 384 LayerTreeHostImpl::FrameData* frame_data, |
385 DrawResult draw_result) override { | 385 DrawResult draw_result) override { |
386 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 386 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
387 RenderSurfaceImpl* root_surface = | 387 RenderSurfaceImpl* root_surface = |
388 host_impl->active_tree()->root_layer()->render_surface(); | 388 host_impl->active_tree()->root_layer_for_testing()->render_surface(); |
389 gfx::Rect root_damage = | 389 gfx::Rect root_damage = |
390 root_surface->damage_tracker()->current_damage_rect(); | 390 root_surface->damage_tracker()->current_damage_rect(); |
391 root_damage.Intersect(root_surface->content_rect()); | 391 root_damage.Intersect(root_surface->content_rect()); |
392 switch (did_swaps_) { | 392 switch (did_swaps_) { |
393 case 0: | 393 case 0: |
394 // The first frame has damage, so we should draw and swap. | 394 // The first frame has damage, so we should draw and swap. |
395 break; | 395 break; |
396 case 1: | 396 case 1: |
397 // The second frame should not damage the scrollbars. | 397 // The second frame should not damage the scrollbars. |
398 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); | 398 EXPECT_FALSE(root_damage.Intersects(gfx::Rect(300, 300, 10, 100))); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 void BeginTest() override { | 463 void BeginTest() override { |
464 did_swaps_ = 0; | 464 did_swaps_ = 0; |
465 PostSetNeedsCommitToMainThread(); | 465 PostSetNeedsCommitToMainThread(); |
466 } | 466 } |
467 | 467 |
468 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 468 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
469 LayerTreeHostImpl::FrameData* frame_data, | 469 LayerTreeHostImpl::FrameData* frame_data, |
470 DrawResult draw_result) override { | 470 DrawResult draw_result) override { |
471 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 471 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
472 RenderSurfaceImpl* root_surface = | 472 RenderSurfaceImpl* root_surface = |
473 host_impl->active_tree()->root_layer()->render_surface(); | 473 host_impl->active_tree()->root_layer_for_testing()->render_surface(); |
474 gfx::Rect root_damage = | 474 gfx::Rect root_damage = |
475 root_surface->damage_tracker()->current_damage_rect(); | 475 root_surface->damage_tracker()->current_damage_rect(); |
476 root_damage.Intersect(root_surface->content_rect()); | 476 root_damage.Intersect(root_surface->content_rect()); |
477 int frame = host_impl->active_tree()->source_frame_number(); | 477 int frame = host_impl->active_tree()->source_frame_number(); |
478 switch (did_swaps_) { | 478 switch (did_swaps_) { |
479 case 0: | 479 case 0: |
480 // The first frame has damage, so we should draw and swap. | 480 // The first frame has damage, so we should draw and swap. |
481 EXPECT_EQ(0, frame); | 481 EXPECT_EQ(0, frame); |
482 break; | 482 break; |
483 case 1: | 483 case 1: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 525 |
526 void AfterTest() override { EXPECT_EQ(3, did_swaps_); } | 526 void AfterTest() override { EXPECT_EQ(3, did_swaps_); } |
527 | 527 |
528 int did_swaps_; | 528 int did_swaps_; |
529 }; | 529 }; |
530 | 530 |
531 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); | 531 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); |
532 | 532 |
533 } // namespace | 533 } // namespace |
534 } // namespace cc | 534 } // namespace cc |
OLD | NEW |