Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest.cc |
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
| index 9a7cc581733b07494d8ae32cb2c3456f1cc1151c..dcbab1dcc4df795159de8308f1803a65e2d6ba18 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -274,12 +274,14 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedraw); |
| class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { |
| public: |
| LayerTreeHostTestSetNeedsRedrawRect() |
| - : num_draws_(0), |
| - bounds_(50, 50), |
| - invalid_rect_(10, 10, 20, 20), |
| - root_layer_(ContentLayer::Create(&client_)) {} |
| + : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
| virtual void BeginTest() OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + root_layer_ = FakePictureLayer::Create(&client_); |
| + else |
| + root_layer_ = ContentLayer::Create(&client_); |
| + |
| root_layer_->SetIsDrawable(true); |
| root_layer_->SetBounds(bounds_); |
| layer_tree_host()->SetRootLayer(root_layer_); |
| @@ -324,7 +326,7 @@ class LayerTreeHostTestSetNeedsRedrawRect : public LayerTreeHostTest { |
| const gfx::Size bounds_; |
| const gfx::Rect invalid_rect_; |
| FakeContentLayerClient client_; |
| - scoped_refptr<ContentLayer> root_layer_; |
| + scoped_refptr<Layer> root_layer_; |
| }; |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsRedrawRect); |
| @@ -443,12 +445,14 @@ SINGLE_AND_MULTI_THREAD_TEST_F( |
| class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
| public: |
| LayerTreeHostTestSetNextCommitForcesRedraw() |
| - : num_draws_(0), |
| - bounds_(50, 50), |
| - invalid_rect_(10, 10, 20, 20), |
| - root_layer_(ContentLayer::Create(&client_)) {} |
| + : num_draws_(0), bounds_(50, 50), invalid_rect_(10, 10, 20, 20) {} |
| virtual void BeginTest() OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + root_layer_ = FakePictureLayer::Create(&client_); |
| + else |
| + root_layer_ = ContentLayer::Create(&client_); |
| + |
| root_layer_->SetIsDrawable(true); |
| root_layer_->SetBounds(bounds_); |
| layer_tree_host()->SetRootLayer(root_layer_); |
| @@ -526,7 +530,7 @@ class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
| const gfx::Size bounds_; |
| const gfx::Rect invalid_rect_; |
| FakeContentLayerClient client_; |
| - scoped_refptr<ContentLayer> root_layer_; |
| + scoped_refptr<Layer> root_layer_; |
| }; |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); |
| @@ -535,22 +539,34 @@ SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); |
| // its damage is preserved until the next time it is drawn. |
| class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
| public: |
| - LayerTreeHostTestUndrawnLayersDamageLater() |
| - : root_layer_(ContentLayer::Create(&client_)) {} |
| + LayerTreeHostTestUndrawnLayersDamageLater() {} |
| virtual void SetupTree() OVERRIDE { |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + root_layer_ = FakePictureLayer::Create(&client_); |
| + else |
| + root_layer_ = ContentLayer::Create(&client_); |
| + |
| root_layer_->SetIsDrawable(true); |
| root_layer_->SetBounds(gfx::Size(50, 50)); |
| layer_tree_host()->SetRootLayer(root_layer_); |
| // The initially transparent layer has a larger child layer, which is |
| // not initially drawn because of the this (parent) layer. |
| - parent_layer_ = FakeContentLayer::Create(&client_); |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + parent_layer_ = FakePictureLayer::Create(&client_); |
| + else |
| + parent_layer_ = FakeContentLayer::Create(&client_); |
| + |
| parent_layer_->SetBounds(gfx::Size(15, 15)); |
| parent_layer_->SetOpacity(0.0f); |
| root_layer_->AddChild(parent_layer_); |
| - child_layer_ = FakeContentLayer::Create(&client_); |
| + if (layer_tree_host()->settings().impl_side_painting) |
| + child_layer_ = FakePictureLayer::Create(&client_); |
| + else |
| + child_layer_ = FakeContentLayer::Create(&client_); |
| + |
| child_layer_->SetBounds(gfx::Size(25, 25)); |
| parent_layer_->AddChild(child_layer_); |
| @@ -616,9 +632,9 @@ class LayerTreeHostTestUndrawnLayersDamageLater : public LayerTreeHostTest { |
| private: |
| FakeContentLayerClient client_; |
| - scoped_refptr<ContentLayer> root_layer_; |
| - scoped_refptr<FakeContentLayer> parent_layer_; |
| - scoped_refptr<FakeContentLayer> child_layer_; |
| + scoped_refptr<Layer> root_layer_; |
| + scoped_refptr<Layer> parent_layer_; |
| + scoped_refptr<Layer> child_layer_; |
| }; |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); |
| @@ -991,8 +1007,8 @@ class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
| public: |
| LayerTreeHostTestOpacityChange() |
| : test_opacity_change_delegate_(), |
| - update_check_layer_(ContentLayerWithUpdateTracking::Create( |
| - &test_opacity_change_delegate_)) { |
| + update_check_layer_( |
| + FakePictureLayer::Create(&test_opacity_change_delegate_)) { |
| test_opacity_change_delegate_.SetTestLayer(update_check_layer_.get()); |
| } |
| @@ -1009,20 +1025,27 @@ class LayerTreeHostTestOpacityChange : public LayerTreeHostTest { |
| virtual void AfterTest() OVERRIDE { |
| // Update() should have been called once. |
| - EXPECT_EQ(1, update_check_layer_->PaintContentsCount()); |
| + EXPECT_EQ(1, (int)update_check_layer_->update_count()); |
| } |
| private: |
| TestOpacityChangeLayerDelegate test_opacity_change_delegate_; |
| - scoped_refptr<ContentLayerWithUpdateTracking> update_check_layer_; |
| + scoped_refptr<FakePictureLayer> update_check_layer_; |
| }; |
| -MULTI_THREAD_TEST_F(LayerTreeHostTestOpacityChange); |
| +TEST_F(LayerTreeHostTestOpacityChange, |
| + RunMultiThread_DirectRenderer_ImplSidePaint) { |
| + RunTest(true, false, true); |
| +} |
| +TEST_F(LayerTreeHostTestOpacityChange, |
| + RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
| + RunTest(true, true, true); |
| +} |
| -class NoScaleContentLayer : public ContentLayer { |
| +class NoScalePictureLayer : public PictureLayer { |
| public: |
| - static scoped_refptr<NoScaleContentLayer> Create(ContentLayerClient* client) { |
| - return make_scoped_refptr(new NoScaleContentLayer(client)); |
| + static scoped_refptr<NoScalePictureLayer> Create(ContentLayerClient* client) { |
| + return make_scoped_refptr(new NoScalePictureLayer(client)); |
| } |
| virtual void CalculateContentsScale(float ideal_contents_scale, |
| @@ -1037,17 +1060,17 @@ class NoScaleContentLayer : public ContentLayer { |
| } |
| private: |
| - explicit NoScaleContentLayer(ContentLayerClient* client) |
| - : ContentLayer(client) {} |
| - virtual ~NoScaleContentLayer() {} |
| + explicit NoScalePictureLayer(ContentLayerClient* client) |
| + : PictureLayer(client) {} |
| + virtual ~NoScalePictureLayer() {} |
| }; |
| class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
| : public LayerTreeHostTest { |
| public: |
| LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers() |
| - : root_layer_(NoScaleContentLayer::Create(&client_)), |
| - child_layer_(ContentLayer::Create(&client_)) {} |
| + : root_layer_(NoScalePictureLayer::Create(&client_)), |
| + child_layer_(FakePictureLayer::Create(&client_)) {} |
| virtual void BeginTest() OVERRIDE { |
| layer_tree_host()->SetViewportSize(gfx::Size(60, 60)); |
| @@ -1080,8 +1103,10 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
| // Device viewport is scaled. |
| EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); |
| - LayerImpl* root = impl->active_tree()->root_layer(); |
| - LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; |
| + FakePictureLayerImpl* root = |
| + static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
| + FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( |
| + impl->active_tree()->root_layer()->children()[0]); |
| // Positions remain in layout pixels. |
| EXPECT_EQ(gfx::Point(0, 0), root->position()); |
| @@ -1105,14 +1130,13 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
| EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), |
| root->render_surface()->content_rect()); |
| - // The content bounds of the child should be scaled. |
| - gfx::Size child_bounds_scaled = |
| - gfx::ToCeiledSize(gfx::ScaleSize(child->bounds(), 1.5)); |
| - EXPECT_EQ(child_bounds_scaled, child->content_bounds()); |
| + // The max tiling scale of the child should be scaled. |
| + EXPECT_EQ(1.5, child->MaximumTilingContentsScale()); |
| gfx::Transform scale_transform; |
| - scale_transform.Scale(impl->device_scale_factor(), |
| - impl->device_scale_factor()); |
| + |
| + scale_transform.Scale(child->MaximumTilingContentsScale(), |
| + child->MaximumTilingContentsScale()); |
| // The root layer is scaled by 2x. |
| gfx::Transform root_screen_space_transform = scale_transform; |
| @@ -1122,13 +1146,14 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
| EXPECT_EQ(root_screen_space_transform, root->screen_space_transform()); |
| // The child is at position 2,2, which is transformed to 3,3 after the scale |
| - gfx::Transform child_screen_space_transform; |
| - child_screen_space_transform.Translate(3.f, 3.f); |
| - gfx::Transform child_draw_transform = child_screen_space_transform; |
| + gfx::Transform child_transform; |
| + child_transform.Translate(3.f, 3.f); |
| - EXPECT_TRANSFORMATION_MATRIX_EQ(child_draw_transform, |
| - child->draw_transform()); |
| - EXPECT_TRANSFORMATION_MATRIX_EQ(child_screen_space_transform, |
| + child_transform.Scale(child->MaximumTilingContentsScale(), |
| + child->MaximumTilingContentsScale()); |
| + |
| + EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, child->draw_transform()); |
| + EXPECT_TRANSFORMATION_MATRIX_EQ(child_transform, |
| child->screen_space_transform()); |
| EndTest(); |
| @@ -1138,11 +1163,20 @@ class LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers |
| private: |
| FakeContentLayerClient client_; |
| - scoped_refptr<NoScaleContentLayer> root_layer_; |
| - scoped_refptr<ContentLayer> child_layer_; |
| + scoped_refptr<NoScalePictureLayer> root_layer_; |
| + scoped_refptr<FakePictureLayer> child_layer_; |
| }; |
| -MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); |
| +TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, |
| + RunMultiThread_DirectRenderer_ImplSidePaint) { |
| + RunTest(true, false, true); |
| +} |
| +TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers, |
| + RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
| + RunTest(true, true, true); |
| +} |
| + |
| +// TODO(sohanjg) : Remove it once impl-side painting ships everywhere. |
|
danakj
2014/09/19 18:12:01
remove this blank line so the comment is attached
sohanjg
2014/09/22 09:31:18
Done.
|
| // Verify atomicity of commits and reuse of textures. |
| class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
| @@ -1252,6 +1286,7 @@ class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
| MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( |
| LayerTreeHostTestDirectRendererAtomicCommit); |
| +// TODO(sohanjg) : Remove it once impl-side painting ships everywhere. |
| class LayerTreeHostTestDelegatingRendererAtomicCommit |
| : public LayerTreeHostTestDirectRendererAtomicCommit { |
| public: |
| @@ -1319,6 +1354,7 @@ static void SetLayerPropertiesForTesting(Layer* layer, |
| layer->SetContentsOpaque(opaque); |
| } |
| +// TODO(sohanjg) : Remove it once impl-side painting ships everywhere. |
| class LayerTreeHostTestAtomicCommitWithPartialUpdate |
| : public LayerTreeHostTest { |
| public: |
| @@ -1815,11 +1851,11 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
| layer_tree_host()->SetViewportSize(gfx::Size(10, 10)); |
| layer_tree_host()->root_layer()->SetBounds(gfx::Size(10, 10)); |
| - content_layer_ = ContentLayer::Create(&client_); |
| - content_layer_->SetBounds(gfx::Size(10, 10)); |
| - content_layer_->SetPosition(gfx::PointF(0.f, 0.f)); |
| - content_layer_->SetIsDrawable(true); |
| - layer_tree_host()->root_layer()->AddChild(content_layer_); |
| + picture_layer_ = FakePictureLayer::Create(&client_); |
| + picture_layer_->SetBounds(gfx::Size(10, 10)); |
| + picture_layer_->SetPosition(gfx::PointF(0.f, 0.f)); |
| + picture_layer_->SetIsDrawable(true); |
| + layer_tree_host()->root_layer()->AddChild(picture_layer_); |
| PostSetNeedsCommitToMainThread(); |
| } |
| @@ -1827,7 +1863,7 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
| virtual void DidCommitAndDrawFrame() OVERRIDE { |
| if (num_draw_layers_ == 2) |
| return; |
| - content_layer_->SetNeedsDisplay(); |
| + picture_layer_->SetNeedsDisplay(); |
| } |
| virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| @@ -1848,12 +1884,19 @@ class LayerTreeHostTestContinuousInvalidate : public LayerTreeHostTest { |
| private: |
| FakeContentLayerClient client_; |
| - scoped_refptr<Layer> content_layer_; |
| + scoped_refptr<Layer> picture_layer_; |
| int num_commit_complete_; |
| int num_draw_layers_; |
| }; |
| -MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostTestContinuousInvalidate); |
|
danakj
2014/09/19 18:12:01
you can just use IMPL instead of NOIMPL in this ma
sohanjg
2014/09/22 09:31:18
Done.
|
| +TEST_F(LayerTreeHostTestContinuousInvalidate, |
| + RunMultiThread_DirectRenderer_ImplSidePaint) { |
| + RunTest(true, false, true); |
| +} |
| +TEST_F(LayerTreeHostTestContinuousInvalidate, |
| + RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
| + RunTest(true, true, true); |
| +} |
| class LayerTreeHostTestDeferCommits : public LayerTreeHostTest { |
| public: |
| @@ -4358,7 +4401,7 @@ class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| } |
| virtual void SetupTree() OVERRIDE { |
| - root_ = FakeContentLayer::Create(&client_); |
| + root_ = FakePictureLayer::Create(&client_); |
| root_->SetBounds(gfx::Size(20, 20)); |
| layer_tree_host()->SetRootLayer(root_); |
| LayerTreeHostTest::SetupTree(); |
| @@ -4401,12 +4444,18 @@ class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| size_t first_output_surface_memory_limit_; |
| size_t second_output_surface_memory_limit_; |
| FakeContentLayerClient client_; |
| - scoped_refptr<FakeContentLayer> root_; |
| + scoped_refptr<FakePictureLayer> root_; |
| }; |
| // No output to copy for delegated renderers. |
|
danakj
2014/09/19 18:12:01
this comment looks out of date, can you remove it?
|
| -SINGLE_AND_MULTI_THREAD_TEST_F( |
|
danakj
2014/09/19 18:12:01
just put IMPL in this macro. you're missing some c
sohanjg
2014/09/22 09:31:19
Done.
|
| - LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
| +TEST_F(LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface, |
| + RunMultiThread_DirectRenderer_ImplSidePaint) { |
| + RunTest(true, false, true); |
| +} |
| +TEST_F(LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface, |
| + RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
| + RunTest(true, true, true); |
| +} |
| struct TestSwapPromiseResult { |
| TestSwapPromiseResult() |