Chromium Code Reviews| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
| 9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
| 10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
| 11 #include "cc/layers/heads_up_display_layer.h" | 11 #include "cc/layers/heads_up_display_layer.h" |
| 12 #include "cc/layers/io_surface_layer.h" | 12 #include "cc/layers/io_surface_layer.h" |
| 13 #include "cc/layers/layer_impl.h" | 13 #include "cc/layers/layer_impl.h" |
| 14 #include "cc/layers/painted_scrollbar_layer.h" | 14 #include "cc/layers/painted_scrollbar_layer.h" |
| 15 #include "cc/layers/picture_layer.h" | 15 #include "cc/layers/picture_layer.h" |
| 16 #include "cc/layers/texture_layer.h" | 16 #include "cc/layers/texture_layer.h" |
| 17 #include "cc/layers/texture_layer_impl.h" | 17 #include "cc/layers/texture_layer_impl.h" |
| 18 #include "cc/layers/video_layer.h" | 18 #include "cc/layers/video_layer.h" |
| 19 #include "cc/layers/video_layer_impl.h" | 19 #include "cc/layers/video_layer_impl.h" |
| 20 #include "cc/output/filter_operations.h" | 20 #include "cc/output/filter_operations.h" |
| 21 #include "cc/test/fake_content_layer.h" | 21 #include "cc/test/fake_content_layer.h" |
| 22 #include "cc/test/fake_content_layer_client.h" | 22 #include "cc/test/fake_content_layer_client.h" |
| 23 #include "cc/test/fake_content_layer_impl.h" | 23 #include "cc/test/fake_content_layer_impl.h" |
| 24 #include "cc/test/fake_delegated_renderer_layer.h" | 24 #include "cc/test/fake_delegated_renderer_layer.h" |
| 25 #include "cc/test/fake_delegated_renderer_layer_impl.h" | 25 #include "cc/test/fake_delegated_renderer_layer_impl.h" |
| 26 #include "cc/test/fake_layer_tree_host_client.h" | 26 #include "cc/test/fake_layer_tree_host_client.h" |
| 27 #include "cc/test/fake_output_surface.h" | 27 #include "cc/test/fake_output_surface.h" |
| 28 #include "cc/test/fake_output_surface_client.h" | 28 #include "cc/test/fake_output_surface_client.h" |
| 29 #include "cc/test/fake_painted_scrollbar_layer.h" | 29 #include "cc/test/fake_painted_scrollbar_layer.h" |
| 30 #include "cc/test/fake_picture_layer.h" | |
| 31 #include "cc/test/fake_picture_layer_impl.h" | |
| 30 #include "cc/test/fake_scoped_ui_resource.h" | 32 #include "cc/test/fake_scoped_ui_resource.h" |
| 31 #include "cc/test/fake_scrollbar.h" | 33 #include "cc/test/fake_scrollbar.h" |
| 32 #include "cc/test/fake_video_frame_provider.h" | 34 #include "cc/test/fake_video_frame_provider.h" |
| 33 #include "cc/test/layer_tree_test.h" | 35 #include "cc/test/layer_tree_test.h" |
| 34 #include "cc/test/render_pass_test_common.h" | 36 #include "cc/test/render_pass_test_common.h" |
| 35 #include "cc/test/test_context_provider.h" | 37 #include "cc/test/test_context_provider.h" |
| 36 #include "cc/test/test_shared_bitmap_manager.h" | 38 #include "cc/test/test_shared_bitmap_manager.h" |
| 37 #include "cc/test/test_web_graphics_context_3d.h" | 39 #include "cc/test/test_web_graphics_context_3d.h" |
| 38 #include "cc/trees/layer_tree_host_impl.h" | 40 #include "cc/trees/layer_tree_host_impl.h" |
| 39 #include "cc/trees/layer_tree_impl.h" | 41 #include "cc/trees/layer_tree_impl.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); | 317 LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); |
| 316 | 318 |
| 317 class LayerTreeHostContextTestLostContextSucceedsWithContent | 319 class LayerTreeHostContextTestLostContextSucceedsWithContent |
| 318 : public LayerTreeHostContextTestLostContextSucceeds { | 320 : public LayerTreeHostContextTestLostContextSucceeds { |
| 319 public: | 321 public: |
| 320 virtual void SetupTree() OVERRIDE { | 322 virtual void SetupTree() OVERRIDE { |
| 321 root_ = Layer::Create(); | 323 root_ = Layer::Create(); |
| 322 root_->SetBounds(gfx::Size(10, 10)); | 324 root_->SetBounds(gfx::Size(10, 10)); |
| 323 root_->SetIsDrawable(true); | 325 root_->SetIsDrawable(true); |
| 324 | 326 |
| 325 content_ = FakeContentLayer::Create(&client_); | 327 // Paint non-solid color. |
| 326 content_->SetBounds(gfx::Size(10, 10)); | 328 SkPaint paint; |
| 327 content_->SetIsDrawable(true); | 329 paint.setColor(SkColorSetARGB(100, 80, 200, 200)); |
| 330 client_.add_draw_rect(gfx::Rect(0, 0, 5, 5), paint); | |
| 331 client_.add_draw_rect(gfx::Rect(10, 10, 10, 10), paint); | |
| 332 client_.add_draw_rect(gfx::Rect(30, 30, 5, 5), paint); | |
| 333 client_.add_draw_rect(gfx::Rect(50, 50, 5, 5), paint); | |
| 328 | 334 |
|
sohanjg
2014/09/08 15:17:32
Are we drawing/recording this too far away from vi
| |
| 329 root_->AddChild(content_); | 335 if (layer_tree_host()->settings().impl_side_painting) |
| 336 layer_ = FakePictureLayer::Create(&client_); | |
| 337 else | |
| 338 layer_ = FakeContentLayer::Create(&client_); | |
| 339 layer_->SetBounds(gfx::Size(10, 10)); | |
| 340 layer_->SetIsDrawable(true); | |
| 341 | |
| 342 root_->AddChild(layer_); | |
| 330 | 343 |
| 331 layer_tree_host()->SetRootLayer(root_); | 344 layer_tree_host()->SetRootLayer(root_); |
| 332 LayerTreeHostContextTest::SetupTree(); | 345 LayerTreeHostContextTest::SetupTree(); |
| 333 } | 346 } |
| 334 | 347 |
| 335 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { | 348 virtual void InvalidateAndSetNeedsCommit() OVERRIDE { |
| 336 // Invalidate the render surface so we don't try to use a cached copy of the | 349 // Invalidate the render surface so we don't try to use a cached copy of the |
| 337 // surface. We want to make sure to test the drawing paths for drawing to | 350 // surface. We want to make sure to test the drawing paths for drawing to |
| 338 // a child surface. | 351 // a child surface. |
| 339 content_->SetNeedsDisplay(); | 352 layer_->SetNeedsDisplay(); |
| 340 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); | 353 LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
| 341 } | 354 } |
| 342 | 355 |
| 343 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 356 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| 344 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( | 357 if (!layer_tree_host()->settings().impl_side_painting) { |
| 345 host_impl->active_tree()->root_layer()->children()[0]); | 358 FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
| 346 // Even though the context was lost, we should have a resource. The | 359 host_impl->active_tree()->root_layer()->children()[0]); |
| 347 // TestWebGraphicsContext3D ensures that this resource is created with | 360 // Even though the context was lost, we should have a resource. The |
| 348 // the active context. | 361 // TestWebGraphicsContext3D ensures that this resource is created with |
| 349 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | 362 // the active context. |
| 363 EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); | |
| 364 } else { | |
| 365 FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( | |
| 366 host_impl->active_tree()->root_layer()->children()[0]); | |
| 367 EXPECT_TRUE(picture_impl->HighResTiling()->TileAt(0, 0)->IsReadyToDraw()); | |
| 368 } | |
| 350 } | 369 } |
| 351 | 370 |
| 352 protected: | 371 protected: |
| 353 FakeContentLayerClient client_; | 372 FakeContentLayerClient client_; |
| 354 scoped_refptr<Layer> root_; | 373 scoped_refptr<Layer> root_; |
| 355 scoped_refptr<ContentLayer> content_; | 374 scoped_refptr<Layer> layer_; |
| 356 }; | 375 }; |
| 357 | 376 |
| 358 // This test uses TiledLayer to check for a working context. | 377 // This test uses TiledLayer and PictureLayer to check for a working context. |
| 359 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( | 378 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 360 LayerTreeHostContextTestLostContextSucceedsWithContent); | 379 LayerTreeHostContextTestLostContextSucceedsWithContent); |
| 361 | 380 |
| 362 class LayerTreeHostContextTestCreateOutputSurfaceFails | 381 class LayerTreeHostContextTestCreateOutputSurfaceFails |
| 363 : public LayerTreeHostContextTest { | 382 : public LayerTreeHostContextTest { |
| 364 public: | 383 public: |
| 365 // Run a test that initially fails OutputSurface creation |times_to_fail| | 384 // Run a test that initially fails OutputSurface creation |times_to_fail| |
| 366 // times. If |expect_fallback_attempt| is |true|, an attempt to create a | 385 // times. If |expect_fallback_attempt| is |true|, an attempt to create a |
| 367 // fallback/software OutputSurface is expected to occur. | 386 // fallback/software OutputSurface is expected to occur. |
| 368 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, | 387 LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail, |
| 369 bool expect_fallback_attempt) | 388 bool expect_fallback_attempt) |
| (...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1515 virtual void AfterTest() OVERRIDE {} | 1534 virtual void AfterTest() OVERRIDE {} |
| 1516 | 1535 |
| 1517 bool deferred_; | 1536 bool deferred_; |
| 1518 }; | 1537 }; |
| 1519 | 1538 |
| 1520 SINGLE_AND_MULTI_THREAD_TEST_F( | 1539 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1521 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); | 1540 LayerTreeHostContextTestLoseAfterSendingBeginMainFrame); |
| 1522 | 1541 |
| 1523 } // namespace | 1542 } // namespace |
| 1524 } // namespace cc | 1543 } // namespace cc |
| OLD | NEW |