| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // Then we set full damage for the next frame. | 286 // Then we set full damage for the next frame. |
| 287 host_impl->SetFullRootLayerDamage(); | 287 host_impl->SetFullRootLayerDamage(); |
| 288 break; | 288 break; |
| 289 case 2: | 289 case 2: |
| 290 // The whole frame should be damaged as requested. | 290 // The whole frame should be damaged as requested. |
| 291 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), | 291 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), |
| 292 root_damage.ToString()); | 292 root_damage.ToString()); |
| 293 EXPECT_FALSE(frame_data->has_no_damage); | 293 EXPECT_FALSE(frame_data->has_no_damage); |
| 294 | 294 |
| 295 // Just a part of the next frame should be damaged. | 295 // Just a part of the next frame should be damaged. |
| 296 child_damage_rect_ = gfx::RectF(10, 11, 12, 13); | 296 child_damage_rect_ = gfx::Rect(10, 11, 12, 13); |
| 297 break; | 297 break; |
| 298 case 3: | 298 case 3: |
| 299 // The update rect in the child should be damaged and the damaged area | 299 // The update rect in the child should be damaged and the damaged area |
| 300 // should match the invalidation. | 300 // should match the invalidation. |
| 301 EXPECT_EQ(gfx::RectF(100+10, 100+11, 12, 13).ToString(), | 301 EXPECT_EQ(gfx::RectF(100+10, 100+11, 12, 13).ToString(), |
| 302 root_damage.ToString()); | 302 root_damage.ToString()); |
| 303 | 303 |
| 304 // TODO(danakj): Remove this when impl side painting is always on. | 304 // TODO(danakj): Remove this when impl side painting is always on. |
| 305 if (delegating_renderer() || | 305 if (delegating_renderer() || |
| 306 host_impl->settings().impl_side_painting) { | 306 host_impl->settings().impl_side_painting) { |
| 307 // When using a delegating renderer, or using impl side painting, the | 307 // When using a delegating renderer, or using impl side painting, the |
| 308 // entire child is considered damaged as we need to replace its | 308 // entire child is considered damaged as we need to replace its |
| 309 // resources with newly created ones. The damaged area is kept as it | 309 // resources with newly created ones. The damaged area is kept as it |
| 310 // is, but entire child is painted. | 310 // is, but entire child is painted. |
| 311 | 311 |
| 312 // The paint rect should match the layer bounds. | 312 // The paint rect should match the layer bounds. |
| 313 gfx::RectF paint_rect = child_->LastPaintRect(); | 313 gfx::RectF paint_rect = child_->LastPaintRect(); |
| 314 paint_rect.set_origin(child_->position()); | 314 paint_rect.set_origin(child_->position()); |
| 315 EXPECT_EQ(gfx::RectF(100, 100, 30, 30).ToString(), | 315 EXPECT_EQ(gfx::RectF(100, 100, 30, 30).ToString(), |
| 316 paint_rect.ToString()); | 316 paint_rect.ToString()); |
| 317 } | 317 } |
| 318 EXPECT_FALSE(frame_data->has_no_damage); | 318 EXPECT_FALSE(frame_data->has_no_damage); |
| 319 | 319 |
| 320 // If we damage part of the frame, but also damage the full | 320 // If we damage part of the frame, but also damage the full |
| 321 // frame, then the whole frame should be damaged. | 321 // frame, then the whole frame should be damaged. |
| 322 child_damage_rect_ = gfx::RectF(10, 11, 12, 13); | 322 child_damage_rect_ = gfx::Rect(10, 11, 12, 13); |
| 323 host_impl->SetFullRootLayerDamage(); | 323 host_impl->SetFullRootLayerDamage(); |
| 324 break; | 324 break; |
| 325 case 4: | 325 case 4: |
| 326 // The whole frame is damaged. | 326 // The whole frame is damaged. |
| 327 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), | 327 EXPECT_EQ(gfx::RectF(root_surface->content_rect()).ToString(), |
| 328 root_damage.ToString()); | 328 root_damage.ToString()); |
| 329 EXPECT_FALSE(frame_data->has_no_damage); | 329 EXPECT_FALSE(frame_data->has_no_damage); |
| 330 | 330 |
| 331 EndTest(); | 331 EndTest(); |
| 332 break; | 332 break; |
| 333 } | 333 } |
| 334 return draw_result; | 334 return draw_result; |
| 335 } | 335 } |
| 336 | 336 |
| 337 virtual void DidCommitAndDrawFrame() override { | 337 virtual void DidCommitAndDrawFrame() override { |
| 338 if (!TestEnded()) | 338 if (!TestEnded()) |
| 339 layer_tree_host()->SetNeedsCommit(); | 339 layer_tree_host()->SetNeedsCommit(); |
| 340 | 340 |
| 341 if (!child_damage_rect_.IsEmpty()) { | 341 if (!child_damage_rect_.IsEmpty()) { |
| 342 child_->SetNeedsDisplayRect(child_damage_rect_); | 342 child_->SetNeedsDisplayRect(child_damage_rect_); |
| 343 child_damage_rect_ = gfx::RectF(); | 343 child_damage_rect_ = gfx::Rect(); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 | 346 |
| 347 virtual void AfterTest() override {} | 347 virtual void AfterTest() override {} |
| 348 | 348 |
| 349 FakeContentLayerClient client_; | 349 FakeContentLayerClient client_; |
| 350 scoped_refptr<FakeContentLayer> root_; | 350 scoped_refptr<FakeContentLayer> root_; |
| 351 scoped_refptr<FakeContentLayer> child_; | 351 scoped_refptr<FakeContentLayer> child_; |
| 352 gfx::RectF child_damage_rect_; | 352 gfx::Rect child_damage_rect_; |
| 353 }; | 353 }; |
| 354 | 354 |
| 355 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage); | 355 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage); |
| 356 | 356 |
| 357 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { | 357 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { |
| 358 virtual void SetupTree() override { | 358 virtual void SetupTree() override { |
| 359 scoped_refptr<Layer> root_layer = Layer::Create(); | 359 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 360 root_layer->SetBounds(gfx::Size(400, 400)); | 360 root_layer->SetBounds(gfx::Size(400, 400)); |
| 361 root_layer->SetMasksToBounds(true); | 361 root_layer->SetMasksToBounds(true); |
| 362 layer_tree_host()->SetRootLayer(root_layer); | 362 layer_tree_host()->SetRootLayer(root_layer); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 FakeContentLayerClient client_; | 637 FakeContentLayerClient client_; |
| 638 int swap_count_; | 638 int swap_count_; |
| 639 int prepare_to_draw_count_; | 639 int prepare_to_draw_count_; |
| 640 int update_visible_tile_count_; | 640 int update_visible_tile_count_; |
| 641 }; | 641 }; |
| 642 | 642 |
| 643 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); | 643 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); |
| 644 | 644 |
| 645 } // namespace | 645 } // namespace |
| 646 } // namespace cc | 646 } // namespace cc |
| OLD | NEW |