Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Unified Diff: Source/core/compositing/DisplayListCompositingTest.cpp

Issue 1287093004: Slimming Paint phase 2 compositing algorithm plumbing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase from space Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/compositing/DisplayListCompositingBuilderTest.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/compositing/DisplayListCompositingTest.cpp
diff --git a/Source/core/compositing/DisplayListCompositingTest.cpp b/Source/core/compositing/DisplayListCompositingTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..39ddb52f83c887d2b0cd3c115be501c48baebd77
--- /dev/null
+++ b/Source/core/compositing/DisplayListCompositingTest.cpp
@@ -0,0 +1,95 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "core/layout/LayoutTestHelper.h"
+#include "core/layout/LayoutView.h"
+#include "core/paint/DeprecatedPaintLayer.h"
+#include "platform/graphics/GraphicsLayer.h"
+#include "platform/transforms/TransformTestHelper.h"
+#include "platform/transforms/TransformationMatrix.h"
+#include <gtest/gtest.h>
+
+namespace blink {
+namespace {
+
+class DisplayListCompositingTest : public RenderingTest {
+public:
+ DisplayListCompositingTest()
+ : m_layoutView(nullptr)
+ , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { }
+
+protected:
+ LayoutView& layoutView() { return *m_layoutView; }
+
+private:
+ void SetUp() override
+ {
+ ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled());
+ RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
+
+ RenderingTest::SetUp();
+ enableCompositing();
+
+ m_layoutView = document().view()->layoutView();
+ ASSERT_TRUE(m_layoutView);
+ }
+
+ void TearDown() override
+ {
+ RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(m_originalSlimmingPaintV2Enabled);
+ }
+
+ LayoutView* m_layoutView;
+ bool m_originalSlimmingPaintV2Enabled;
+};
+
+TEST_F(DisplayListCompositingTest, TransformTreeBuildingNoTransforms)
+{
+ setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div>A</div>");
+ const auto* compositedDisplayList = layoutView().compositedDisplayList();
+ auto* tree = compositedDisplayList->transformTree.get();
+
+ // There should only be a root transform node.
+ ASSERT_EQ(1u, tree->nodeCount());
+ EXPECT_TRUE(tree->nodeAt(0).isRoot());
+ EXPECT_TRUE(tree->nodeAt(0).matrix.isIdentity());
+}
+
+TEST_F(DisplayListCompositingTest, TransformTreeBuildingMultipleTransforms)
+{
+ setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"transform: translate3d(2px,3px,4px);\">X</div>");
+ const auto* compositedDisplayList = layoutView().compositedDisplayList();
+ auto* tree = compositedDisplayList->transformTree.get();
+
+ ASSERT_EQ(2u, tree->nodeCount());
+ EXPECT_TRUE(tree->nodeAt(0).isRoot());
+ EXPECT_FALSE(tree->nodeAt(1).isRoot());
+
+ TransformationMatrix matrix;
+ matrix.translate3d(2, 3, 4);
+ EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix);
+
+ // Add a nested 3d transform.
+ setBodyInnerHTML("<style>* { margin: 0; padding: 0;}</style><div style=\"transform: translate3d(2px,3px,4px);\"><div style=\"transform: translate3d(5px,6px,7px);\">X</div></div>");
+ compositedDisplayList = layoutView().compositedDisplayList();
+ tree = compositedDisplayList->transformTree.get();
+
+ ASSERT_EQ(3u, tree->nodeCount());
+ EXPECT_TRUE(tree->nodeAt(0).isRoot());
+ EXPECT_FALSE(tree->nodeAt(1).isRoot());
+ EXPECT_FALSE(tree->nodeAt(2).isRoot());
+
+ matrix.makeIdentity();
+ matrix.translate3d(2, 3, 4);
+ EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(1).matrix);
+
+ matrix.makeIdentity();
+ matrix.translate3d(5, 6, 7);
+ EXPECT_TRANSFORMS_ALMOST_EQ(matrix, tree->nodeAt(2).matrix);
+}
+
+}
+} // namespace blink
« no previous file with comments | « Source/core/compositing/DisplayListCompositingBuilderTest.cpp ('k') | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698