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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintChunkerTest.cpp

Issue 2573883002: Refactor PaintChunkProperties to use PropertyTreeState (Closed)
Patch Set: none Created 4 years 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 "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 "platform/testing/PaintPropertyTestHelpers.h" 8 #include "platform/testing/PaintPropertyTestHelpers.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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { 108 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
109 PaintChunker chunker; 109 PaintChunker chunker;
110 chunker.updateCurrentPaintChunkProperties(nullptr, 110 chunker.updateCurrentPaintChunkProperties(nullptr,
111 defaultPaintChunkProperties()); 111 defaultPaintChunkProperties());
112 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 112 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
113 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 113 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
114 114
115 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); 115 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
116 simpleTransform.transform = TransformPaintPropertyNode::create( 116 simpleTransform.propertyTreeState.setTransform(
117 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 117 TransformPaintPropertyNode::create(nullptr,
118 TransformationMatrix(0, 1, 2, 3, 4, 5),
119 FloatPoint3D(9, 8, 7))
120 .get());
118 121
119 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 122 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
120 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 123 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
121 124
122 PaintChunkProperties anotherTransform = defaultPaintChunkProperties(); 125 PaintChunkProperties anotherTransform = defaultPaintChunkProperties();
123 anotherTransform.transform = TransformPaintPropertyNode::create( 126 anotherTransform.propertyTreeState.setTransform(
124 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 127 TransformPaintPropertyNode::create(nullptr,
128 TransformationMatrix(0, 1, 2, 3, 4, 5),
129 FloatPoint3D(9, 8, 7))
130 .get());
125 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); 131 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
126 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 132 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
127 133
128 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 134 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
129 135
130 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr, 136 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 2, nullptr,
131 defaultPaintChunkProperties()), 137 defaultPaintChunkProperties()),
132 PaintChunk(2, 3, nullptr, simpleTransform), 138 PaintChunk(2, 3, nullptr, simpleTransform),
133 PaintChunk(3, 4, nullptr, anotherTransform))); 139 PaintChunk(3, 4, nullptr, anotherTransform)));
134 } 140 }
135 141
136 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { 142 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
137 PaintChunker chunker; 143 PaintChunker chunker;
138 chunker.updateCurrentPaintChunkProperties(nullptr, 144 chunker.updateCurrentPaintChunkProperties(nullptr,
139 defaultPaintChunkProperties()); 145 defaultPaintChunkProperties());
140 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
141 147
142 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); 148 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
143 simpleTransform.transform = TransformPaintPropertyNode::create( 149 simpleTransform.propertyTreeState.setTransform(
144 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); 150 TransformPaintPropertyNode::create(nullptr,
151 TransformationMatrix(0, 0, 0, 0, 0, 0),
152 FloatPoint3D(9, 8, 7))
153 .get());
145 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 154 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 155 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
147 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 156 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
148 157
149 PaintChunkProperties simpleTransformAndEffect = defaultPaintChunkProperties(); 158 PaintChunkProperties simpleTransformAndEffect = defaultPaintChunkProperties();
150 simpleTransformAndEffect.transform = simpleTransform.transform; 159 simpleTransformAndEffect.propertyTreeState.setTransform(
151 simpleTransformAndEffect.effect = 160 simpleTransform.propertyTreeState.transform());
152 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f); 161 simpleTransformAndEffect.propertyTreeState.setEffect(
162 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f).get());
153 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 163 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 164 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
155 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 165 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
156 166
157 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform = 167 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform =
158 defaultPaintChunkProperties(); 168 defaultPaintChunkProperties();
159 simpleTransformAndEffectWithUpdatedTransform.transform = 169 simpleTransformAndEffectWithUpdatedTransform.propertyTreeState.setTransform(
160 TransformPaintPropertyNode::create(nullptr, 170 TransformPaintPropertyNode::create(nullptr,
161 TransformationMatrix(1, 1, 0, 0, 0, 0), 171 TransformationMatrix(1, 1, 0, 0, 0, 0),
162 FloatPoint3D(9, 8, 7)); 172 FloatPoint3D(9, 8, 7))
163 simpleTransformAndEffectWithUpdatedTransform.effect = 173 .get());
164 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 174 simpleTransformAndEffectWithUpdatedTransform.propertyTreeState.setEffect(
165 simpleTransformAndEffect.effect->opacity()); 175 createOpacityOnlyEffect(
176 EffectPaintPropertyNode::root(),
177 simpleTransformAndEffect.propertyTreeState.effect()->opacity())
178 .get());
166 chunker.updateCurrentPaintChunkProperties( 179 chunker.updateCurrentPaintChunkProperties(
167 nullptr, simpleTransformAndEffectWithUpdatedTransform); 180 nullptr, simpleTransformAndEffectWithUpdatedTransform);
168 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 181 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
169 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 182 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
170 183
171 // Test that going back to a previous chunk property still creates a new 184 // Test that going back to a previous chunk property still creates a new
172 // chunk. 185 // chunk.
173 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 186 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
174 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 187 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
175 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 188 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
(...skipping 14 matching lines...) Expand all
190 // Test that "nested" transforms linearize using the following 203 // Test that "nested" transforms linearize using the following
191 // sequence of transforms and display items: 204 // sequence of transforms and display items:
192 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, 205 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
193 // </root xform> 206 // </root xform>
194 PaintChunker chunker; 207 PaintChunker chunker;
195 chunker.updateCurrentPaintChunkProperties(nullptr, 208 chunker.updateCurrentPaintChunkProperties(nullptr,
196 defaultPaintChunkProperties()); 209 defaultPaintChunkProperties());
197 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 210 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
198 211
199 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); 212 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
200 simpleTransform.transform = TransformPaintPropertyNode::create( 213 simpleTransform.propertyTreeState.setTransform(
201 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 214 TransformPaintPropertyNode::create(nullptr,
215 TransformationMatrix(0, 1, 2, 3, 4, 5),
216 FloatPoint3D(9, 8, 7))
217 .get());
202 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 218 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
203 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 219 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
204 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 220 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
205 221
206 chunker.updateCurrentPaintChunkProperties(nullptr, 222 chunker.updateCurrentPaintChunkProperties(nullptr,
207 defaultPaintChunkProperties()); 223 defaultPaintChunkProperties());
208 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 224 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
209 225
210 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 226 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
211 227
212 EXPECT_THAT( 228 EXPECT_THAT(
213 chunks, 229 chunks,
214 ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()), 230 ElementsAre(PaintChunk(0, 1, nullptr, defaultPaintChunkProperties()),
215 PaintChunk(1, 3, nullptr, simpleTransform), 231 PaintChunk(1, 3, nullptr, simpleTransform),
216 PaintChunk(3, 4, nullptr, defaultPaintChunkProperties()))); 232 PaintChunk(3, 4, nullptr, defaultPaintChunkProperties())));
217 } 233 }
218 234
219 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { 235 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
220 // Test that properties can change without display items being generated. 236 // Test that properties can change without display items being generated.
221 PaintChunker chunker; 237 PaintChunker chunker;
222 chunker.updateCurrentPaintChunkProperties(nullptr, 238 chunker.updateCurrentPaintChunkProperties(nullptr,
223 defaultPaintChunkProperties()); 239 defaultPaintChunkProperties());
224 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 240 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
225 241
226 PaintChunkProperties firstTransform = defaultPaintChunkProperties(); 242 PaintChunkProperties firstTransform = defaultPaintChunkProperties();
227 firstTransform.transform = TransformPaintPropertyNode::create( 243 firstTransform.propertyTreeState.setTransform(
228 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 244 TransformPaintPropertyNode::create(nullptr,
245 TransformationMatrix(0, 1, 2, 3, 4, 5),
246 FloatPoint3D(9, 8, 7))
247 .get());
229 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); 248 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
230 249
231 PaintChunkProperties secondTransform = defaultPaintChunkProperties(); 250 PaintChunkProperties secondTransform = defaultPaintChunkProperties();
232 secondTransform.transform = TransformPaintPropertyNode::create( 251 secondTransform.propertyTreeState.setTransform(
233 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); 252 TransformPaintPropertyNode::create(nullptr,
253 TransformationMatrix(9, 8, 7, 6, 5, 4),
254 FloatPoint3D(3, 2, 1))
255 .get());
234 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); 256 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
235 257
236 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 258 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
237 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 259 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
238 260
239 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 1, nullptr, 261 EXPECT_THAT(chunks, ElementsAre(PaintChunk(0, 1, nullptr,
240 defaultPaintChunkProperties()), 262 defaultPaintChunkProperties()),
241 PaintChunk(1, 2, nullptr, secondTransform))); 263 PaintChunk(1, 2, nullptr, secondTransform)));
242 } 264 }
243 265
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 DisplayItem::Id id1 = i1.getId(); 311 DisplayItem::Id id1 = i1.getId();
290 TestDisplayItemRequiringSeparateChunk i2(m_client); 312 TestDisplayItemRequiringSeparateChunk i2(m_client);
291 DisplayItem::Id id2 = i2.getId(); 313 DisplayItem::Id id2 = i2.getId();
292 314
293 chunker.updateCurrentPaintChunkProperties(nullptr, 315 chunker.updateCurrentPaintChunkProperties(nullptr,
294 defaultPaintChunkProperties()); 316 defaultPaintChunkProperties());
295 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 317 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 318 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
297 319
298 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); 320 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
299 simpleTransform.transform = TransformPaintPropertyNode::create( 321 simpleTransform.propertyTreeState.setTransform(
300 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 322 TransformPaintPropertyNode::create(nullptr,
323 TransformationMatrix(0, 1, 2, 3, 4, 5),
324 FloatPoint3D(9, 8, 7))
325 .get());
301 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 326 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
302 327
303 chunker.incrementDisplayItemIndex(i1); 328 chunker.incrementDisplayItemIndex(i1);
304 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 329 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
305 chunker.incrementDisplayItemIndex(i2); 330 chunker.incrementDisplayItemIndex(i2);
306 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 331 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
307 332
308 chunker.updateCurrentPaintChunkProperties(nullptr, 333 chunker.updateCurrentPaintChunkProperties(nullptr,
309 defaultPaintChunkProperties()); 334 defaultPaintChunkProperties());
310 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 335 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
(...skipping 15 matching lines...) Expand all
326 DisplayItem::Id id1 = i1.getId(); 351 DisplayItem::Id id1 = i1.getId();
327 TestDisplayItemRequiringSeparateChunk i2(m_client); 352 TestDisplayItemRequiringSeparateChunk i2(m_client);
328 i2.setSkippedCache(); 353 i2.setSkippedCache();
329 354
330 chunker.updateCurrentPaintChunkProperties(nullptr, 355 chunker.updateCurrentPaintChunkProperties(nullptr,
331 defaultPaintChunkProperties()); 356 defaultPaintChunkProperties());
332 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 357 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
333 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 358 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
334 359
335 PaintChunkProperties simpleTransform = defaultPaintChunkProperties(); 360 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
336 simpleTransform.transform = TransformPaintPropertyNode::create( 361 simpleTransform.propertyTreeState.setTransform(
337 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 362 TransformPaintPropertyNode::create(nullptr,
363 TransformationMatrix(0, 1, 2, 3, 4, 5),
364 FloatPoint3D(9, 8, 7))
365 .get());
338 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 366 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
339 367
340 chunker.incrementDisplayItemIndex(i1); 368 chunker.incrementDisplayItemIndex(i1);
341 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 369 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
342 chunker.incrementDisplayItemIndex(i2); 370 chunker.incrementDisplayItemIndex(i2);
343 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 371 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
344 372
345 chunker.updateCurrentPaintChunkProperties(nullptr, 373 chunker.updateCurrentPaintChunkProperties(nullptr,
346 defaultPaintChunkProperties()); 374 defaultPaintChunkProperties());
347 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client)); 375 chunker.incrementDisplayItemIndex(NormalTestDisplayItem(m_client));
348 376
349 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 377 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
350 EXPECT_THAT( 378 EXPECT_THAT(
351 chunks, 379 chunks,
352 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()), 380 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
353 PaintChunk(2, 4, nullptr, simpleTransform), 381 PaintChunk(2, 4, nullptr, simpleTransform),
354 PaintChunk(4, 5, nullptr, simpleTransform), 382 PaintChunk(4, 5, nullptr, simpleTransform),
355 PaintChunk(5, 6, nullptr, simpleTransform), 383 PaintChunk(5, 6, nullptr, simpleTransform),
356 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties()))); 384 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
357 } 385 }
358 386
359 } // namespace 387 } // namespace
360 } // namespace blink 388 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698