| Index: src/core/SkPictureAnalyzer.cpp
|
| diff --git a/src/core/SkPictureAnalyzer.cpp b/src/core/SkPictureAnalyzer.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a9cdff910763b5aceed57183497ccaf010e33ad8
|
| --- /dev/null
|
| +++ b/src/core/SkPictureAnalyzer.cpp
|
| @@ -0,0 +1,45 @@
|
| +/*
|
| + * Copyright 2016 Google Inc.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#include "SkPicture.h"
|
| +#include "SkPictureAnalyzer.h"
|
| +
|
| +namespace {
|
| +
|
| +inline bool veto_predicate(uint32_t numSlowPaths) {
|
| + return numSlowPaths > 5;
|
| +}
|
| +
|
| +} // anonymous namespace
|
| +
|
| +SkPictureGpuAnalyzer::SkPictureGpuAnalyzer()
|
| + : fNumSlowPaths(0) { }
|
| +
|
| +SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture)
|
| + : SkPictureGpuAnalyzer() {
|
| + this->analyze(picture.get());
|
| +}
|
| +
|
| +void SkPictureGpuAnalyzer::analyze(const SkPicture* picture) {
|
| + if (!picture || veto_predicate(fNumSlowPaths)) {
|
| + return;
|
| + }
|
| +
|
| + fNumSlowPaths += picture->numSlowPaths();
|
| +}
|
| +
|
| +void SkPictureGpuAnalyzer::reset() {
|
| + fNumSlowPaths = 0;
|
| +}
|
| +
|
| +bool SkPictureGpuAnalyzer::suitableForGpuRasterization(GrContext*, const char** whyNot) const {
|
| + if(veto_predicate(fNumSlowPaths)) {
|
| + if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed)."; }
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
|
|