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 #include "platform/graphics/paint/DisplayItemTransformTreeBuilder.h" | 6 #include "platform/graphics/paint/DisplayItemTransformTreeBuilder.h" |
7 | 7 |
8 #include "platform/graphics/paint/DisplayItem.h" | 8 #include "platform/graphics/paint/DisplayItem.h" |
9 #include "platform/graphics/paint/DisplayItemClient.h" | 9 #include "platform/graphics/paint/DisplayItemClient.h" |
10 #include "platform/graphics/paint/DisplayItemTransformTree.h" | 10 #include "platform/graphics/paint/DisplayItemTransformTree.h" |
11 #include "platform/graphics/paint/Transform3DDisplayItem.h" | 11 #include "platform/graphics/paint/Transform3DDisplayItem.h" |
12 #include "platform/transforms/TransformTestHelper.h" | 12 #include "platform/transforms/TransformTestHelper.h" |
13 #include "platform/transforms/TransformationMatrix.h" | 13 #include "platform/transforms/TransformationMatrix.h" |
14 #include "public/platform/WebDisplayItemTransformTree.h" | 14 #include "public/platform/WebDisplayItemTransformTree.h" |
15 #include <gtest/gtest.h> | 15 #include <gtest/gtest.h> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 namespace { | 18 namespace { |
19 | 19 |
20 using RangeRecord = WebDisplayItemTransformTree::RangeRecord; | 20 using RangeRecord = WebDisplayItemTransformTree::RangeRecord; |
21 | 21 |
22 struct DummyClient { | 22 struct DummyClient { |
23 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi
s); } | 23 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi
s); } |
24 String debugName() const { return "DummyClient"; } | 24 String debugName() const { return "DummyClient"; } |
25 }; | 25 }; |
26 | 26 |
27 class DummyDisplayItem : public DisplayItem { | 27 class DummyDisplayItem : public DisplayItem { |
28 public: | 28 public: |
29 static PassOwnPtr<DummyDisplayItem> create(const DummyClient& client) { retu
rn adoptPtr(new DummyDisplayItem(client)); } | |
30 private: | |
31 DummyDisplayItem(const DummyClient& client) : DisplayItem(client, DisplayIte
m::DrawingFirst) { } | 29 DummyDisplayItem(const DummyClient& client) : DisplayItem(client, DisplayIte
m::DrawingFirst) { } |
32 }; | 30 }; |
33 | 31 |
34 class DisplayItemTransformTreeBuilderTest : public ::testing::Test { | 32 class DisplayItemTransformTreeBuilderTest : public ::testing::Test { |
35 protected: | 33 protected: |
36 DisplayItemTransformTreeBuilder& builder() { return m_builder; } | 34 DisplayItemTransformTreeBuilder& builder() { return m_builder; } |
37 | 35 |
38 void processDisplayItem(const DisplayItem& displayItem) { m_builder.processD
isplayItem(displayItem); } | 36 void processDisplayItem(const DisplayItem& displayItem) { m_builder.processD
isplayItem(displayItem); } |
39 void processDisplayItem(PassOwnPtr<DisplayItem> displayItem) { processDispla
yItem(*displayItem); } | 37 void processDisplayItem(PassOwnPtr<DisplayItem> displayItem) { processDispla
yItem(*displayItem); } |
40 void processDummyDisplayItem() { processDisplayItem(DummyDisplayItem::create
(newDummyClient())); } | 38 void processDummyDisplayItem() { processDisplayItem(DummyDisplayItem(newDumm
yClient())); } |
41 const DummyClient& processBeginTransform3D(const TransformationMatrix& trans
form) | 39 const DummyClient& processBeginTransform3D(const TransformationMatrix& trans
form) |
42 { | 40 { |
43 const DummyClient& client = newDummyClient(); | 41 const DummyClient& client = newDummyClient(); |
44 processDisplayItem(BeginTransform3DDisplayItem::create(client, DisplayIt
em::Transform3DElementTransform, transform)); | 42 processDisplayItem(BeginTransform3DDisplayItem(client, DisplayItem::Tran
sform3DElementTransform, transform)); |
45 return client; | 43 return client; |
46 } | 44 } |
47 void processEndTransform3D(const DummyClient& client) | 45 void processEndTransform3D(const DummyClient& client) |
48 { | 46 { |
49 processDisplayItem(EndTransform3DDisplayItem::create(client, DisplayItem
::transform3DTypeToEndTransform3DType(DisplayItem::Transform3DElementTransform))
); | 47 processDisplayItem(EndTransform3DDisplayItem(client, DisplayItem::transf
orm3DTypeToEndTransform3DType(DisplayItem::Transform3DElementTransform))); |
50 } | 48 } |
51 | 49 |
52 private: | 50 private: |
53 // This makes empty objects which can be used as display item clients. | 51 // This makes empty objects which can be used as display item clients. |
54 const DummyClient& newDummyClient() | 52 const DummyClient& newDummyClient() |
55 { | 53 { |
56 m_dummyClients.append(adoptPtr(new DummyClient)); | 54 m_dummyClients.append(adoptPtr(new DummyClient)); |
57 return *m_dummyClients.last(); | 55 return *m_dummyClients.last(); |
58 } | 56 } |
59 | 57 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 WebDisplayItemTransformTree tree(builder().releaseTransformTree()); | 283 WebDisplayItemTransformTree tree(builder().releaseTransformTree()); |
286 | 284 |
287 const auto& transformNode = tree.nodeAt(tree.rangeRecordAt(0).transformNodeI
ndex); | 285 const auto& transformNode = tree.nodeAt(tree.rangeRecordAt(0).transformNodeI
ndex); |
288 ASSERT_FALSE(transformNode.isRoot()); | 286 ASSERT_FALSE(transformNode.isRoot()); |
289 EXPECT_TRANSFORMS_ALMOST_EQ(matrix2, transformNode.matrix); | 287 EXPECT_TRANSFORMS_ALMOST_EQ(matrix2, transformNode.matrix); |
290 EXPECT_TRANSFORMS_ALMOST_EQ(matrix1, tree.parentNode(transformNode).matrix); | 288 EXPECT_TRANSFORMS_ALMOST_EQ(matrix1, tree.parentNode(transformNode).matrix); |
291 } | 289 } |
292 | 290 |
293 } // namespace | 291 } // namespace |
294 } // namespace blink | 292 } // namespace blink |
OLD | NEW |