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

Side by Side Diff: Source/platform/graphics/paint/DisplayItemTransformTreeBuilderTest.cpp

Issue 1193433004: Blink-side contiguous allocation of display items. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Ready for review Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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/DisplayItems.h"
11 #include "platform/graphics/paint/Transform3DDisplayItem.h" 12 #include "platform/graphics/paint/Transform3DDisplayItem.h"
12 #include "platform/transforms/TransformTestHelper.h" 13 #include "platform/transforms/TransformTestHelper.h"
13 #include "platform/transforms/TransformationMatrix.h" 14 #include "platform/transforms/TransformationMatrix.h"
14 #include "public/platform/WebDisplayItemTransformTree.h" 15 #include "public/platform/WebDisplayItemTransformTree.h"
15 #include <gtest/gtest.h> 16 #include <gtest/gtest.h>
16 17
17 namespace blink { 18 namespace blink {
18 namespace { 19 namespace {
19 20
20 using RangeRecord = WebDisplayItemTransformTree::RangeRecord; 21 using RangeRecord = WebDisplayItemTransformTree::RangeRecord;
21 22
22 struct DummyClient { 23 struct DummyClient {
23 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); } 24 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); }
24 String debugName() const { return "DummyClient"; } 25 String debugName() const { return "DummyClient"; }
25 }; 26 };
26 27
27 class DummyDisplayItem : public DisplayItem { 28 class DummyDisplayItem : public DisplayItem {
28 public: 29 public:
29 static PassOwnPtr<DummyDisplayItem> create(const DummyClient& client) { retu rn adoptPtr(new DummyDisplayItem(client)); } 30 DummyDisplayItem(const DummyClient& client) : DisplayItem(client, DisplayIte m::DrawingFirst), m_dummyClient(client) { }
31
32 void appendByMoving(DisplayItems& destination) override
33 {
34 destination.emplaceBack<DummyDisplayItem>(m_dummyClient);
35 }
36
30 private: 37 private:
31 DummyDisplayItem(const DummyClient& client) : DisplayItem(client, DisplayIte m::DrawingFirst) { } 38 const DummyClient& m_dummyClient;
32 }; 39 };
33 40
34 class DisplayItemTransformTreeBuilderTest : public ::testing::Test { 41 class DisplayItemTransformTreeBuilderTest : public ::testing::Test {
35 protected: 42 protected:
36 DisplayItemTransformTreeBuilder& builder() { return m_builder; } 43 DisplayItemTransformTreeBuilder& builder() { return m_builder; }
37 44
38 void processDisplayItem(const DisplayItem& displayItem) { m_builder.processD isplayItem(displayItem); } 45 void processDisplayItem(const DisplayItem& displayItem) { m_builder.processD isplayItem(displayItem); }
39 void processDisplayItem(PassOwnPtr<DisplayItem> displayItem) { processDispla yItem(*displayItem); } 46 void processDisplayItem(PassOwnPtr<DisplayItem> displayItem) { processDispla yItem(*displayItem); }
40 void processDummyDisplayItem() { processDisplayItem(DummyDisplayItem::create (newDummyClient())); } 47 void processDummyDisplayItem() { processDisplayItem(adoptPtr(new DummyDispla yItem(newDummyClient()))); }
41 const DummyClient& processBeginTransform3D(const TransformationMatrix& trans form) 48 const DummyClient& processBeginTransform3D(const TransformationMatrix& trans form)
42 { 49 {
43 const DummyClient& client = newDummyClient(); 50 const DummyClient& client = newDummyClient();
44 processDisplayItem(BeginTransform3DDisplayItem::create(client, DisplayIt em::Transform3DElementTransform, transform)); 51 processDisplayItem(adoptPtr(new BeginTransform3DDisplayItem(client, Disp layItem::Transform3DElementTransform, transform)));
45 return client; 52 return client;
46 } 53 }
47 void processEndTransform3D(const DummyClient& client) 54 void processEndTransform3D(const DummyClient& client)
48 { 55 {
49 processDisplayItem(EndTransform3DDisplayItem::create(client, DisplayItem ::transform3DTypeToEndTransform3DType(DisplayItem::Transform3DElementTransform)) ); 56 processDisplayItem(adoptPtr(new EndTransform3DDisplayItem(client, Displa yItem::transform3DTypeToEndTransform3DType(DisplayItem::Transform3DElementTransf orm))));
50 } 57 }
51 58
52 private: 59 private:
53 // This makes empty objects which can be used as display item clients. 60 // This makes empty objects which can be used as display item clients.
54 const DummyClient& newDummyClient() 61 const DummyClient& newDummyClient()
55 { 62 {
56 m_dummyClients.append(adoptPtr(new DummyClient)); 63 m_dummyClients.append(adoptPtr(new DummyClient));
57 return *m_dummyClients.last(); 64 return *m_dummyClients.last();
58 } 65 }
59 66
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 WebDisplayItemTransformTree tree(builder().releaseTransformTree()); 292 WebDisplayItemTransformTree tree(builder().releaseTransformTree());
286 293
287 const auto& transformNode = tree.nodeAt(tree.rangeRecordAt(0).transformNodeI ndex); 294 const auto& transformNode = tree.nodeAt(tree.rangeRecordAt(0).transformNodeI ndex);
288 ASSERT_FALSE(transformNode.isRoot()); 295 ASSERT_FALSE(transformNode.isRoot());
289 EXPECT_TRANSFORMS_ALMOST_EQ(matrix2, transformNode.matrix); 296 EXPECT_TRANSFORMS_ALMOST_EQ(matrix2, transformNode.matrix);
290 EXPECT_TRANSFORMS_ALMOST_EQ(matrix1, tree.parentNode(transformNode).matrix); 297 EXPECT_TRANSFORMS_ALMOST_EQ(matrix1, tree.parentNode(transformNode).matrix);
291 } 298 }
292 299
293 } // namespace 300 } // namespace
294 } // namespace blink 301 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698