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 "platform/graphics/paint/PaintChunker.h" | 5 #include "platform/graphics/paint/PaintChunker.h" |
6 | 6 |
7 #include "platform/testing/PaintPropertyTestHelpers.h" | 7 #include "platform/testing/PaintPropertyTestHelpers.h" |
8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" | 8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 TEST_F(PaintChunkerTest, SingleNonEmptyRange) { | 61 TEST_F(PaintChunkerTest, SingleNonEmptyRange) { |
62 PaintChunker chunker; | 62 PaintChunker chunker; |
63 chunker.updateCurrentPaintChunkProperties(nullptr, | 63 chunker.updateCurrentPaintChunkProperties(nullptr, |
64 defaultPaintChunkProperties()); | 64 defaultPaintChunkProperties()); |
65 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 65 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
66 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 66 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
67 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 67 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
68 | 68 |
69 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, | 69 EXPECT_THAT( |
70 defaultPaintChunkProperties()))); | 70 chunks, |
| 71 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()))); |
71 } | 72 } |
72 | 73 |
73 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) { | 74 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) { |
74 PaintChunker chunker; | 75 PaintChunker chunker; |
75 chunker.updateCurrentPaintChunkProperties(nullptr, | 76 chunker.updateCurrentPaintChunkProperties(nullptr, |
76 defaultPaintChunkProperties()); | 77 defaultPaintChunkProperties()); |
77 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 78 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
78 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 79 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
79 chunker.updateCurrentPaintChunkProperties(nullptr, | 80 chunker.updateCurrentPaintChunkProperties(nullptr, |
80 defaultPaintChunkProperties()); | 81 defaultPaintChunkProperties()); |
81 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 82 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
82 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 83 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
83 | 84 |
84 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 3, nullptr, | 85 EXPECT_THAT( |
85 defaultPaintChunkProperties()))); | 86 chunks, |
| 87 ElementsAre(PaintChunk(0, 3, nullptr, defaultPaintChunkProperties()))); |
86 } | 88 } |
87 | 89 |
88 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) { | 90 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) { |
89 PaintChunker chunker; | 91 PaintChunker chunker; |
90 chunker.updateCurrentPaintChunkProperties(nullptr, | 92 chunker.updateCurrentPaintChunkProperties(nullptr, |
91 defaultPaintChunkProperties()); | 93 defaultPaintChunkProperties()); |
92 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 94 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
93 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 95 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
94 chunker.decrementDisplayItemIndex(); | 96 chunker.decrementDisplayItemIndex(); |
95 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 97 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
96 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 98 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
97 | 99 |
98 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, | 100 EXPECT_THAT( |
99 defaultPaintChunkProperties()))); | 101 chunks, |
| 102 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()))); |
100 } | 103 } |
101 | 104 |
102 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { | 105 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { |
103 PaintChunker chunker; | 106 PaintChunker chunker; |
104 chunker.updateCurrentPaintChunkProperties(nullptr, | 107 chunker.updateCurrentPaintChunkProperties(nullptr, |
105 defaultPaintChunkProperties()); | 108 defaultPaintChunkProperties()); |
106 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 109 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
107 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 110 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
108 | 111 |
109 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); | 112 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); |
(...skipping 10 matching lines...) Expand all Loading... |
120 anotherTransform.propertyTreeState.setTransform( | 123 anotherTransform.propertyTreeState.setTransform( |
121 TransformPaintPropertyNode::create(nullptr, | 124 TransformPaintPropertyNode::create(nullptr, |
122 TransformationMatrix(0, 1, 2, 3, 4, 5), | 125 TransformationMatrix(0, 1, 2, 3, 4, 5), |
123 FloatPoint3D(9, 8, 7)) | 126 FloatPoint3D(9, 8, 7)) |
124 .get()); | 127 .get()); |
125 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); | 128 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); |
126 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 129 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
127 | 130 |
128 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 131 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
129 | 132 |
130 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, | 133 EXPECT_THAT( |
131 defaultPaintChunkProperties()), | 134 chunks, |
132 PaintChunk(2, 3, nullptr, simpleTransform), | 135 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()), |
133 PaintChunk(3, 4, nullptr, anotherTransform))); | 136 PaintChunk(2, 3, nullptr, simpleTransform), |
| 137 PaintChunk(3, 4, nullptr, anotherTransform))); |
134 } | 138 } |
135 | 139 |
136 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { | 140 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { |
137 PaintChunker chunker; | 141 PaintChunker chunker; |
138 chunker.updateCurrentPaintChunkProperties(nullptr, | 142 chunker.updateCurrentPaintChunkProperties(nullptr, |
139 defaultPaintChunkProperties()); | 143 defaultPaintChunkProperties()); |
140 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 144 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
141 | 145 |
142 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); | 146 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); |
143 simpleTransform.propertyTreeState.setTransform( | 147 simpleTransform.propertyTreeState.setTransform( |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 secondTransform.propertyTreeState.setTransform( | 249 secondTransform.propertyTreeState.setTransform( |
246 TransformPaintPropertyNode::create(nullptr, | 250 TransformPaintPropertyNode::create(nullptr, |
247 TransformationMatrix(9, 8, 7, 6, 5, 4), | 251 TransformationMatrix(9, 8, 7, 6, 5, 4), |
248 FloatPoint3D(3, 2, 1)) | 252 FloatPoint3D(3, 2, 1)) |
249 .get()); | 253 .get()); |
250 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); | 254 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); |
251 | 255 |
252 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); | 256 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); |
253 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 257 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
254 | 258 |
255 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 1, nullptr, | 259 EXPECT_THAT( |
256 defaultPaintChunkProperties()), | 260 chunks, |
257 PaintChunk(1, 2, nullptr, secondTransform))); | 261 ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()), |
| 262 PaintChunk(1, 2, nullptr, secondTransform))); |
258 } | 263 } |
259 | 264 |
260 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { | 265 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { |
261 // Tests that the chunker creates a separate chunks for display items which | 266 // Tests that the chunker creates a separate chunks for display items which |
262 // require it. | 267 // require it. |
263 PaintChunker chunker; | 268 PaintChunker chunker; |
264 TestDisplayItemRequiringSeparateChunk i1(m_client); | 269 TestDisplayItemRequiringSeparateChunk i1(m_client); |
265 TestDisplayItemRequiringSeparateChunk i2(m_client); | 270 TestDisplayItemRequiringSeparateChunk i2(m_client); |
266 TestDisplayItemRequiringSeparateChunk i3(m_client); | 271 TestDisplayItemRequiringSeparateChunk i3(m_client); |
267 TestDisplayItemRequiringSeparateChunk i4(m_client); | 272 TestDisplayItemRequiringSeparateChunk i4(m_client); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 chunks, | 378 chunks, |
374 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()), | 379 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()), |
375 PaintChunk(2, 4, nullptr, simpleTransform), | 380 PaintChunk(2, 4, nullptr, simpleTransform), |
376 PaintChunk(4, 5, nullptr, simpleTransform), | 381 PaintChunk(4, 5, nullptr, simpleTransform), |
377 PaintChunk(5, 6, nullptr, simpleTransform), | 382 PaintChunk(5, 6, nullptr, simpleTransform), |
378 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties()))); | 383 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties()))); |
379 } | 384 } |
380 | 385 |
381 } // namespace | 386 } // namespace |
382 } // namespace blink | 387 } // namespace blink |
OLD | NEW |