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

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

Issue 2698673007: Only create PaintChunks at drawing and foreignLayer boundaries (Closed)
Patch Set: Great expectations Created 3 years, 10 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 "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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 Vector<PaintChunk> chunks = chunker.releasePaintChunks(); 371 Vector<PaintChunk> chunks = chunker.releasePaintChunks();
372 EXPECT_THAT( 372 EXPECT_THAT(
373 chunks, 373 chunks,
374 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()), 374 ElementsAre(PaintChunk(0, 2, nullptr, defaultPaintChunkProperties()),
375 PaintChunk(2, 4, nullptr, simpleTransform), 375 PaintChunk(2, 4, nullptr, simpleTransform),
376 PaintChunk(4, 5, nullptr, simpleTransform), 376 PaintChunk(4, 5, nullptr, simpleTransform),
377 PaintChunk(5, 6, nullptr, simpleTransform), 377 PaintChunk(5, 6, nullptr, simpleTransform),
378 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties()))); 378 PaintChunk(6, 7, nullptr, defaultPaintChunkProperties())));
379 } 379 }
380 380
381 TEST_F(PaintChunkerTest, NoNonDrawingChunks) {
382 // Non-drawing/foreignLayer items should not create chunks for:
383 // <xform>, <drawing>, </xform>
384 // with all items in the same property tree state.
385 PaintChunker chunker;
386
387 TestDisplayItem beginTransform(m_client, DisplayItem::kBeginTransform);
388 chunker.updateCurrentPaintChunkProperties(nullptr,
389 defaultPaintChunkProperties());
390 chunker.incrementDisplayItemIndex(beginTransform);
391
392 TestDisplayItem drawing(m_client, DisplayItem::kDrawingFirst);
393 chunker.incrementDisplayItemIndex(drawing);
394
395 TestDisplayItem endTransform(m_client, DisplayItem::kEndTransform);
396 chunker.incrementDisplayItemIndex(endTransform);
397
398 EXPECT_THAT(
399 chunker.releasePaintChunks(),
400 ElementsAre(PaintChunk(1, 2, nullptr, defaultPaintChunkProperties())));
401 }
402
403 TEST_F(PaintChunkerTest, NoNonDrawingChunksWithDifferentProperties) {
404 // Non-drawing/foreignLayer items should not create chunks for:
405 // <xform>, <drawing>, </xform>
406 // with items in different property tree states.
407 PaintChunker chunker;
408
409 TestDisplayItem beginTransform(m_client, DisplayItem::kBeginTransform);
410 PaintChunkProperties simpleTransform = defaultPaintChunkProperties();
411 simpleTransform.propertyTreeState.setTransform(
412 TransformPaintPropertyNode::create(nullptr,
413 TransformationMatrix(0, 1, 2, 3, 4, 5),
414 FloatPoint3D(9, 8, 7))
415 .get());
416 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
417 chunker.incrementDisplayItemIndex(beginTransform);
418
419 TestDisplayItem drawing(m_client, DisplayItem::kDrawingFirst);
420 chunker.updateCurrentPaintChunkProperties(nullptr,
421 defaultPaintChunkProperties());
422 chunker.incrementDisplayItemIndex(drawing);
423
424 TestDisplayItem endTransform(m_client, DisplayItem::kEndTransform);
425 chunker.updateCurrentPaintChunkProperties(nullptr, simpleTransform);
426 chunker.incrementDisplayItemIndex(endTransform);
427
428 EXPECT_THAT(
429 chunker.releasePaintChunks(),
430 ElementsAre(PaintChunk(1, 2, nullptr, defaultPaintChunkProperties())));
431 }
432
433 TEST_F(PaintChunkerTest, NoNonForeignLayerChunks) {
434 // Non-drawing/foreignLayer items should not create chunks for:
435 // <xform>, <foreignLayer>, </xform>
436 PaintChunker chunker;
437
438 TestDisplayItem beginTransform(m_client, DisplayItem::kBeginTransform);
439 chunker.updateCurrentPaintChunkProperties(nullptr,
440 defaultPaintChunkProperties());
441 chunker.incrementDisplayItemIndex(beginTransform);
442
443 TestDisplayItem foreignLayer(m_client, DisplayItem::kForeignLayerCanvas);
444 DisplayItem::Id layerId = foreignLayer.getId();
445 chunker.incrementDisplayItemIndex(foreignLayer);
446
447 TestDisplayItem endTransform(m_client, DisplayItem::kEndTransform);
448 chunker.incrementDisplayItemIndex(endTransform);
449
450 EXPECT_THAT(
451 chunker.releasePaintChunks(),
452 ElementsAre(PaintChunk(1, 2, &layerId, defaultPaintChunkProperties())));
453 }
454
381 } // namespace 455 } // namespace
382 } // namespace blink 456 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698