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/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 void TearDown() override | 25 void TearDown() override |
26 { | 26 { |
27 m_featuresBackup.restore(); | 27 m_featuresBackup.restore(); |
28 } | 28 } |
29 | 29 |
30 private: | 30 private: |
31 RuntimeEnabledFeatures::Backup m_featuresBackup; | 31 RuntimeEnabledFeatures::Backup m_featuresBackup; |
32 }; | 32 }; |
33 | 33 |
34 class TestDisplayItem : public DisplayItem, public DisplayItemClient { | |
35 public: | |
36 TestDisplayItem(DisplayItem::Type type) : DisplayItem(*this, type, sizeof(*t
his)) { } | |
37 | |
38 void replay(GraphicsContext&) const final { NOTREACHED(); } | |
39 void appendToWebDisplayItemList(const IntRect&, WebDisplayItemList*) const f
inal { NOTREACHED(); } | |
40 String debugName() const final { return "Test"; } | |
41 LayoutRect visualRect() const final { return LayoutRect(); } | |
42 }; | |
43 | |
44 class NormalTestDisplayItem : public TestDisplayItem { | |
45 public: | |
46 NormalTestDisplayItem() : TestDisplayItem(DisplayItem::DrawingFirst) { } | |
47 }; | |
48 | |
49 class TestDisplayItemRequiringSeparateChunk : public TestDisplayItem { | |
50 public: | |
51 TestDisplayItemRequiringSeparateChunk() : TestDisplayItem(DisplayItem::Forei
gnLayerPlugin) { } | |
52 }; | |
53 | |
54 TEST_F(PaintChunkerTest, Empty) | 34 TEST_F(PaintChunkerTest, Empty) |
55 { | 35 { |
56 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); | 36 Vector<PaintChunk> chunks = PaintChunker().releasePaintChunks(); |
57 ASSERT_TRUE(chunks.isEmpty()); | 37 ASSERT_TRUE(chunks.isEmpty()); |
58 } | 38 } |
59 | 39 |
60 TEST_F(PaintChunkerTest, SingleNonEmptyRange) | 40 TEST_F(PaintChunkerTest, SingleNonEmptyRange) |
61 { | 41 { |
62 PaintChunker chunker; | 42 PaintChunker chunker; |
63 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 43 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
64 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 44 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
65 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 45 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
66 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 46 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
67 | 47 |
68 EXPECT_THAT(chunks, ElementsAre( | 48 EXPECT_THAT(chunks, ElementsAre( |
69 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()))); | 49 PaintChunk(0, 2, rootPaintChunkProperties()))); |
70 } | 50 } |
71 | 51 |
72 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) | 52 TEST_F(PaintChunkerTest, SamePropertiesTwiceCombineIntoOneChunk) |
73 { | 53 { |
74 PaintChunker chunker; | 54 PaintChunker chunker; |
75 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 55 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
76 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 56 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
77 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 57 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
78 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 58 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
79 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 59 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
80 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 60 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
81 | 61 |
82 EXPECT_THAT(chunks, ElementsAre( | 62 EXPECT_THAT(chunks, ElementsAre( |
83 PaintChunk(0, 3, nullptr, rootPaintChunkProperties()))); | 63 PaintChunk(0, 3, rootPaintChunkProperties()))); |
84 } | 64 } |
85 | 65 |
86 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) | 66 TEST_F(PaintChunkerTest, CanRewindDisplayItemIndex) |
87 { | 67 { |
88 PaintChunker chunker; | 68 PaintChunker chunker; |
89 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 69 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
90 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 70 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
91 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 71 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
92 chunker.decrementDisplayItemIndex(); | 72 chunker.decrementDisplayItemIndex(); |
93 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 73 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
94 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 74 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
95 | 75 |
96 EXPECT_THAT(chunks, ElementsAre( | 76 EXPECT_THAT(chunks, ElementsAre( |
97 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()))); | 77 PaintChunk(0, 2, rootPaintChunkProperties()))); |
98 } | 78 } |
99 | 79 |
100 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) | 80 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) |
101 { | 81 { |
102 PaintChunker chunker; | 82 PaintChunker chunker; |
103 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 83 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
104 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 84 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
105 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 85 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
106 | 86 |
107 PaintChunkProperties simpleTransform; | 87 PaintChunkProperties simpleTransform; |
108 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 88 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
109 | 89 |
110 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 90 chunker.updateCurrentPaintChunkProperties(simpleTransform); |
111 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 91 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
112 | 92 |
113 PaintChunkProperties anotherTransform; | 93 PaintChunkProperties anotherTransform; |
114 anotherTransform.transform = TransformPaintPropertyNode::create(Transformati
onMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 94 anotherTransform.transform = TransformPaintPropertyNode::create(Transformati
onMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
115 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); | 95 chunker.updateCurrentPaintChunkProperties(anotherTransform); |
116 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 96 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
117 | 97 |
118 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 98 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
119 | 99 |
120 EXPECT_THAT(chunks, ElementsAre( | 100 EXPECT_THAT(chunks, ElementsAre( |
121 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | 101 PaintChunk(0, 2, rootPaintChunkProperties()), |
122 PaintChunk(2, 3, nullptr, simpleTransform), | 102 PaintChunk(2, 3, simpleTransform), |
123 PaintChunk(3, 4, nullptr, anotherTransform))); | 103 PaintChunk(3, 4, anotherTransform))); |
124 } | 104 } |
125 | 105 |
126 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) | 106 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) |
127 { | 107 { |
128 PaintChunker chunker; | 108 PaintChunker chunker; |
129 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 109 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
130 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 110 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
131 | 111 |
132 PaintChunkProperties simpleTransform; | 112 PaintChunkProperties simpleTransform; |
133 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 113 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
134 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 114 chunker.updateCurrentPaintChunkProperties(simpleTransform); |
135 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 115 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
136 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 116 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
137 | 117 |
138 PaintChunkProperties simpleTransformAndEffect; | 118 PaintChunkProperties simpleTransformAndEffect; |
139 simpleTransformAndEffect.transform = simpleTransform.transform; | 119 simpleTransformAndEffect.transform = simpleTransform.transform; |
140 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(0.5f); | 120 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(0.5f); |
141 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect)
; | 121 chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffect); |
142 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 122 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
143 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 123 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
144 | 124 |
145 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; | 125 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; |
146 simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPrope
rtyNode::create(TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); | 126 simpleTransformAndEffectWithUpdatedTransform.transform = TransformPaintPrope
rtyNode::create(TransformationMatrix(1, 1, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); |
147 simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNod
e::create(simpleTransformAndEffect.effect->opacity()); | 127 simpleTransformAndEffectWithUpdatedTransform.effect = EffectPaintPropertyNod
e::create(simpleTransformAndEffect.effect->opacity()); |
148 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffectW
ithUpdatedTransform); | 128 chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffectWithUpdate
dTransform); |
149 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 129 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
150 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 130 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
151 | 131 |
152 // Test that going back to a previous chunk property still creates a new chu
nk. | 132 // Test that going back to a previous chunk property still creates a new chu
nk. |
153 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect)
; | 133 chunker.updateCurrentPaintChunkProperties(simpleTransformAndEffect); |
154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 134 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
155 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 135 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
156 | 136 |
157 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 137 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
158 | 138 |
159 EXPECT_THAT(chunks, ElementsAre( | 139 EXPECT_THAT(chunks, ElementsAre( |
160 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 140 PaintChunk(0, 1, rootPaintChunkProperties()), |
161 PaintChunk(1, 3, nullptr, simpleTransform), | 141 PaintChunk(1, 3, simpleTransform), |
162 PaintChunk(3, 5, nullptr, simpleTransformAndEffect), | 142 PaintChunk(3, 5, simpleTransformAndEffect), |
163 PaintChunk(5, 7, nullptr, simpleTransformAndEffectWithUpdatedTransform), | 143 PaintChunk(5, 7, simpleTransformAndEffectWithUpdatedTransform), |
164 PaintChunk(7, 9, nullptr, simpleTransformAndEffect))); | 144 PaintChunk(7, 9, simpleTransformAndEffect))); |
165 } | 145 } |
166 | 146 |
167 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) | 147 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) |
168 { | 148 { |
169 // Test that "nested" transforms linearize using the following | 149 // Test that "nested" transforms linearize using the following |
170 // sequence of transforms and display items: | 150 // sequence of transforms and display items: |
171 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
</root xform> | 151 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
</root xform> |
172 PaintChunker chunker; | 152 PaintChunker chunker; |
173 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 153 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
174 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 154 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
175 | 155 |
176 PaintChunkProperties simpleTransform; | 156 PaintChunkProperties simpleTransform; |
177 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 157 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
178 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); | 158 chunker.updateCurrentPaintChunkProperties(simpleTransform); |
179 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 159 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
180 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 160 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
181 | 161 |
182 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 162 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
183 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 163 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
184 | 164 |
185 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 165 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
186 | 166 |
187 EXPECT_THAT(chunks, ElementsAre( | 167 EXPECT_THAT(chunks, ElementsAre( |
188 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 168 PaintChunk(0, 1, rootPaintChunkProperties()), |
189 PaintChunk(1, 3, nullptr, simpleTransform), | 169 PaintChunk(1, 3, simpleTransform), |
190 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); | 170 PaintChunk(3, 4, rootPaintChunkProperties()))); |
191 } | 171 } |
192 | 172 |
193 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) | 173 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) |
194 { | 174 { |
195 // Test that properties can change without display items being generated. | 175 // Test that properties can change without display items being generated. |
196 PaintChunker chunker; | 176 PaintChunker chunker; |
197 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 177 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
198 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 178 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
199 | 179 |
200 PaintChunkProperties firstTransform; | 180 PaintChunkProperties firstTransform; |
201 firstTransform.transform = TransformPaintPropertyNode::create(Transformation
Matrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | 181 firstTransform.transform = TransformPaintPropertyNode::create(Transformation
Matrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); |
202 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); | 182 chunker.updateCurrentPaintChunkProperties(firstTransform); |
203 | 183 |
204 PaintChunkProperties secondTransform; | 184 PaintChunkProperties secondTransform; |
205 secondTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); | 185 secondTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); |
206 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); | 186 chunker.updateCurrentPaintChunkProperties(secondTransform); |
207 | 187 |
208 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 188 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
209 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 189 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
210 | 190 |
211 EXPECT_THAT(chunks, ElementsAre( | 191 EXPECT_THAT(chunks, ElementsAre( |
212 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | 192 PaintChunk(0, 1, rootPaintChunkProperties()), |
213 PaintChunk(1, 2, nullptr, secondTransform))); | 193 PaintChunk(1, 2, secondTransform))); |
214 } | 194 } |
215 | 195 |
216 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) | 196 TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) |
217 { | 197 { |
218 // Tests that the chunker creates a separate chunks for display items which | 198 // Tests that the chunker creates a separate chunks for display items which |
219 // require it. | 199 // require it. |
220 PaintChunker chunker; | 200 PaintChunker chunker; |
221 TestDisplayItemRequiringSeparateChunk i1, i2, i3, i4, i5, i6; | 201 chunker.updateCurrentPaintChunkProperties(rootPaintChunkProperties()); |
222 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | 202 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
223 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 203 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); |
224 chunker.incrementDisplayItemIndex(i1); | 204 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); |
225 chunker.incrementDisplayItemIndex(i2); | 205 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); |
226 chunker.incrementDisplayItemIndex(i3); | 206 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
227 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 207 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
228 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 208 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); |
229 chunker.incrementDisplayItemIndex(i4); | 209 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); |
230 chunker.incrementDisplayItemIndex(i5); | |
231 chunker.decrementDisplayItemIndex(); | 210 chunker.decrementDisplayItemIndex(); |
232 chunker.decrementDisplayItemIndex(); | 211 chunker.decrementDisplayItemIndex(); |
233 chunker.decrementDisplayItemIndex(); | 212 chunker.decrementDisplayItemIndex(); |
234 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | 213 chunker.incrementDisplayItemIndex(PaintChunker::DefaultBehavior); |
235 chunker.incrementDisplayItemIndex(i6); | 214 chunker.incrementDisplayItemIndex(PaintChunker::RequiresSeparateChunk); |
236 | |
237 DisplayItem::Id id1 = i1.getId(); | |
238 DisplayItem::Id id2 = i2.getId(); | |
239 DisplayItem::Id id3 = i3.getId(); | |
240 DisplayItem::Id id6 = i6.getId(); | |
241 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | |
242 EXPECT_THAT(chunks, ElementsAre( | |
243 PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), | |
244 PaintChunk(1, 2, &id1, rootPaintChunkProperties()), | |
245 PaintChunk(2, 3, &id2, rootPaintChunkProperties()), | |
246 PaintChunk(3, 4, &id3, rootPaintChunkProperties()), | |
247 PaintChunk(4, 6, nullptr, rootPaintChunkProperties()), | |
248 PaintChunk(6, 7, &id6, rootPaintChunkProperties()))); | |
249 } | |
250 | |
251 TEST_F(PaintChunkerTest, ChunkIds) | |
252 { | |
253 PaintChunker chunker; | |
254 TestDisplayItem i1(DisplayItem::DrawingFirst); | |
255 DisplayItem::Id id1 = i1.getId(); | |
256 TestDisplayItemRequiringSeparateChunk i2; | |
257 DisplayItem::Id id2 = i2.getId(); | |
258 | |
259 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
260 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
261 | |
262 PaintChunkProperties simpleTransform; | |
263 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | |
264 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | |
265 | |
266 chunker.incrementDisplayItemIndex(i1); | |
267 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
268 chunker.incrementDisplayItemIndex(i2); | |
269 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
270 | |
271 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | |
272 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
273 | 215 |
274 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | 216 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); |
275 EXPECT_THAT(chunks, ElementsAre( | 217 EXPECT_THAT(chunks, ElementsAre( |
276 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | 218 PaintChunk(0, 1, rootPaintChunkProperties()), |
277 PaintChunk(2, 4, &id1, simpleTransform), | 219 PaintChunk(1, 2, rootPaintChunkProperties()), |
278 PaintChunk(4, 5, &id2, simpleTransform), | 220 PaintChunk(2, 3, rootPaintChunkProperties()), |
279 PaintChunk(5, 6, nullptr, simpleTransform), | 221 PaintChunk(3, 4, rootPaintChunkProperties()), |
280 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | 222 PaintChunk(4, 6, rootPaintChunkProperties()), |
281 } | 223 PaintChunk(6, 7, rootPaintChunkProperties()))); |
282 | |
283 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) | |
284 { | |
285 PaintChunker chunker; | |
286 TestDisplayItem i1(DisplayItem::DrawingFirst); | |
287 i1.setSkippedCache(); | |
288 DisplayItem::Id id1 = i1.getId(); | |
289 TestDisplayItemRequiringSeparateChunk i2; | |
290 i2.setSkippedCache(); | |
291 | |
292 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
293 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
294 | |
295 PaintChunkProperties simpleTransform; | |
296 simpleTransform.transform = TransformPaintPropertyNode::create(Transformatio
nMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); | |
297 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); | |
298 | |
299 chunker.incrementDisplayItemIndex(i1); | |
300 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
301 chunker.incrementDisplayItemIndex(i2); | |
302 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
303 | |
304 chunker.updateCurrentPaintChunkProperties(nullptr, rootPaintChunkProperties(
)); | |
305 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); | |
306 | |
307 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); | |
308 EXPECT_THAT(chunks, ElementsAre( | |
309 PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), | |
310 PaintChunk(2, 4, nullptr, simpleTransform), | |
311 PaintChunk(4, 5, nullptr, simpleTransform), | |
312 PaintChunk(5, 6, nullptr, simpleTransform), | |
313 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); | |
314 } | 224 } |
315 | 225 |
316 } // namespace | 226 } // namespace |
317 } // namespace blink | 227 } // namespace blink |
OLD | NEW |