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

Side by Side Diff: cc/paint/paint_op_buffer_unittest.cc

Issue 2876033005: Track slow paths in DisplayItemList (Closed)
Patch Set: danakj review Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "cc/paint/paint_op_buffer.h" 5 #include "cc/paint/paint_op_buffer.h"
6 #include "cc/paint/display_item_list.h" 6 #include "cc/paint/display_item_list.h"
7 #include "cc/test/skia_common.h" 7 #include "cc/test/skia_common.h"
8 #include "cc/test/test_skcanvas.h" 8 #include "cc/test/test_skcanvas.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/effects/SkDashPathEffect.h" 10 #include "third_party/skia/include/effects/SkDashPathEffect.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 buffer->push<ClipPathOp>(concave, SkClipOp::kIntersect, true); 490 buffer->push<ClipPathOp>(concave, SkClipOp::kIntersect, true);
491 EXPECT_EQ(buffer->numSlowPaths(), 2); 491 EXPECT_EQ(buffer->numSlowPaths(), 2);
492 buffer->push<ClipPathOp>(concave, SkClipOp::kIntersect, false); 492 buffer->push<ClipPathOp>(concave, SkClipOp::kIntersect, false);
493 EXPECT_EQ(buffer->numSlowPaths(), 2); 493 EXPECT_EQ(buffer->numSlowPaths(), 2);
494 494
495 // Drawing a record with slow paths into another adds the same 495 // Drawing a record with slow paths into another adds the same
496 // number of slow paths as the record. 496 // number of slow paths as the record.
497 auto buffer2 = sk_make_sp<PaintOpBuffer>(); 497 auto buffer2 = sk_make_sp<PaintOpBuffer>();
498 EXPECT_EQ(buffer2->numSlowPaths(), 0); 498 EXPECT_EQ(buffer2->numSlowPaths(), 0);
499 buffer2->push<DrawRecordOp>(buffer); 499 buffer2->push<DrawRecordOp>(buffer);
500 EXPECT_EQ(buffer->numSlowPaths(), buffer2->numSlowPaths()); 500 EXPECT_EQ(buffer2->numSlowPaths(), 2);
501 buffer2->push<DrawRecordOp>(buffer);
502 EXPECT_EQ(buffer2->numSlowPaths(), 4);
503
504 // Drawing an empty display item list doesn't change anything.
505 auto empty_list = base::MakeRefCounted<DisplayItemList>();
506 buffer2->push<DrawDisplayItemListOp>(empty_list);
507 EXPECT_EQ(buffer2->numSlowPaths(), 4);
508
509 // Drawing a display item list adds the items from that list.
510 auto slow_path_list = base::MakeRefCounted<DisplayItemList>();
511 slow_path_list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
512 gfx::Rect(1, 2, 3, 4), sk_make_sp<PaintOpBuffer>(),
513 SkRect::MakeXYWH(1, 2, 3, 4));
514 // Setting this properly is tested in PaintControllerTest.cpp.
515 slow_path_list->SetNumSlowPaths(50);
516 buffer2->push<DrawDisplayItemListOp>(slow_path_list);
517 EXPECT_EQ(buffer2->numSlowPaths(), 54);
501 } 518 }
502 519
503 TEST(PaintOpBufferTest, ContiguousRanges) { 520 TEST(PaintOpBufferTest, ContiguousRanges) {
504 PaintOpBuffer buffer; 521 PaintOpBuffer buffer;
505 MockCanvas canvas; 522 MockCanvas canvas;
506 523
507 buffer.push<DrawColorOp>(0u, SkBlendMode::kClear); 524 buffer.push<DrawColorOp>(0u, SkBlendMode::kClear);
508 buffer.push<DrawColorOp>(1u, SkBlendMode::kClear); 525 buffer.push<DrawColorOp>(1u, SkBlendMode::kClear);
509 buffer.push<DrawColorOp>(2u, SkBlendMode::kClear); 526 buffer.push<DrawColorOp>(2u, SkBlendMode::kClear);
510 buffer.push<DrawColorOp>(3u, SkBlendMode::kClear); 527 buffer.push<DrawColorOp>(3u, SkBlendMode::kClear);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 { 909 {
893 testing::Sequence s; 910 testing::Sequence s;
894 EXPECT_CALL(canvas, OnDrawRectWithColor(0u)).InSequence(s); 911 EXPECT_CALL(canvas, OnDrawRectWithColor(0u)).InSequence(s);
895 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s); 912 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s);
896 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s); 913 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s);
897 buffer.PlaybackRanges(ranges, {0, 2}, &canvas); 914 buffer.PlaybackRanges(ranges, {0, 2}, &canvas);
898 } 915 }
899 } 916 }
900 917
901 } // namespace cc 918 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/paint_op_buffer.cc ('k') | third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698