| 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_compositor_frame_sink.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/layer_tree_settings.h" | 15 #include "cc/trees/layer_tree_settings.h" |
| 16 #include "cc/trees/scroll_node.h" | 16 #include "cc/trees/scroll_node.h" |
| 17 #include "cc/trees/transform_node.h" | 17 #include "cc/trees/transform_node.h" |
| 18 #include "platform/RuntimeEnabledFeatures.h" | |
| 19 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 18 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 20 #include "platform/graphics/paint/PaintArtifact.h" | 19 #include "platform/graphics/paint/PaintArtifact.h" |
| 21 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 20 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 22 #include "platform/testing/PaintPropertyTestHelpers.h" | 21 #include "platform/testing/PaintPropertyTestHelpers.h" |
| 23 #include "platform/testing/PictureMatchers.h" | 22 #include "platform/testing/PictureMatchers.h" |
| 23 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 24 #include "platform/testing/TestPaintArtifact.h" | 24 #include "platform/testing/TestPaintArtifact.h" |
| 25 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 25 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 #include <memory> | 28 #include <memory> |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 using ::blink::testing::createOpacityOnlyEffect; | 33 using ::blink::testing::createOpacityOnlyEffect; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 52 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) | 52 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) |
| 53 : WebLayerTreeViewImplForTesting(settings) {} | 53 : WebLayerTreeViewImplForTesting(settings) {} |
| 54 | 54 |
| 55 // cc::LayerTreeHostClient | 55 // cc::LayerTreeHostClient |
| 56 void RequestNewCompositorFrameSink() override { | 56 void RequestNewCompositorFrameSink() override { |
| 57 layerTreeHost()->SetCompositorFrameSink( | 57 layerTreeHost()->SetCompositorFrameSink( |
| 58 cc::FakeCompositorFrameSink::Create3d()); | 58 cc::FakeCompositorFrameSink::Create3d()); |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class PaintArtifactCompositorTestWithPropertyTrees : public ::testing::Test { | 62 class PaintArtifactCompositorTestWithPropertyTrees |
| 63 : public ::testing::Test, |
| 64 private ScopedSlimmingPaintV2ForTest { |
| 63 protected: | 65 protected: |
| 64 PaintArtifactCompositorTestWithPropertyTrees() | 66 PaintArtifactCompositorTestWithPropertyTrees() |
| 65 : m_taskRunner(new base::TestSimpleTaskRunner), | 67 : ScopedSlimmingPaintV2ForTest(true), |
| 68 m_taskRunner(new base::TestSimpleTaskRunner), |
| 66 m_taskRunnerHandle(m_taskRunner) {} | 69 m_taskRunnerHandle(m_taskRunner) {} |
| 67 | 70 |
| 68 void SetUp() override { | 71 void SetUp() override { |
| 69 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | |
| 70 | |
| 71 // Delay constructing the compositor until after the feature is set. | 72 // Delay constructing the compositor until after the feature is set. |
| 72 m_paintArtifactCompositor = PaintArtifactCompositor::create(); | 73 m_paintArtifactCompositor = PaintArtifactCompositor::create(); |
| 73 m_paintArtifactCompositor->enableExtraDataForTesting(); | 74 m_paintArtifactCompositor->enableExtraDataForTesting(); |
| 74 | 75 |
| 75 cc::LayerTreeSettings settings = | 76 cc::LayerTreeSettings settings = |
| 76 WebLayerTreeViewImplForTesting::defaultLayerTreeSettings(); | 77 WebLayerTreeViewImplForTesting::defaultLayerTreeSettings(); |
| 77 settings.single_thread_proxy_scheduler = false; | 78 settings.single_thread_proxy_scheduler = false; |
| 78 settings.use_layer_lists = true; | 79 settings.use_layer_lists = true; |
| 79 m_webLayerTreeView = | 80 m_webLayerTreeView = |
| 80 WTF::makeUnique<WebLayerTreeViewWithCompositorFrameSink>(settings); | 81 WTF::makeUnique<WebLayerTreeViewWithCompositorFrameSink>(settings); |
| 81 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer()); | 82 m_webLayerTreeView->setRootLayer(*m_paintArtifactCompositor->getWebLayer()); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void TearDown() override { m_featuresBackup.restore(); } | |
| 85 | |
| 86 const cc::PropertyTrees& propertyTrees() { | 85 const cc::PropertyTrees& propertyTrees() { |
| 87 return *m_webLayerTreeView->layerTreeHost() | 86 return *m_webLayerTreeView->layerTreeHost() |
| 88 ->GetLayerTree() | 87 ->GetLayerTree() |
| 89 ->property_trees(); | 88 ->property_trees(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 const cc::TransformNode& transformNode(const cc::Layer* layer) { | 91 const cc::TransformNode& transformNode(const cc::Layer* layer) { |
| 93 return *propertyTrees().transform_tree.Node(layer->transform_tree_index()); | 92 return *propertyTrees().transform_tree.Node(layer->transform_tree_index()); |
| 94 } | 93 } |
| 95 | 94 |
| 96 void update(const PaintArtifact& artifact) { | 95 void update(const PaintArtifact& artifact) { |
| 97 m_paintArtifactCompositor->update(artifact, nullptr, false); | 96 m_paintArtifactCompositor->update(artifact, nullptr, false); |
| 98 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers(); | 97 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers(); |
| 99 } | 98 } |
| 100 | 99 |
| 101 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); } | 100 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); } |
| 102 | 101 |
| 103 size_t contentLayerCount() { | 102 size_t contentLayerCount() { |
| 104 return m_paintArtifactCompositor->getExtraDataForTesting() | 103 return m_paintArtifactCompositor->getExtraDataForTesting() |
| 105 ->contentLayers.size(); | 104 ->contentLayers.size(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 cc::Layer* contentLayerAt(unsigned index) { | 107 cc::Layer* contentLayerAt(unsigned index) { |
| 109 return m_paintArtifactCompositor->getExtraDataForTesting() | 108 return m_paintArtifactCompositor->getExtraDataForTesting() |
| 110 ->contentLayers[index] | 109 ->contentLayers[index] |
| 111 .get(); | 110 .get(); |
| 112 } | 111 } |
| 113 | 112 |
| 114 private: | 113 private: |
| 115 RuntimeEnabledFeatures::Backup m_featuresBackup; | |
| 116 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; | 114 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; |
| 117 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; | 115 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; |
| 118 base::ThreadTaskRunnerHandle m_taskRunnerHandle; | 116 base::ThreadTaskRunnerHandle m_taskRunnerHandle; |
| 119 std::unique_ptr<WebLayerTreeViewWithCompositorFrameSink> m_webLayerTreeView; | 117 std::unique_ptr<WebLayerTreeViewWithCompositorFrameSink> m_webLayerTreeView; |
| 120 }; | 118 }; |
| 121 | 119 |
| 122 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) { | 120 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) { |
| 123 PaintArtifact emptyArtifact; | 121 PaintArtifact emptyArtifact; |
| 124 update(emptyArtifact); | 122 update(emptyArtifact); |
| 125 EXPECT_TRUE(rootLayer()->children().empty()); | 123 EXPECT_TRUE(rootLayer()->children().empty()); |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); | 713 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); |
| 716 | 714 |
| 717 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & | 715 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & |
| 718 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 716 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 719 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & | 717 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & |
| 720 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 718 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 721 } | 719 } |
| 722 | 720 |
| 723 } // namespace | 721 } // namespace |
| 724 } // namespace blink | 722 } // namespace blink |
| OLD | NEW |