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

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

Issue 2480863002: DCHECK that paint properties are never null (Closed)
Patch Set: dcheckmate Created 4 years, 1 month 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 "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
11 using testing::ElementsAre; 11 using testing::ElementsAre;
12 12
13 namespace blink { 13 namespace blink {
14 namespace { 14 namespace {
15 15
16 // TODO(crbug.com/629946): The tests fail mysteriously on some Windows debug 16 // TODO(crbug.com/629946): The tests fail mysteriously on some Windows debug
17 // bots. 17 // bots.
18 #if defined(NDEBUG) || !OS(WIN) 18 #if defined(NDEBUG) || !OS(WIN)
19 19
20 PaintChunkProperties rootPaintChunkProperties() { 20 PaintChunkProperties rootPaintChunkProperties() {
21 return PaintChunkProperties(); 21 PaintChunkProperties rootProperties;
22 rootProperties.transform = TransformPaintPropertyNode::root();
23 rootProperties.clip = ClipPaintPropertyNode::root();
24 rootProperties.effect = EffectPaintPropertyNode::root();
25 rootProperties.scroll = ScrollPaintPropertyNode::root();
26 return rootProperties;
22 } 27 }
23 28
24 class PaintChunkerTest : public testing::Test { 29 class PaintChunkerTest : public testing::Test {
25 protected: 30 protected:
26 void SetUp() override { 31 void SetUp() override {
27 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 32 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
28 } 33 }
29 34
30 void TearDown() override { m_featuresBackup.restore(); } 35 void TearDown() override { m_featuresBackup.restore(); }
31 36
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 rootPaintChunkProperties()))); 109 rootPaintChunkProperties())));
105 } 110 }
106 111
107 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { 112 TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) {
108 PaintChunker chunker; 113 PaintChunker chunker;
109 chunker.updateCurrentPaintChunkProperties(nullptr, 114 chunker.updateCurrentPaintChunkProperties(nullptr,
110 rootPaintChunkProperties()); 115 rootPaintChunkProperties());
111 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 116 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
112 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 117 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
113 118
114 PaintChunkProperties simpleTransform; 119 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
115 simpleTransform.transform = TransformPaintPropertyNode::create( 120 simpleTransform.transform = TransformPaintPropertyNode::create(
116 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 121 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
117 122
118 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 123 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
119 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 124 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
120 125
121 PaintChunkProperties anotherTransform; 126 PaintChunkProperties anotherTransform = rootPaintChunkProperties();
122 anotherTransform.transform = TransformPaintPropertyNode::create( 127 anotherTransform.transform = TransformPaintPropertyNode::create(
123 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 128 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
124 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform); 129 chunker.updateCurrentPaintChunkProperties(nullptr, anotherTransform);
125 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 130 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
126 131
127 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 132 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
128 133
129 EXPECT_THAT(chunks, 134 EXPECT_THAT(chunks,
130 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 135 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
131 PaintChunk(2, 3, nullptr, simpleTransform), 136 PaintChunk(2, 3, nullptr, simpleTransform),
132 PaintChunk(3, 4, nullptr, anotherTransform))); 137 PaintChunk(3, 4, nullptr, anotherTransform)));
133 } 138 }
134 139
135 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { 140 TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) {
136 PaintChunker chunker; 141 PaintChunker chunker;
137 chunker.updateCurrentPaintChunkProperties(nullptr, 142 chunker.updateCurrentPaintChunkProperties(nullptr,
138 rootPaintChunkProperties()); 143 rootPaintChunkProperties());
139 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 144 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
140 145
141 PaintChunkProperties simpleTransform; 146 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
142 simpleTransform.transform = TransformPaintPropertyNode::create( 147 simpleTransform.transform = TransformPaintPropertyNode::create(
143 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7)); 148 nullptr, TransformationMatrix(0, 0, 0, 0, 0, 0), FloatPoint3D(9, 8, 7));
144 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 149 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
145 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 150 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
146 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 151 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
147 152
148 PaintChunkProperties simpleTransformAndEffect; 153 PaintChunkProperties simpleTransformAndEffect = rootPaintChunkProperties();
149 simpleTransformAndEffect.transform = simpleTransform.transform; 154 simpleTransformAndEffect.transform = simpleTransform.transform;
150 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create( 155 simpleTransformAndEffect.effect = EffectPaintPropertyNode::create(
151 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 156 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
152 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f); 157 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5f);
153 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect); 158 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransformAndEffect);
154 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 159 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
155 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 160 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
156 161
157 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform; 162 PaintChunkProperties simpleTransformAndEffectWithUpdatedTransform =
163 rootPaintChunkProperties();
158 simpleTransformAndEffectWithUpdatedTransform.transform = 164 simpleTransformAndEffectWithUpdatedTransform.transform =
159 TransformPaintPropertyNode::create(nullptr, 165 TransformPaintPropertyNode::create(nullptr,
160 TransformationMatrix(1, 1, 0, 0, 0, 0), 166 TransformationMatrix(1, 1, 0, 0, 0, 0),
161 FloatPoint3D(9, 8, 7)); 167 FloatPoint3D(9, 8, 7));
162 simpleTransformAndEffectWithUpdatedTransform.effect = 168 simpleTransformAndEffectWithUpdatedTransform.effect =
163 EffectPaintPropertyNode::create( 169 EffectPaintPropertyNode::create(
164 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), 170 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
165 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 171 ClipPaintPropertyNode::root(), CompositorFilterOperations(),
166 simpleTransformAndEffect.effect->opacity()); 172 simpleTransformAndEffect.effect->opacity());
167 chunker.updateCurrentPaintChunkProperties( 173 chunker.updateCurrentPaintChunkProperties(
(...skipping 22 matching lines...) Expand all
190 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { 196 TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) {
191 // Test that "nested" transforms linearize using the following 197 // Test that "nested" transforms linearize using the following
192 // sequence of transforms and display items: 198 // sequence of transforms and display items:
193 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>, 199 // <root xform>, <paint>, <a xform>, <paint>, <paint>, </a xform>, <paint>,
194 // </root xform> 200 // </root xform>
195 PaintChunker chunker; 201 PaintChunker chunker;
196 chunker.updateCurrentPaintChunkProperties(nullptr, 202 chunker.updateCurrentPaintChunkProperties(nullptr,
197 rootPaintChunkProperties()); 203 rootPaintChunkProperties());
198 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 204 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
199 205
200 PaintChunkProperties simpleTransform; 206 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
201 simpleTransform.transform = TransformPaintPropertyNode::create( 207 simpleTransform.transform = TransformPaintPropertyNode::create(
202 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 208 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
203 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform); 209 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
204 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 210 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
205 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 211 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
206 212
207 chunker.updateCurrentPaintChunkProperties(nullptr, 213 chunker.updateCurrentPaintChunkProperties(nullptr,
208 rootPaintChunkProperties()); 214 rootPaintChunkProperties());
209 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 215 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
210 216
211 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 217 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
212 218
213 EXPECT_THAT( 219 EXPECT_THAT(
214 chunks, 220 chunks,
215 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 221 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
216 PaintChunk(1, 3, nullptr, simpleTransform), 222 PaintChunk(1, 3, nullptr, simpleTransform),
217 PaintChunk(3, 4, nullptr, rootPaintChunkProperties()))); 223 PaintChunk(3, 4, nullptr, rootPaintChunkProperties())));
218 } 224 }
219 225
220 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { 226 TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) {
221 // Test that properties can change without display items being generated. 227 // Test that properties can change without display items being generated.
222 PaintChunker chunker; 228 PaintChunker chunker;
223 chunker.updateCurrentPaintChunkProperties(nullptr, 229 chunker.updateCurrentPaintChunkProperties(nullptr,
224 rootPaintChunkProperties()); 230 rootPaintChunkProperties());
225 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 231 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
226 232
227 PaintChunkProperties firstTransform; 233 PaintChunkProperties firstTransform = rootPaintChunkProperties();
228 firstTransform.transform = TransformPaintPropertyNode::create( 234 firstTransform.transform = TransformPaintPropertyNode::create(
229 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 235 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
230 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform); 236 chunker.updateCurrentPaintChunkProperties(nullptr, firstTransform);
231 237
232 PaintChunkProperties secondTransform; 238 PaintChunkProperties secondTransform = rootPaintChunkProperties();
233 secondTransform.transform = TransformPaintPropertyNode::create( 239 secondTransform.transform = TransformPaintPropertyNode::create(
234 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1)); 240 nullptr, TransformationMatrix(9, 8, 7, 6, 5, 4), FloatPoint3D(3, 2, 1));
235 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform); 241 chunker.updateCurrentPaintChunkProperties(nullptr, secondTransform);
236 242
237 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 243 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
238 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 244 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
239 245
240 EXPECT_THAT(chunks, 246 EXPECT_THAT(chunks,
241 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()), 247 ElementsAre(PaintChunk(0, 1, nullptr, rootPaintChunkProperties()),
242 PaintChunk(1, 2, nullptr, secondTransform))); 248 PaintChunk(1, 2, nullptr, secondTransform)));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 PaintChunk(6, 7, &id6, rootPaintChunkProperties()))); 283 PaintChunk(6, 7, &id6, rootPaintChunkProperties())));
278 } 284 }
279 285
280 TEST_F(PaintChunkerTest, ChunkIds) { 286 TEST_F(PaintChunkerTest, ChunkIds) {
281 PaintChunker chunker; 287 PaintChunker chunker;
282 TestDisplayItem i1(DisplayItem::kDrawingFirst); 288 TestDisplayItem i1(DisplayItem::kDrawingFirst);
283 DisplayItem::Id id1 = i1.getId(); 289 DisplayItem::Id id1 = i1.getId();
284 TestDisplayItemRequiringSeparateChunk i2; 290 TestDisplayItemRequiringSeparateChunk i2;
285 DisplayItem::Id id2 = i2.getId(); 291 DisplayItem::Id id2 = i2.getId();
286 292
293 chunker.updateCurrentPaintChunkProperties(nullptr,
294 rootPaintChunkProperties());
287 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 295 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
288 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
289 297
290 PaintChunkProperties simpleTransform; 298 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
291 simpleTransform.transform = TransformPaintPropertyNode::create( 299 simpleTransform.transform = TransformPaintPropertyNode::create(
292 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 300 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
293 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 301 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
294 302
295 chunker.incrementDisplayItemIndex(i1); 303 chunker.incrementDisplayItemIndex(i1);
296 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 304 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
297 chunker.incrementDisplayItemIndex(i2); 305 chunker.incrementDisplayItemIndex(i2);
298 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 306 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
299 307
300 chunker.updateCurrentPaintChunkProperties(nullptr, 308 chunker.updateCurrentPaintChunkProperties(nullptr,
(...skipping 11 matching lines...) Expand all
312 } 320 }
313 321
314 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { 322 TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) {
315 PaintChunker chunker; 323 PaintChunker chunker;
316 TestDisplayItem i1(DisplayItem::kDrawingFirst); 324 TestDisplayItem i1(DisplayItem::kDrawingFirst);
317 i1.setSkippedCache(); 325 i1.setSkippedCache();
318 DisplayItem::Id id1 = i1.getId(); 326 DisplayItem::Id id1 = i1.getId();
319 TestDisplayItemRequiringSeparateChunk i2; 327 TestDisplayItemRequiringSeparateChunk i2;
320 i2.setSkippedCache(); 328 i2.setSkippedCache();
321 329
330 chunker.updateCurrentPaintChunkProperties(nullptr,
331 rootPaintChunkProperties());
322 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 332 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
323 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 333 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
324 334
325 PaintChunkProperties simpleTransform; 335 PaintChunkProperties simpleTransform = rootPaintChunkProperties();
326 simpleTransform.transform = TransformPaintPropertyNode::create( 336 simpleTransform.transform = TransformPaintPropertyNode::create(
327 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7)); 337 nullptr, TransformationMatrix(0, 1, 2, 3, 4, 5), FloatPoint3D(9, 8, 7));
328 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform); 338 chunker.updateCurrentPaintChunkProperties(&id1, simpleTransform);
329 339
330 chunker.incrementDisplayItemIndex(i1); 340 chunker.incrementDisplayItemIndex(i1);
331 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 341 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
332 chunker.incrementDisplayItemIndex(i2); 342 chunker.incrementDisplayItemIndex(i2);
333 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 343 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
334 344
335 chunker.updateCurrentPaintChunkProperties(nullptr, 345 chunker.updateCurrentPaintChunkProperties(nullptr,
336 rootPaintChunkProperties()); 346 rootPaintChunkProperties());
337 chunker.incrementDisplayItemIndex(NormalTestDisplayItem()); 347 chunker.incrementDisplayItemIndex(NormalTestDisplayItem());
338 348
339 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 349 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
340 EXPECT_THAT( 350 EXPECT_THAT(
341 chunks, 351 chunks,
342 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()), 352 ElementsAre(PaintChunk(0, 2, nullptr, rootPaintChunkProperties()),
343 PaintChunk(2, 4, nullptr, simpleTransform), 353 PaintChunk(2, 4, nullptr, simpleTransform),
344 PaintChunk(4, 5, nullptr, simpleTransform), 354 PaintChunk(4, 5, nullptr, simpleTransform),
345 PaintChunk(5, 6, nullptr, simpleTransform), 355 PaintChunk(5, 6, nullptr, simpleTransform),
346 PaintChunk(6, 7, nullptr, rootPaintChunkProperties()))); 356 PaintChunk(6, 7, nullptr, rootPaintChunkProperties())));
347 } 357 }
348 358
349 #endif 359 #endif
350 360
351 } // namespace 361 } // namespace
352 } // namespace blink 362 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698