aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkPicture.h2
-rw-r--r--src/core/SkPicture.cpp13
-rw-r--r--tests/PictureTest.cpp5
3 files changed, 15 insertions, 5 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 44681ea7e6..7ccd3379e2 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -296,7 +296,7 @@ public:
*/
#if SK_SUPPORT_GPU
- bool suitableForGpuRasterization(GrContext*) const;
+ bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const;
#endif
protected:
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 0f016acca4..57a614913e 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -654,15 +654,22 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const {
}
#if SK_SUPPORT_GPU
-bool SkPicture::suitableForGpuRasterization(GrContext* context) const {
+bool SkPicture::suitableForGpuRasterization(GrContext* context, const char **reason) const {
// TODO: the heuristic used here needs to be refined
static const int kNumPaintWithPathEffectUsesTol = 1;
static const int kNumAAConcavePaths = 5;
SkASSERT(this->numAAHairlineConcavePaths() <= this->numAAConcavePaths());
- return this->numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol &&
- (this->numAAConcavePaths()-this->numAAHairlineConcavePaths()) < kNumAAConcavePaths;
+ bool ret = this->numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol &&
+ (this->numAAConcavePaths()-this->numAAHairlineConcavePaths()) < kNumAAConcavePaths;
+ if (!ret && reason) {
+ if (this->numPaintWithPathEffectUses() < kNumPaintWithPathEffectUsesTol)
+ *reason = "Too many path effects.";
+ else if ((this->numAAConcavePaths()-this->numAAHairlineConcavePaths()) < kNumAAConcavePaths)
+ *reason = "Too many anti-aliased concave paths.";
+ }
+ return ret;
}
#endif
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index 1ef32abb95..d27b463583 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -730,7 +730,10 @@ static void test_gpu_veto(skiatest::Reporter* reporter) {
}
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
// path effects currently render an SkPicture undesireable for GPU rendering
- REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL));
+
+ const char *reason = NULL;
+ REPORTER_ASSERT(reporter, !picture->suitableForGpuRasterization(NULL, &reason));
+ REPORTER_ASSERT(reporter, NULL != reason);
canvas = recorder.beginRecording(100, 100, NULL, 0);
{