Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest_context.cc |
| diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc |
| index 8fcfa28a10f1067557ae51fe21fdc4abfc20ae24..fedc41fc1888e203821223b4037c3ba0df5fa28c 100644 |
| --- a/cc/trees/layer_tree_host_unittest_context.cc |
| +++ b/cc/trees/layer_tree_host_unittest_context.cc |
| @@ -27,6 +27,8 @@ |
| #include "cc/test/fake_output_surface.h" |
| #include "cc/test/fake_output_surface_client.h" |
| #include "cc/test/fake_painted_scrollbar_layer.h" |
| +#include "cc/test/fake_picture_layer.h" |
| +#include "cc/test/fake_picture_layer_impl.h" |
| #include "cc/test/fake_scoped_ui_resource.h" |
| #include "cc/test/fake_scrollbar.h" |
| #include "cc/test/fake_video_frame_provider.h" |
| @@ -314,7 +316,7 @@ class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface |
| SINGLE_AND_MULTI_THREAD_TEST_F( |
| LayerTreeHostClientNotReadyDoesNotCreateOutputSurface); |
| -class LayerTreeHostContextTestLostContextSucceedsWithContent |
| +class LayerTreeHostContextTestLostContextSucceedsWithContentAndImpl |
|
danakj
2014/08/26 18:54:41
leave the test name
sohanjg
2014/08/27 06:59:50
Done.
|
| : public LayerTreeHostContextTestLostContextSucceeds { |
| public: |
| virtual void SetupTree() OVERRIDE { |
| @@ -322,11 +324,14 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent |
| root_->SetBounds(gfx::Size(10, 10)); |
| root_->SetIsDrawable(true); |
| - content_ = FakeContentLayer::Create(&client_); |
| - content_->SetBounds(gfx::Size(10, 10)); |
| - content_->SetIsDrawable(true); |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + layer_ = PictureLayer::Create(&client_); |
|
danakj
2014/08/26 18:54:41
FakePictureLayer
sohanjg
2014/08/27 06:59:50
Done.
|
| + else |
| + layer_ = ContentLayer::Create(&client_); |
|
danakj
2014/08/26 18:54:41
You mean FakeContentLayer
sohanjg
2014/08/27 06:59:49
Done.
|
| + layer_->SetBounds(gfx::Size(10, 10)); |
| + layer_->SetIsDrawable(true); |
| - root_->AddChild(content_); |
| + root_->AddChild(layer_); |
| layer_tree_host()->SetRootLayer(root_); |
| LayerTreeHostContextTest::SetupTree(); |
| @@ -336,28 +341,36 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent |
| // Invalidate the render surface so we don't try to use a cached copy of the |
| // surface. We want to make sure to test the drawing paths for drawing to |
| // a child surface. |
| - content_->SetNeedsDisplay(); |
| + layer_->SetNeedsDisplay(); |
| LayerTreeHostContextTestLostContextSucceeds::InvalidateAndSetNeedsCommit(); |
| } |
| virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| - FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
| - host_impl->active_tree()->root_layer()->children()[0]); |
| - // Even though the context was lost, we should have a resource. The |
| - // TestWebGraphicsContext3D ensures that this resource is created with |
| - // the active context. |
| - EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
| + if (layer_tree_host()->settings().impl_side_painting) { |
| + FakePictureLayerImpl* picture_impl = static_cast<FakePictureLayerImpl*>( |
| + host_impl->active_tree()->root_layer()->children()[0]); |
| + // Even though the context was lost, we should have valid tile |
| + // priorities. |
| + EXPECT_TRUE(picture_impl->HasValidTilePriorities()); |
|
sohanjg
2014/08/26 09:36:47
hope this is the closest to having resource for ti
danakj
2014/08/26 18:54:40
picture_impl->HighResTiling()->TileAt(0, 0)->HasRe
sohanjg
2014/08/27 06:59:50
yea! but i think for impl-side paint, can we be su
danakj
2014/08/27 12:59:26
It should not activate and draw without a resource
sohanjg
2014/08/27 13:33:01
Hmm.
picture_impl->HighResTiling()->TileAt(0, 0)->
danakj
2014/08/27 13:49:32
That sounds wrong, does it do this every time it d
sohanjg
2014/08/27 14:13:34
DrawLayersOnThread is always having no resource, i
sohanjg
2014/09/01 10:51:28
Sorry for the late response.
For tests we use soli
danakj
2014/09/03 19:51:40
Oh, maybe we need to make the client_ draw somethi
|
| + } else { |
| + FakeContentLayerImpl* content_impl = static_cast<FakeContentLayerImpl*>( |
| + host_impl->active_tree()->root_layer()->children()[0]); |
| + // Even though the context was lost, we should have a resource. The |
| + // TestWebGraphicsContext3D ensures that this resource is created with |
| + // the active context. |
| + EXPECT_TRUE(content_impl->HaveResourceForTileAt(0, 0)); |
| + } |
| } |
| protected: |
| FakeContentLayerClient client_; |
| scoped_refptr<Layer> root_; |
| - scoped_refptr<ContentLayer> content_; |
| + scoped_refptr<Layer> layer_; |
| }; |
| -// This test uses TiledLayer to check for a working context. |
| -SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F( |
| - LayerTreeHostContextTestLostContextSucceedsWithContent); |
| +// This test uses TiledLayer and PictureLayer to check for a working context. |
| +SINGLE_AND_MULTI_THREAD_TEST_F( |
| + LayerTreeHostContextTestLostContextSucceedsWithContentAndImpl); |
| class LayerTreeHostContextTestCreateOutputSurfaceFails |
| : public LayerTreeHostContextTest { |
| @@ -436,11 +449,14 @@ class LayerTreeHostContextTestLostContextAndEvictTextures |
| public: |
| LayerTreeHostContextTestLostContextAndEvictTextures() |
| : LayerTreeHostContextTest(), |
| - layer_(FakeContentLayer::Create(&client_)), |
| impl_host_(0), |
| num_commits_(0) {} |
| virtual void SetupTree() OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + layer_ = PictureLayer::Create(&client_); |
|
danakj
2014/08/26 18:54:40
FakePictureLayer
sohanjg
2014/08/27 06:59:49
Done.
|
| + else |
| + layer_ = FakeContentLayer::Create(&client_); |
| layer_->SetBounds(gfx::Size(10, 20)); |
| layer_tree_host()->SetRootLayer(layer_); |
| LayerTreeHostContextTest::SetupTree(); |
| @@ -470,7 +486,6 @@ class LayerTreeHostContextTestLostContextAndEvictTextures |
| virtual void DidCommitAndDrawFrame() OVERRIDE { |
| if (num_commits_ > 1) |
| return; |
| - EXPECT_TRUE(layer_->HaveBackingAt(0, 0)); |
|
sohanjg
2014/08/26 09:36:47
if we use impl-side painting, this test cant be us
danakj
2014/08/26 18:54:40
we can't check this here on the main thread with i
sohanjg
2014/08/27 06:59:50
Done.
|
| PostEvictTextures(); |
| } |
| @@ -491,7 +506,7 @@ class LayerTreeHostContextTestLostContextAndEvictTextures |
| protected: |
| bool lose_after_evict_; |
| FakeContentLayerClient client_; |
| - scoped_refptr<FakeContentLayer> layer_; |
| + scoped_refptr<Layer> layer_; |
| LayerTreeHostImpl* impl_host_; |
| int num_commits_; |
| }; |
| @@ -567,9 +582,7 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources |
| : public LayerTreeHostContextTest { |
| public: |
| LayerTreeHostContextTestLostContextWhileUpdatingResources() |
| - : parent_(FakeContentLayer::Create(&client_)), |
| - num_children_(50), |
| - times_to_lose_on_end_query_(3) {} |
| + : num_children_(50), times_to_lose_on_end_query_(3) {} |
| virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() OVERRIDE { |
| scoped_ptr<TestWebGraphicsContext3D> context = |
| @@ -582,11 +595,19 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources |
| } |
| virtual void SetupTree() OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + parent_ = PictureLayer::Create(&client_); |
| + else |
| + parent_ = FakeContentLayer::Create(&client_); |
| + |
| parent_->SetBounds(gfx::Size(num_children_, 1)); |
| for (int i = 0; i < num_children_; i++) { |
| - scoped_refptr<FakeContentLayer> child = |
| - FakeContentLayer::Create(&client_); |
| + scoped_refptr<Layer> child; |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + child = PictureLayer::Create(&client_); |
| + else |
| + child = FakeContentLayer::Create(&client_); |
| child->SetPosition(gfx::PointF(i, 0.f)); |
| child->SetBounds(gfx::Size(1, 1)); |
| parent_->AddChild(child); |
| @@ -609,7 +630,7 @@ class LayerTreeHostContextTestLostContextWhileUpdatingResources |
| private: |
| FakeContentLayerClient client_; |
| - scoped_refptr<FakeContentLayer> parent_; |
| + scoped_refptr<Layer> parent_; |
| int num_children_; |
| int times_to_lose_on_end_query_; |
| }; |
| @@ -623,9 +644,15 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
| : LayerTreeHostContextTest(), num_commits_(0) {} |
| virtual void SetupTree() OVERRIDE { |
| - root_ = FakeContentLayer::Create(&client_); |
| - child_ = FakeContentLayer::Create(&client_); |
| - grandchild_ = FakeContentLayer::Create(&client_); |
| + if (layer_tree_host()->settings().impl_side_painting) { |
| + root_ = PictureLayer::Create(&client_); |
|
danakj
2014/08/26 18:54:41
FakePictureLayers, or you can't cast the impl to a
sohanjg
2014/08/27 06:59:49
Done.
|
| + child_ = PictureLayer::Create(&client_); |
| + grandchild_ = PictureLayer::Create(&client_); |
| + } else { |
| + root_ = FakeContentLayer::Create(&client_); |
| + child_ = FakeContentLayer::Create(&client_); |
| + grandchild_ = FakeContentLayer::Create(&client_); |
| + } |
| root_->AddChild(child_); |
| child_->AddChild(grandchild_); |
| @@ -639,27 +666,31 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
| virtual void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| LayerTreeHostContextTest::DidActivateTreeOnThread(host_impl); |
| - FakeContentLayerImpl* root = static_cast<FakeContentLayerImpl*>( |
| - host_impl->active_tree()->root_layer()); |
| - FakeContentLayerImpl* child = |
| - static_cast<FakeContentLayerImpl*>(root->children()[0]); |
| - FakeContentLayerImpl* grandchild = |
| - static_cast<FakeContentLayerImpl*>(child->children()[0]); |
| + LayerImpl* root; |
| + LayerImpl* child; |
| + LayerImpl* grandchild; |
| + |
| + if (layer_tree_host()->settings().impl_side_painting) { |
| + root = static_cast<FakePictureLayerImpl*>( |
| + host_impl->active_tree()->root_layer()); |
| + child = static_cast<FakePictureLayerImpl*>(root->children()[0]); |
| + grandchild = static_cast<FakePictureLayerImpl*>(child->children()[0]); |
| + |
| + } else { |
| + root = static_cast<FakeContentLayerImpl*>( |
| + host_impl->active_tree()->root_layer()); |
| + child = static_cast<FakeContentLayerImpl*>(root->children()[0]); |
| + grandchild = static_cast<FakeContentLayerImpl*>(child->children()[0]); |
| + } |
| ++num_commits_; |
| switch (num_commits_) { |
| case 1: |
| - EXPECT_EQ(0u, root->lost_output_surface_count()); |
| - EXPECT_EQ(0u, child->lost_output_surface_count()); |
| - EXPECT_EQ(0u, grandchild->lost_output_surface_count()); |
|
sohanjg
2014/08/26 09:36:47
if we use impl-side, these test cant be used, are
sohanjg
2014/08/26 10:56:26
can we check something like LayerPropertyChanged ?
danakj
2014/08/26 18:54:40
add this to FakePictureLayerImpl.
https://code.go
sohanjg
2014/08/27 06:59:50
Done.
|
| // Lose the context and struggle to recreate it. |
| LoseContext(); |
| times_to_fail_create_ = 1; |
| break; |
| case 2: |
| - EXPECT_GE(1u, root->lost_output_surface_count()); |
| - EXPECT_GE(1u, child->lost_output_surface_count()); |
| - EXPECT_GE(1u, grandchild->lost_output_surface_count()); |
|
sohanjg
2014/08/26 09:36:47
if we use impl-side, these test cant be used, are
|
| EndTest(); |
| break; |
| default: |
| @@ -673,9 +704,9 @@ class LayerTreeHostContextTestLayersNotified : public LayerTreeHostContextTest { |
| int num_commits_; |
| FakeContentLayerClient client_; |
| - scoped_refptr<FakeContentLayer> root_; |
| - scoped_refptr<FakeContentLayer> child_; |
| - scoped_refptr<FakeContentLayer> grandchild_; |
| + scoped_refptr<Layer> root_; |
| + scoped_refptr<Layer> child_; |
| + scoped_refptr<Layer> grandchild_; |
| }; |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestLayersNotified); |
| @@ -748,10 +779,14 @@ class LayerTreeHostContextTestDontUseLostResources |
| delegated->SetIsDrawable(true); |
| root->AddChild(delegated); |
| - scoped_refptr<ContentLayer> content = ContentLayer::Create(&client_); |
| - content->SetBounds(gfx::Size(10, 10)); |
| - content->SetIsDrawable(true); |
| - root->AddChild(content); |
| + scoped_refptr<Layer> layer; |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + layer = PictureLayer::Create(&client_); |
| + else |
| + layer = ContentLayer::Create(&client_); |
| + layer->SetBounds(gfx::Size(10, 10)); |
| + layer->SetIsDrawable(true); |
| + root->AddChild(layer); |
| scoped_refptr<TextureLayer> texture = TextureLayer::CreateForMailbox(NULL); |
| texture->SetBounds(gfx::Size(10, 10)); |
| @@ -763,15 +798,22 @@ class LayerTreeHostContextTestDontUseLostResources |
| EmptyReleaseCallback))); |
| root->AddChild(texture); |
| - scoped_refptr<ContentLayer> mask = ContentLayer::Create(&client_); |
| + scoped_refptr<Layer> mask; |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + mask = PictureLayer::Create(&client_); |
| + else |
| + mask = ContentLayer::Create(&client_); |
| mask->SetBounds(gfx::Size(10, 10)); |
| - scoped_refptr<ContentLayer> content_with_mask = |
| - ContentLayer::Create(&client_); |
| - content_with_mask->SetBounds(gfx::Size(10, 10)); |
| - content_with_mask->SetIsDrawable(true); |
| - content_with_mask->SetMaskLayer(mask.get()); |
| - root->AddChild(content_with_mask); |
| + scoped_refptr<Layer> layer_with_mask; |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + layer_with_mask = PictureLayer::Create(&client_); |
| + else |
| + layer_with_mask = ContentLayer::Create(&client_); |
| + layer_with_mask->SetBounds(gfx::Size(10, 10)); |
| + layer_with_mask->SetIsDrawable(true); |
| + layer_with_mask->SetMaskLayer(mask.get()); |
| + root->AddChild(layer_with_mask); |
| scoped_refptr<VideoLayer> video_color = |
| VideoLayer::Create(&color_frame_provider_, media::VIDEO_ROTATION_0); |
| @@ -832,7 +874,7 @@ class LayerTreeHostContextTestDontUseLostResources |
| scoped_refptr<PaintedScrollbarLayer> scrollbar = |
| PaintedScrollbarLayer::Create( |
| - scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), content->id()); |
| + scoped_ptr<Scrollbar>(new FakeScrollbar).Pass(), layer->id()); |
| scrollbar->SetBounds(gfx::Size(10, 10)); |
| scrollbar->SetIsDrawable(true); |
| root->AddChild(scrollbar); |
| @@ -1405,10 +1447,13 @@ class LayerTreeHostContextTestSurfaceCreateCallback |
| : public LayerTreeHostContextTest { |
| public: |
| LayerTreeHostContextTestSurfaceCreateCallback() |
| - : LayerTreeHostContextTest(), |
| - layer_(FakeContentLayer::Create(&client_)) {} |
| + : LayerTreeHostContextTest() {} |
| virtual void SetupTree() OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + layer_ = PictureLayer::Create(&client_); |
| + else |
| + layer_ = FakeContentLayer::Create(&client_); |
| layer_->SetBounds(gfx::Size(10, 20)); |
| layer_tree_host()->SetRootLayer(layer_); |
| LayerTreeHostContextTest::SetupTree(); |
| @@ -1419,18 +1464,14 @@ class LayerTreeHostContextTestSurfaceCreateCallback |
| virtual void DidCommit() OVERRIDE { |
| switch (layer_tree_host()->source_frame_number()) { |
| case 1: |
| - EXPECT_EQ(1u, layer_->output_surface_created_count()); |
|
sohanjg
2014/08/26 09:36:47
this seems to be the only thing this test checks,
sohanjg
2014/08/26 10:56:26
like LayerTreeHostContextTestLayersNotified test,
danakj
2014/08/26 18:54:40
Add this to FakePictureLayer.
https://code.google
sohanjg
2014/08/27 06:59:50
Done.
|
| layer_tree_host()->SetNeedsCommit(); |
| break; |
| case 2: |
| - EXPECT_EQ(1u, layer_->output_surface_created_count()); |
| layer_tree_host()->SetNeedsCommit(); |
| break; |
| case 3: |
| - EXPECT_EQ(1u, layer_->output_surface_created_count()); |
| break; |
| case 4: |
| - EXPECT_EQ(2u, layer_->output_surface_created_count()); |
| layer_tree_host()->SetNeedsCommit(); |
| break; |
| } |
| @@ -1456,7 +1497,7 @@ class LayerTreeHostContextTestSurfaceCreateCallback |
| protected: |
| FakeContentLayerClient client_; |
| - scoped_refptr<FakeContentLayer> layer_; |
| + scoped_refptr<Layer> layer_; |
| }; |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); |