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/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 void DidCommitAndDrawFrame() override { | 43 void DidCommitAndDrawFrame() override { |
44 switch (layer_tree_host()->source_frame_number()) { | 44 switch (layer_tree_host()->source_frame_number()) { |
45 case 1: | 45 case 1: |
46 layer_tree_host()->SetNeedsRedraw(); | 46 layer_tree_host()->SetNeedsRedraw(); |
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 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()->render_surface(); |
58 gfx::RectF root_damage = | 58 gfx::RectF 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: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 void DidCommitAndDrawFrame() override { | 104 void DidCommitAndDrawFrame() override { |
105 switch (layer_tree_host()->source_frame_number()) { | 105 switch (layer_tree_host()->source_frame_number()) { |
106 case 1: | 106 case 1: |
107 layer_tree_host()->SetViewportSize(gfx::Size(15, 15)); | 107 layer_tree_host()->SetViewportSize(gfx::Size(15, 15)); |
108 break; | 108 break; |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, | 112 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl, |
113 LayerTreeHostImpl::FrameData* frame_data, | 113 FrameData* frame_data, |
114 DrawResult draw_result) override { | 114 DrawResult draw_result) override { |
115 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 115 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
116 | 116 |
117 RenderSurfaceImpl* root_surface = | 117 RenderSurfaceImpl* root_surface = |
118 impl->active_tree()->root_layer()->render_surface(); | 118 impl->active_tree()->root_layer()->render_surface(); |
119 gfx::RectF root_damage = | 119 gfx::RectF root_damage = |
120 root_surface->damage_tracker()->current_damage_rect(); | 120 root_surface->damage_tracker()->current_damage_rect(); |
121 | 121 |
122 switch (draw_count_) { | 122 switch (draw_count_) { |
123 case 0: | 123 case 0: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Most of the layer isn't visible. | 161 // Most of the layer isn't visible. |
162 content_ = FakeContentLayer::Create(&client_); | 162 content_ = FakeContentLayer::Create(&client_); |
163 content_->SetBounds(gfx::Size(2000, 100)); | 163 content_->SetBounds(gfx::Size(2000, 100)); |
164 root->AddChild(content_); | 164 root->AddChild(content_); |
165 | 165 |
166 layer_tree_host()->SetRootLayer(root); | 166 layer_tree_host()->SetRootLayer(root); |
167 LayerTreeHostDamageTest::SetupTree(); | 167 LayerTreeHostDamageTest::SetupTree(); |
168 } | 168 } |
169 | 169 |
170 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 170 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
171 LayerTreeHostImpl::FrameData* frame_data, | 171 FrameData* frame_data, |
172 DrawResult draw_result) override { | 172 DrawResult draw_result) override { |
173 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 173 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
174 | 174 |
175 int source_frame = host_impl->active_tree()->source_frame_number(); | 175 int source_frame = host_impl->active_tree()->source_frame_number(); |
176 switch (source_frame) { | 176 switch (source_frame) { |
177 case 0: | 177 case 0: |
178 // The first frame has damage, so we should draw and swap. | 178 // The first frame has damage, so we should draw and swap. |
179 ++expect_swap_and_succeed_; | 179 ++expect_swap_and_succeed_; |
180 break; | 180 break; |
181 case 1: | 181 case 1: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 root_->SetBounds(gfx::Size(500, 500)); | 246 root_->SetBounds(gfx::Size(500, 500)); |
247 child_->SetPosition(gfx::Point(100, 100)); | 247 child_->SetPosition(gfx::Point(100, 100)); |
248 child_->SetBounds(gfx::Size(30, 30)); | 248 child_->SetBounds(gfx::Size(30, 30)); |
249 | 249 |
250 root_->AddChild(child_); | 250 root_->AddChild(child_); |
251 layer_tree_host()->SetRootLayer(root_); | 251 layer_tree_host()->SetRootLayer(root_); |
252 LayerTreeHostDamageTest::SetupTree(); | 252 LayerTreeHostDamageTest::SetupTree(); |
253 } | 253 } |
254 | 254 |
255 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 255 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
256 LayerTreeHostImpl::FrameData* frame_data, | 256 FrameData* frame_data, |
257 DrawResult draw_result) override { | 257 DrawResult draw_result) override { |
258 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 258 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
259 | 259 |
260 RenderSurfaceImpl* root_surface = | 260 RenderSurfaceImpl* root_surface = |
261 host_impl->active_tree()->root_layer()->render_surface(); | 261 host_impl->active_tree()->root_layer()->render_surface(); |
262 gfx::RectF root_damage = | 262 gfx::RectF root_damage = |
263 root_surface->damage_tracker()->current_damage_rect(); | 263 root_surface->damage_tracker()->current_damage_rect(); |
264 root_damage.Intersect(root_surface->content_rect()); | 264 root_damage.Intersect(root_surface->content_rect()); |
265 | 265 |
266 int source_frame = host_impl->active_tree()->source_frame_number(); | 266 int source_frame = host_impl->active_tree()->source_frame_number(); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 }; | 387 }; |
388 | 388 |
389 class LayerTreeHostDamageTestScrollbarDoesDamage | 389 class LayerTreeHostDamageTestScrollbarDoesDamage |
390 : public LayerTreeHostScrollbarDamageTest { | 390 : public LayerTreeHostScrollbarDamageTest { |
391 void BeginTest() override { | 391 void BeginTest() override { |
392 did_swaps_ = 0; | 392 did_swaps_ = 0; |
393 PostSetNeedsCommitToMainThread(); | 393 PostSetNeedsCommitToMainThread(); |
394 } | 394 } |
395 | 395 |
396 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 396 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
397 LayerTreeHostImpl::FrameData* frame_data, | 397 FrameData* frame_data, |
398 DrawResult draw_result) override { | 398 DrawResult draw_result) override { |
399 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 399 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
400 RenderSurfaceImpl* root_surface = | 400 RenderSurfaceImpl* root_surface = |
401 host_impl->active_tree()->root_layer()->render_surface(); | 401 host_impl->active_tree()->root_layer()->render_surface(); |
402 gfx::RectF root_damage = | 402 gfx::RectF root_damage = |
403 root_surface->damage_tracker()->current_damage_rect(); | 403 root_surface->damage_tracker()->current_damage_rect(); |
404 root_damage.Intersect(root_surface->content_rect()); | 404 root_damage.Intersect(root_surface->content_rect()); |
405 switch (did_swaps_) { | 405 switch (did_swaps_) { |
406 case 0: | 406 case 0: |
407 // The first frame has damage, so we should draw and swap. | 407 // The first frame has damage, so we should draw and swap. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarDoesDamage); | 458 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarDoesDamage); |
459 | 459 |
460 class LayerTreeHostDamageTestScrollbarCommitDoesNoDamage | 460 class LayerTreeHostDamageTestScrollbarCommitDoesNoDamage |
461 : public LayerTreeHostScrollbarDamageTest { | 461 : public LayerTreeHostScrollbarDamageTest { |
462 void BeginTest() override { | 462 void BeginTest() override { |
463 did_swaps_ = 0; | 463 did_swaps_ = 0; |
464 PostSetNeedsCommitToMainThread(); | 464 PostSetNeedsCommitToMainThread(); |
465 } | 465 } |
466 | 466 |
467 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 467 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
468 LayerTreeHostImpl::FrameData* frame_data, | 468 FrameData* frame_data, |
469 DrawResult draw_result) override { | 469 DrawResult draw_result) override { |
470 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 470 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
471 RenderSurfaceImpl* root_surface = | 471 RenderSurfaceImpl* root_surface = |
472 host_impl->active_tree()->root_layer()->render_surface(); | 472 host_impl->active_tree()->root_layer()->render_surface(); |
473 gfx::RectF root_damage = | 473 gfx::RectF root_damage = |
474 root_surface->damage_tracker()->current_damage_rect(); | 474 root_surface->damage_tracker()->current_damage_rect(); |
475 root_damage.Intersect(root_surface->content_rect()); | 475 root_damage.Intersect(root_surface->content_rect()); |
476 int frame = host_impl->active_tree()->source_frame_number(); | 476 int frame = host_impl->active_tree()->source_frame_number(); |
477 switch (did_swaps_) { | 477 switch (did_swaps_) { |
478 case 0: | 478 case 0: |
(...skipping 46 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 |