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

Unified Diff: src/core/SkPictureAnalyzer.cpp

Issue 1974833003: SkPictureGpuAnalyzer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: sk_sp<GrContextThreadSafeProxy> Created 4 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 side-by-side diff with in-line comments
Download patch
Index: src/core/SkPictureAnalyzer.cpp
diff --git a/src/core/SkPictureAnalyzer.cpp b/src/core/SkPictureAnalyzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0ba420258bb3d389b3f5a081278e622901bfc6dc
--- /dev/null
+++ b/src/core/SkPictureAnalyzer.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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"
+
+#if SK_SUPPORT_GPU
+
+namespace {
+
+inline bool veto_predicate(uint32_t numSlowPaths) {
+ return numSlowPaths > 5;
+}
+
+} // anonymous namespace
+
+SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> /* unused ATM */)
+ : fNumSlowPaths(0) { }
+
+SkPictureGpuAnalyzer::SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture,
+ sk_sp<GrContextThreadSafeProxy> ctx)
+ : SkPictureGpuAnalyzer(std::move(ctx)) {
+ 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(const char** whyNot) const {
+ if(veto_predicate(fNumSlowPaths)) {
+ if (whyNot) { *whyNot = "Too many slow paths (either concave or dashed)."; }
+ return false;
+ }
+ return true;
+}
+
+#endif // SK_SUPPORT_GPU

Powered by Google App Engine
This is Rietveld 408576698