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

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

Issue 2875343002: cc: fix for MSAA veto. (Closed)
Patch Set: Windows fix. Created 3 years, 7 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
« no previous file with comments | « cc/paint/paint_op_buffer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11
11 namespace { 12 namespace {
12 13
13 template <typename T> 14 template <typename T>
14 void CheckRefCnt(const T& obj, int32_t count) { 15 void CheckRefCnt(const T& obj, int32_t count) {
15 // Skia doesn't define getRefCnt in all builds. 16 // Skia doesn't define getRefCnt in all builds.
16 #ifdef SK_DEBUG 17 #ifdef SK_DEBUG
17 EXPECT_EQ(obj->getRefCnt(), count); 18 EXPECT_EQ(obj->getRefCnt(), count);
18 #endif 19 #endif
19 } 20 }
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { 469 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) {
469 PaintOpBuffer buffer; 470 PaintOpBuffer buffer;
470 PaintFlags flags; 471 PaintFlags flags;
471 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); 472 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100));
472 flags.setShader( 473 flags.setShader(
473 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); 474 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
474 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); 475 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
475 EXPECT_TRUE(buffer.HasDiscardableImages()); 476 EXPECT_TRUE(buffer.HasDiscardableImages());
476 } 477 }
477 478
479 TEST(PaintOpBufferTest, SlowPaths) {
480 auto buffer = sk_make_sp<PaintOpBuffer>();
481 EXPECT_EQ(buffer->numSlowPaths(), 0);
482
483 // Op without slow paths
484 PaintFlags noop_flags;
485 SkRect rect = SkRect::MakeXYWH(2, 3, 4, 5);
486 buffer->push<SaveLayerOp>(&rect, &noop_flags);
487
488 // Line op with a slow path
489 PaintFlags line_effect_slow;
490 line_effect_slow.setStrokeWidth(1.f);
491 line_effect_slow.setStyle(PaintFlags::kStroke_Style);
492 line_effect_slow.setStrokeCap(PaintFlags::kRound_Cap);
493 SkScalar intervals[] = {1.f, 1.f};
494 line_effect_slow.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
495
496 buffer->push<DrawLineOp>(1.f, 2.f, 3.f, 4.f, line_effect_slow);
497 EXPECT_EQ(buffer->numSlowPaths(), 1);
498
499 // Line effect special case that Skia handles specially.
500 PaintFlags line_effect = line_effect_slow;
501 line_effect.setStrokeCap(PaintFlags::kButt_Cap);
502 buffer->push<DrawLineOp>(1.f, 2.f, 3.f, 4.f, line_effect);
503 EXPECT_EQ(buffer->numSlowPaths(), 1);
504
505 // Antialiased convex path is not slow.
506 SkPath path;
507 path.addCircle(2, 2, 5);
508 EXPECT_TRUE(path.isConvex());
509 buffer->push<ClipPathOp>(path, SkClipOp::kIntersect, true);
510 EXPECT_EQ(buffer->numSlowPaths(), 1);
511
512 // Concave paths are slow only when antialiased.
513 SkPath concave = path;
514 concave.addCircle(3, 4, 2);
515 EXPECT_FALSE(concave.isConvex());
516 buffer->push<ClipPathOp>(concave, SkClipOp::kIntersect, true);
517 EXPECT_EQ(buffer->numSlowPaths(), 2);
518 buffer->push<ClipPathOp>(concave, SkClipOp::kIntersect, false);
519 EXPECT_EQ(buffer->numSlowPaths(), 2);
520
521 // Drawing a record with slow paths into another adds the same
522 // number of slow paths as the record.
523 auto buffer2 = sk_make_sp<PaintOpBuffer>();
524 EXPECT_EQ(buffer2->numSlowPaths(), 0);
525 buffer2->push<DrawRecordOp>(buffer);
526 EXPECT_EQ(buffer->numSlowPaths(), buffer2->numSlowPaths());
527 }
528
478 } // namespace cc 529 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/paint_op_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698