| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
| 8 #include "core/layout/LayoutView.h" | 8 #include "core/page/Page.h" |
| 9 #include "core/paint/DeprecatedPaintLayer.h" | 9 #include "core/paint/DeprecatedPaintLayer.h" |
| 10 #include "platform/graphics/CompositedDisplayList.h" |
| 10 #include "platform/graphics/GraphicsLayer.h" | 11 #include "platform/graphics/GraphicsLayer.h" |
| 11 #include "platform/transforms/TransformTestHelper.h" | 12 #include "platform/transforms/TransformTestHelper.h" |
| 12 #include "platform/transforms/TransformationMatrix.h" | 13 #include "platform/transforms/TransformationMatrix.h" |
| 13 #include <gtest/gtest.h> | 14 #include <gtest/gtest.h> |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 class DisplayListCompositingTest : public RenderingTest { | 19 class DisplayListCompositingTest : public RenderingTest { |
| 19 public: | 20 public: |
| 20 DisplayListCompositingTest() | 21 DisplayListCompositingTest() |
| 21 : m_layoutView(nullptr) | 22 : m_page(nullptr) |
| 22 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } | 23 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint
V2Enabled()) { } |
| 23 | 24 |
| 24 protected: | 25 protected: |
| 25 LayoutView& layoutView() { return *m_layoutView; } | 26 Page& page() { return *m_page; } |
| 26 | 27 |
| 27 private: | 28 private: |
| 28 void SetUp() override | 29 void SetUp() override |
| 29 { | 30 { |
| 30 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); | 31 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
| 31 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); | 32 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); |
| 32 | 33 |
| 33 RenderingTest::SetUp(); | 34 RenderingTest::SetUp(); |
| 34 enableCompositing(); | 35 enableCompositing(); |
| 35 | 36 |
| 36 m_layoutView = document().view()->layoutView(); | 37 m_page = document().page(); |
| 37 ASSERT_TRUE(m_layoutView); | 38 ASSERT_TRUE(m_page); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void TearDown() override | 41 void TearDown() override |
| 41 { | 42 { |
| 42 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); | 43 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPain
tV2Enabled); |
| 43 } | 44 } |
| 44 | 45 |
| 45 LayoutView* m_layoutView; | 46 Page* m_page; |
| 46 bool m_originalSlimmingPaintV2Enabled; | 47 bool m_originalSlimmingPaintV2Enabled; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 TEST_F(DisplayListCompositingTest, TransformTreeBuildingNoTransforms) | 50 TEST_F(DisplayListCompositingTest, TransformTreeBuildingNoTransforms) |
| 50 { | 51 { |
| 51 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div>A</div>"); | 52 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div>A</div>"); |
| 52 const auto* compositedDisplayList = layoutView().compositedDisplayList(); | 53 auto* compositedDisplayList = page().compositedDisplayListForTesting(); |
| 54 ASSERT_TRUE(compositedDisplayList); |
| 53 auto* tree = compositedDisplayList->transformTree.get(); | 55 auto* tree = compositedDisplayList->transformTree.get(); |
| 54 | 56 |
| 55 // There should only be a root transform node. | 57 // There should only be a root transform node. |
| 56 ASSERT_EQ(1u, tree->nodeCount()); | 58 ASSERT_EQ(1u, tree->nodeCount()); |
| 57 EXPECT_TRUE(tree->nodeAt(0).isRoot()); | 59 EXPECT_TRUE(tree->nodeAt(0).isRoot()); |
| 58 EXPECT_TRUE(tree->nodeAt(0).matrix.isIdentity()); | 60 EXPECT_TRUE(tree->nodeAt(0).matrix.isIdentity()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 TEST_F(DisplayListCompositingTest, TransformTreeBuildingMultipleTransforms) | 63 TEST_F(DisplayListCompositingTest, TransformTreeBuildingMultipleTransforms) |
| 62 { | 64 { |
| 63 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"tra
nsform: translate3d(2px,3px,4px);\">X</div>"); | 65 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"tra
nsform: translate3d(2px,3px,4px);\">X</div>"); |
| 64 const auto* compositedDisplayList = layoutView().compositedDisplayList(); | 66 auto* compositedDisplayList = page().compositedDisplayListForTesting(); |
| 67 ASSERT_TRUE(compositedDisplayList); |
| 65 auto* tree = compositedDisplayList->transformTree.get(); | 68 auto* tree = compositedDisplayList->transformTree.get(); |
| 66 | 69 |
| 67 ASSERT_EQ(2u, tree->nodeCount()); | 70 ASSERT_EQ(2u, tree->nodeCount()); |
| 68 EXPECT_TRUE(tree->nodeAt(0).isRoot()); | 71 EXPECT_TRUE(tree->nodeAt(0).isRoot()); |
| 69 EXPECT_FALSE(tree->nodeAt(1).isRoot()); | 72 EXPECT_FALSE(tree->nodeAt(1).isRoot()); |
| 70 | 73 |
| 71 TransformationMatrix matrix; | 74 TransformationMatrix matrix; |
| 72 matrix.translate3d(2, 3, 4); | 75 matrix.translate3d(2, 3, 4); |
| 73 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); | 76 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); |
| 74 | 77 |
| 75 // Add a nested 3d transform. | 78 // Add a nested 3d transform. |
| 76 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"tra
nsform: translate3d(2px,3px,4px);\"><div style=\"transform: translate3d(5px,6px,
7px);\">X</div></div>"); | 79 setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"tra
nsform: translate3d(2px,3px,4px);\"><div style=\"transform: translate3d(5px,6px,
7px);\">X</div></div>"); |
| 77 compositedDisplayList = layoutView().compositedDisplayList(); | 80 compositedDisplayList = page().compositedDisplayListForTesting(); |
| 81 ASSERT_TRUE(compositedDisplayList); |
| 78 tree = compositedDisplayList->transformTree.get(); | 82 tree = compositedDisplayList->transformTree.get(); |
| 79 | 83 |
| 80 ASSERT_EQ(3u, tree->nodeCount()); | 84 ASSERT_EQ(3u, tree->nodeCount()); |
| 81 EXPECT_TRUE(tree->nodeAt(0).isRoot()); | 85 EXPECT_TRUE(tree->nodeAt(0).isRoot()); |
| 82 EXPECT_FALSE(tree->nodeAt(1).isRoot()); | 86 EXPECT_FALSE(tree->nodeAt(1).isRoot()); |
| 83 EXPECT_FALSE(tree->nodeAt(2).isRoot()); | 87 EXPECT_FALSE(tree->nodeAt(2).isRoot()); |
| 84 | 88 |
| 85 matrix.makeIdentity(); | 89 matrix.makeIdentity(); |
| 86 matrix.translate3d(2, 3, 4); | 90 matrix.translate3d(2, 3, 4); |
| 87 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); | 91 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix); |
| 88 | 92 |
| 89 matrix.makeIdentity(); | 93 matrix.makeIdentity(); |
| 90 matrix.translate3d(5, 6, 7); | 94 matrix.translate3d(5, 6, 7); |
| 91 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(2).matrix); | 95 EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(2).matrix); |
| 92 } | 96 } |
| 93 | 97 |
| 94 } | 98 } |
| 95 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |