diff options
author | 2015-01-26 11:29:36 -0800 | |
---|---|---|
committer | 2015-01-26 11:29:36 -0800 | |
commit | 98b0315ad6beb7dbc311fd365ffe5c24d7ef2d0f (patch) | |
tree | 072a47c5c205b1938eda6e83c905570019b25687 | |
parent | 1d9e80f02b8260ffe2eb1944042cd79f10e38d43 (diff) |
Alter gpu veto
This CL unifies the treatment of the dashed and concave paths.
Before:
TP 28 FP 15 TN 8 FN 3 IND 3
After:
TP 28 FP 18 TN 7 FN 2 IND 2
One of the TrueNegatives that became a FalsePositive was the motivation use case (the Chromium busy spinner).
Committed: https://skia.googlesource.com/skia/+/87a6a8e18c7d5bbc94f478b44c53dc0e0549f927
Review URL: https://codereview.chromium.org/875913002
-rw-r--r-- | src/core/SkPicture.cpp | 33 | ||||
-rw-r--r-- | tests/PictureTest.cpp | 13 |
2 files changed, 22 insertions, 24 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp index 871a62e8f3..c7e36e7ecd 100644 --- a/src/core/SkPicture.cpp +++ b/src/core/SkPicture.cpp @@ -239,31 +239,22 @@ SkPicture::Analysis::Analysis(const SkRecord& record) { bool SkPicture::Analysis::suitableForGpuRasterization(const char** reason, int sampleCount) const { // TODO: the heuristic used here needs to be refined - static const int kNumPaintWithPathEffectsUsesTol = 1; - static const int kNumAAConcavePathsTol = 5; + static const int kNumSlowPathsTol = 6; - int numNonDashedPathEffects = fNumPaintWithPathEffectUses - - fNumFastPathDashEffects; - bool suitableForDash = (0 == fNumPaintWithPathEffectUses) || - (numNonDashedPathEffects < kNumPaintWithPathEffectsUsesTol - && 0 == sampleCount); + int numSlowPathDashedPaths = fNumPaintWithPathEffectUses; + if (0 == sampleCount) { + // The fast dashing path only works when MSAA is disabled + numSlowPathDashedPaths -= fNumFastPathDashEffects; + } + + int numSlowPaths = fNumAAConcavePaths - + fNumAAHairlineConcavePaths - + fNumAADFEligibleConcavePaths; - bool ret = suitableForDash && - (fNumAAConcavePaths - fNumAAHairlineConcavePaths - fNumAADFEligibleConcavePaths) - < kNumAAConcavePathsTol; + bool ret = numSlowPathDashedPaths + numSlowPaths < kNumSlowPathsTol; if (!ret && reason) { - if (!suitableForDash) { - if (0 != sampleCount) { - *reason = "Can't use multisample on dash effect."; - } else { - *reason = "Too many non dashed path effects."; - } - } else if ((fNumAAConcavePaths - fNumAAHairlineConcavePaths - fNumAADFEligibleConcavePaths) - >= kNumAAConcavePathsTol) - *reason = "Too many anti-aliased concave paths."; - else - *reason = "Unknown reason for GPU unsuitability."; + *reason = "Too many slow paths (either concave or dashed)."; } return ret; } diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index b63b35eea7..c9860f994c 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -140,7 +140,9 @@ static void test_gpu_veto(skiatest::Reporter* reporter) { paint.setStyle(SkPaint::kStroke_Style); paint.setPathEffect(dash); - canvas->drawPath(path, paint); + for (int i = 0; i < 50; ++i) { + canvas->drawPath(path, paint); + } } SkAutoTUnref<SkPicture> picture(recorder.endRecording()); // path effects currently render an SkPicture undesireable for GPU rendering @@ -225,7 +227,10 @@ static void test_gpu_veto(skiatest::Reporter* reporter) { paint.setPathEffect(pe)->unref(); SkPoint points [2] = { { 0, 0 }, { 100, 0 } }; - canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint); + + for (int i = 0; i < 50; ++i) { + canvas->drawPoints(SkCanvas::kLines_PointMode, 2, points, paint); + } } picture.reset(recorder.endRecording()); // fast-path dashed effects are fine for GPU rendering ... @@ -238,7 +243,9 @@ static void test_gpu_veto(skiatest::Reporter* reporter) { SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 25); paint.setPathEffect(pe)->unref(); - canvas->drawRect(SkRect::MakeWH(10, 10), paint); + for (int i = 0; i < 50; ++i) { + canvas->drawRect(SkRect::MakeWH(10, 10), paint); + } } picture.reset(recorder.endRecording()); // ... but only when applied to drawPoint() calls |