diff options
author | egdaniel <egdaniel@google.com> | 2014-06-18 07:34:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-18 07:34:39 -0700 |
commit | 12c2198535759ee9aae91ec385e8e31e5dbc12d7 (patch) | |
tree | 528320c21b84cf0dd125d3ca269aeb3510c15688 /src | |
parent | de10fdeee5114537ab2875768e6c44a93ccb7a2d (diff) |
Remove dashing from gpu veto
With new veto our new veto test results look like the following:
TP: true positive (picked to use gpu and gpu was faster)
I: inderminate, the raster time is withing 5% of gpu time
TP FP TN FN I
old 21 9 15 12 3
new 29 12 11 6 3
There are three skps that tend to move from TN -> FP, however
the absolute difference in their run times are not huge between
them. The largest being desk_booking which is about 7.1 raster
and 8.8 gpu. The other two skps are desk_yahooanswers and
desk_linkedin
BUG=skia:
R=bsalomon@google.com, robertphillips@google.com
Author: egdaniel@google.com
Review URL: https://codereview.chromium.org/334053005
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 40 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.h | 23 | ||||
-rw-r--r-- | src/core/SkPictureRecord.cpp | 8 |
3 files changed, 64 insertions, 7 deletions
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index 75801fb960..16887107fb 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -14,6 +14,10 @@ #include "SkTSort.h" #include "SkWriteBuffer.h" +#if SK_SUPPORT_GPU +#include "GrContext.h" +#endif + template <typename T> int SafeCount(const T* obj) { return obj ? obj->count() : 0; } @@ -1335,27 +1339,51 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback) #if SK_SUPPORT_GPU -bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason) const { +bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason, + int sampleCount) const { // TODO: the heuristic used here needs to be refined static const int kNumPaintWithPathEffectUsesTol = 1; static const int kNumAAConcavePaths = 5; SkASSERT(fContentInfo.numAAHairlineConcavePaths() <= fContentInfo.numAAConcavePaths()); - bool ret = fContentInfo.numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol && + int numNonDashedPathEffects = fContentInfo.numPaintWithPathEffectUses() - + fContentInfo.numFastPathDashEffects(); + + bool suitableForDash = (0 == fContentInfo.numPaintWithPathEffectUses()) || + (numNonDashedPathEffects < kNumPaintWithPathEffectUsesTol + && 0 == sampleCount); + + bool ret = suitableForDash && (fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths()) < kNumAAConcavePaths; if (!ret && NULL != reason) { - if (fContentInfo.numPaintWithPathEffectUses() >= kNumPaintWithPathEffectUsesTol) - *reason = "Too many path effects."; - else if ((fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths()) - >= kNumAAConcavePaths) + if (!suitableForDash) { + if (0 != sampleCount) { + *reason = "Can't use multisample on dash effect."; + } else { + *reason = "Too many non dashed path effects."; + } + } else if ((fContentInfo.numAAConcavePaths() - fContentInfo.numAAHairlineConcavePaths()) + >= kNumAAConcavePaths) *reason = "Too many anti-aliased concave paths."; else *reason = "Unknown reason for GPU unsuitability."; } return ret; } + +bool SkPicturePlayback::suitableForGpuRasterization(GrContext* context, const char **reason, + GrPixelConfig config, SkScalar dpi) const { + + if (context != NULL) { + return this->suitableForGpuRasterization(context, reason, + context->getRecommendedSampleCount(config, dpi)); + } else { + return this->suitableForGpuRasterization(NULL, reason); + } +} + #endif /////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h index 23c49cfe71..3cdd9af3f3 100644 --- a/src/core/SkPicturePlayback.h +++ b/src/core/SkPicturePlayback.h @@ -70,18 +70,21 @@ public: void set(const SkPictureContentInfo& src) { fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses; + fNumFastPathDashEffects = src.fNumFastPathDashEffects; fNumAAConcavePaths = src.fNumAAConcavePaths; fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths; } void reset() { fNumPaintWithPathEffectUses = 0; + fNumFastPathDashEffects = 0; fNumAAConcavePaths = 0; fNumAAHairlineConcavePaths = 0; } void swap(SkPictureContentInfo* other) { SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses); + SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects); SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths); SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths); } @@ -89,6 +92,9 @@ public: void incPaintWithPathEffectUses() { ++fNumPaintWithPathEffectUses; } int numPaintWithPathEffectUses() const { return fNumPaintWithPathEffectUses; } + void incFastPathDashEffects() { ++fNumFastPathDashEffects; } + int numFastPathDashEffects() const { return fNumFastPathDashEffects; } + void incAAConcavePaths() { ++fNumAAConcavePaths; } int numAAConcavePaths() const { return fNumAAConcavePaths; } @@ -102,6 +108,9 @@ private: // This field is incremented every time a paint with a path effect is // used (i.e., it is not a de-duplicated count) int fNumPaintWithPathEffectUses; + // This field is incremented every time a paint with a path effect that is + // dashed, we are drawing a line, and we can use the gpu fast path + int fNumFastPathDashEffects; // This field is incremented every time an anti-aliased drawPath call is // issued with a concave path int fNumAAConcavePaths; @@ -269,7 +278,19 @@ public: #endif #if SK_SUPPORT_GPU - bool suitableForGpuRasterization(GrContext* context, const char **reason) const; + /** + * sampleCount is the number of samples-per-pixel or zero if non-MSAA. + * It is defaulted to be zero. + */ + bool suitableForGpuRasterization(GrContext* context, const char **reason, + int sampleCount = 0) const; + + /** + * Calls getRecommendedSampleCount with GrPixelConfig and dpi to calculate sampleCount + * and then calls the above version of suitableForGpuRasterization + */ + bool suitableForGpuRasterization(GrContext* context, const char **reason, + GrPixelConfig config, SkScalar dpi) const; #endif private: // these help us with reading/writing diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index 5d2eca7a55..16856d639d 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -988,6 +988,14 @@ void SkPictureRecord::drawPoints(PointMode mode, size_t count, const SkPoint pts size_t initialOffset = this->addDraw(DRAW_POINTS, &size); SkASSERT(initialOffset+getPaintOffset(DRAW_POINTS, size) == fWriter.bytesWritten()); this->addPaint(paint); + if (paint.getPathEffect() != NULL) { + SkPathEffect::DashInfo info; + SkPathEffect::DashType dashType = paint.getPathEffect()->asADash(&info); + if (2 == count && SkPaint::kRound_Cap != paint.getStrokeCap() && + SkPathEffect::kDash_DashType == dashType && 2 == info.fCount) { + fContentInfo.incFastPathDashEffects(); + } + } this->addInt(mode); this->addInt(SkToInt(count)); fWriter.writeMul4(pts, count * sizeof(SkPoint)); |