| 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/scroll_node.h" | 15 #include "cc/trees/scroll_node.h" |
| 16 #include "cc/trees/transform_node.h" | 16 #include "cc/trees/transform_node.h" |
| 17 #include "platform/RuntimeEnabledFeatures.h" | 17 #include "platform/RuntimeEnabledFeatures.h" |
| 18 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 18 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 19 #include "platform/graphics/paint/PaintArtifact.h" | 19 #include "platform/graphics/paint/PaintArtifact.h" |
| 20 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 20 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 36 transform.Translate(x, y); | 36 transform.Translate(x, y); |
| 37 return transform; | 37 return transform; |
| 38 } | 38 } |
| 39 | 39 |
| 40 EffectPaintPropertyNode* dummyRootEffect() | 40 EffectPaintPropertyNode* dummyRootEffect() |
| 41 { | 41 { |
| 42 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr
eate(nullptr, 1.0)); | 42 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, EffectPaintPropertyNode::cr
eate(nullptr, 1.0)); |
| 43 return node; | 43 return node; |
| 44 } | 44 } |
| 45 | 45 |
| 46 class WebLayerTreeViewWithOutputSurface : public WebLayerTreeViewImplForTesting
{ | 46 class WebLayerTreeViewWithCompositorFrameSink : public WebLayerTreeViewImplForTe
sting { |
| 47 public: | 47 public: |
| 48 WebLayerTreeViewWithOutputSurface(const cc::LayerTreeSettings& settings) | 48 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& setting
s) |
| 49 : WebLayerTreeViewImplForTesting(settings) {} | 49 : WebLayerTreeViewImplForTesting(settings) |
| 50 { |
| 51 } |
| 50 | 52 |
| 51 // cc::LayerTreeHostClient | 53 // cc::LayerTreeHostClient |
| 52 void RequestNewOutputSurface() override | 54 void RequestNewCompositorFrameSink() override |
| 53 { | 55 { |
| 54 layerTreeHost()->SetOutputSurface(cc::FakeOutputSurface::CreateDelegatin
g3d()); | 56 layerTreeHost()->SetCompositorFrameSink(cc::FakeCompositorFrameSink::Cre
ate3d()); |
| 55 } | 57 } |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test { | 60 class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test { |
| 59 protected: | 61 protected: |
| 60 PaintArtifactCompositorTestWithPropertyTrees() | 62 PaintArtifactCompositorTestWithPropertyTrees() |
| 61 : m_taskRunner(new base::TestSimpleTaskRunner) | 63 : m_taskRunner(new base::TestSimpleTaskRunner) |
| 62 , m_taskRunnerHandle(m_taskRunner) | 64 , m_taskRunnerHandle(m_taskRunner) |
| 63 { | 65 { |
| 64 } | 66 } |
| 65 | 67 |
| 66 void SetUp() override | 68 void SetUp() override |
| 67 { | 69 { |
| 68 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 70 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 69 | 71 |
| 70 // Delay constructing the compositor until after the feature is set. | 72 // Delay constructing the compositor until after the feature is set. |
| 71 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); | 73 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); |
| 72 m_paintArtifactCompositor->enableExtraDataForTesting(); | 74 m_paintArtifactCompositor->enableExtraDataForTesting(); |
| 73 | 75 |
| 74 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default
LayerTreeSettings(); | 76 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default
LayerTreeSettings(); |
| 75 settings.single_thread_proxy_scheduler = false; | 77 settings.single_thread_proxy_scheduler = false; |
| 76 settings.use_layer_lists = true; | 78 settings.use_layer_lists = true; |
| 77 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithOutputSurface(se
ttings)); | 79 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithCompositorFrameS
ink(settings)); |
| 78 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer
()); | 80 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer
()); |
| 79 } | 81 } |
| 80 | 82 |
| 81 void TearDown() override | 83 void TearDown() override |
| 82 { | 84 { |
| 83 m_featuresBackup.restore(); | 85 m_featuresBackup.restore(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 const cc::PropertyTrees& propertyTrees() | 88 const cc::PropertyTrees& propertyTrees() |
| 87 { | 89 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 109 cc::Layer* contentLayerAt(unsigned index) | 111 cc::Layer* contentLayerAt(unsigned index) |
| 110 { | 112 { |
| 111 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer
s[index].get(); | 113 return m_paintArtifactCompositor->getExtraDataForTesting()->contentLayer
s[index].get(); |
| 112 } | 114 } |
| 113 | 115 |
| 114 private: | 116 private: |
| 115 RuntimeEnabledFeatures::Backup m_featuresBackup; | 117 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 116 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; | 118 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; |
| 117 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; | 119 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; |
| 118 base::ThreadTaskRunnerHandle m_taskRunnerHandle; | 120 base::ThreadTaskRunnerHandle m_taskRunnerHandle; |
| 119 std::unique_ptr<WebLayerTreeViewWithOutputSurface> m_webLayerTreeView; | 121 std::unique_ptr<WebLayerTreeViewWithCompositorFrameSink> m_webLayerTreeView; |
| 120 }; | 122 }; |
| 121 | 123 |
| 122 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) | 124 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) |
| 123 { | 125 { |
| 124 PaintArtifact emptyArtifact; | 126 PaintArtifact emptyArtifact; |
| 125 update(emptyArtifact); | 127 update(emptyArtifact); |
| 126 EXPECT_TRUE(rootLayer()->children().empty()); | 128 EXPECT_TRUE(rootLayer()->children().empty()); |
| 127 } | 129 } |
| 128 | 130 |
| 129 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) | 131 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 EXPECT_TRUE(transformNodeA.local.IsIdentity()); | 611 EXPECT_TRUE(transformNodeA.local.IsIdentity()); |
| 610 const cc::TransformNode& transformNodeB = *transformTree.Node(scrollNodeB.tr
ansform_id); | 612 const cc::TransformNode& transformNodeB = *transformTree.Node(scrollNodeB.tr
ansform_id); |
| 611 EXPECT_TRUE(transformNodeB.local.IsIdentity()); | 613 EXPECT_TRUE(transformNodeB.local.IsIdentity()); |
| 612 | 614 |
| 613 EXPECT_EQ(gfx::ScrollOffset(-11, -13), scrollTree.current_scroll_offset(cont
entLayerAt(0)->id())); | 615 EXPECT_EQ(gfx::ScrollOffset(-11, -13), scrollTree.current_scroll_offset(cont
entLayerAt(0)->id())); |
| 614 EXPECT_EQ(gfx::ScrollOffset(-37, -41), scrollTree.current_scroll_offset(cont
entLayerAt(1)->id())); | 616 EXPECT_EQ(gfx::ScrollOffset(-37, -41), scrollTree.current_scroll_offset(cont
entLayerAt(1)->id())); |
| 615 } | 617 } |
| 616 | 618 |
| 617 } // namespace | 619 } // namespace |
| 618 } // namespace blink | 620 } // namespace blink |
| OLD | NEW |