| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| 6 | 6 |
| 7 #include "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
| 11 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
| 12 #include "cc/trees/clip_node.h" | 12 #include "cc/trees/clip_node.h" |
| 13 #include "cc/trees/effect_node.h" | 13 #include "cc/trees/effect_node.h" |
| 14 #include "cc/trees/layer_tree_host.h" | 14 #include "cc/trees/layer_tree_host.h" |
| 15 #include "cc/trees/transform_node.h" | 15 #include "cc/trees/transform_node.h" |
| 16 #include "platform/RuntimeEnabledFeatures.h" | 16 #include "platform/RuntimeEnabledFeatures.h" |
| 17 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 17 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 18 #include "platform/graphics/paint/PaintArtifact.h" | 18 #include "platform/graphics/paint/PaintArtifact.h" |
| 19 #include "platform/testing/PictureMatchers.h" | 19 #include "platform/testing/PictureMatchers.h" |
| 20 #include "platform/testing/TestPaintArtifact.h" | 20 #include "platform/testing/TestPaintArtifact.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 34 transform.Translate(x, y); | 34 transform.Translate(x, y); |
| 35 return transform; | 35 return transform; |
| 36 } | 36 } |
| 37 | 37 |
| 38 EffectPaintPropertyNode* dummyRootEffect() | 38 EffectPaintPropertyNode* dummyRootEffect() |
| 39 { | 39 { |
| 40 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr
eate(nullptr, 1.0)); | 40 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr
eate(nullptr, 1.0)); |
| 41 return node; | 41 return node; |
| 42 } | 42 } |
| 43 | 43 |
| 44 class WebLayerTreeViewWithOutputSurface : public WebLayerTreeViewImplForTesting
{ | 44 class WebLayerTreeViewWithCompositorFrameSink : public WebLayerTreeViewImplForTe
sting { |
| 45 public: | 45 public: |
| 46 WebLayerTreeViewWithOutputSurface(const cc::LayerTreeSettings& settings) | 46 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& setting
s) |
| 47 : WebLayerTreeViewImplForTesting(settings) {} | 47 : WebLayerTreeViewImplForTesting(settings) |
| 48 { |
| 49 } |
| 48 | 50 |
| 49 // cc::LayerTreeHostClient | 51 // cc::LayerTreeHostClient |
| 50 void RequestNewOutputSurface() override | 52 void RequestNewCompositorFrameSink() override |
| 51 { | 53 { |
| 52 layerTreeHost()->SetOutputSurface(cc::FakeOutputSurface::CreateDelegatin
g3d()); | 54 layerTreeHost()->SetCompositorFrameSink(cc::FakeCompositorFrameSink::Cre
ate3d()); |
| 53 } | 55 } |
| 54 }; | 56 }; |
| 55 | 57 |
| 56 class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test { | 58 class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test { |
| 57 protected: | 59 protected: |
| 58 PaintArtifactCompositorTestWithPropertyTrees() | 60 PaintArtifactCompositorTestWithPropertyTrees() |
| 59 : m_taskRunner(new base::TestSimpleTaskRunner) | 61 : m_taskRunner(new base::TestSimpleTaskRunner) |
| 60 , m_taskRunnerHandle(m_taskRunner) | 62 , m_taskRunnerHandle(m_taskRunner) |
| 61 { | 63 { |
| 62 } | 64 } |
| 63 | 65 |
| 64 void SetUp() override | 66 void SetUp() override |
| 65 { | 67 { |
| 66 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 68 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 67 | 69 |
| 68 // Delay constructing the compositor until after the feature is set. | 70 // Delay constructing the compositor until after the feature is set. |
| 69 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); | 71 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); |
| 70 m_paintArtifactCompositor->enableExtraDataForTesting(); | 72 m_paintArtifactCompositor->enableExtraDataForTesting(); |
| 71 | 73 |
| 72 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default
LayerTreeSettings(); | 74 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default
LayerTreeSettings(); |
| 73 settings.single_thread_proxy_scheduler = false; | 75 settings.single_thread_proxy_scheduler = false; |
| 74 settings.use_layer_lists = true; | 76 settings.use_layer_lists = true; |
| 75 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithOutputSurface(se
ttings)); | 77 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithCompositorFrameS
ink(settings)); |
| 76 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer
()); | 78 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer
()); |
| 77 } | 79 } |
| 78 | 80 |
| 79 void TearDown() override | 81 void TearDown() override |
| 80 { | 82 { |
| 81 m_featuresBackup.restore(); | 83 m_featuresBackup.restore(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 const cc::PropertyTrees& propertyTrees() | 86 const cc::PropertyTrees& propertyTrees() |
| 85 { | 87 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 107 cc::Layer* contentLayerAt(unsigned index) | 109 cc::Layer* contentLayerAt(unsigned index) |
| 108 { | 110 { |
| 109 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer
s[index].get(); | 111 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer
s[index].get(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 private: | 114 private: |
| 113 RuntimeEnabledFeatures::Backup m_featuresBackup; | 115 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 114 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; | 116 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; |
| 115 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; | 117 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; |
| 116 base::ThreadTaskRunnerHandle m_taskRunnerHandle; | 118 base::ThreadTaskRunnerHandle m_taskRunnerHandle; |
| 117 std::unique_ptr<WebLayerTreeViewWithOutputSurface> m_webLayerTreeView; | 119 std::unique_ptr<WebLayerTreeViewWithCompositorFrameSink> m_webLayerTreeView; |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) | 122 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) |
| 121 { | 123 { |
| 122 PaintArtifact emptyArtifact; | 124 PaintArtifact emptyArtifact; |
| 123 update(emptyArtifact); | 125 update(emptyArtifact); |
| 124 EXPECT_TRUE(rootLayer()->children().empty()); | 126 EXPECT_TRUE(rootLayer()->children().empty()); |
| 125 } | 127 } |
| 126 | 128 |
| 127 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) | 129 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); | 534 EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id); |
| 533 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); | 535 EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity); |
| 534 | 536 |
| 535 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); | 537 EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index()); |
| 536 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); | 538 EXPECT_EQ(convertedEffect1.id, contentLayerAt(1)->effect_tree_index()); |
| 537 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); | 539 EXPECT_EQ(convertedEffect3.id, contentLayerAt(2)->effect_tree_index()); |
| 538 } | 540 } |
| 539 | 541 |
| 540 } // namespace | 542 } // namespace |
| 541 } // namespace blink | 543 } // namespace blink |
| OLD | NEW |