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