aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-05-13 11:40:07 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-05-13 11:40:07 -0700
commit796e365999220f53acc58ba91ed55bb35900c8bc (patch)
tree40e1884defdbee394a49ef5f105d4699bd753ea6 /include
parentb2df0c2702329be6380a943d548e7377a51d8565 (diff)
SkPictureGpuAnalyzer
Stateful helper for gathering multi-picture GPU stats. Exposes the existing SkPicture GPU veto semantics, while preserving the SKP impl (which has some nice properties: lazy, hierarchical, cached per pic). R=reed@google.com,bsalomon@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1974833003 Review-Url: https://codereview.chromium.org/1974833003
Diffstat (limited to 'include')
-rw-r--r--include/core/SkPicture.h3
-rw-r--r--include/core/SkPictureAnalyzer.h52
2 files changed, 55 insertions, 0 deletions
diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h
index 44a1e5bdb9..eb35ef6366 100644
--- a/include/core/SkPicture.h
+++ b/include/core/SkPicture.h
@@ -153,8 +153,10 @@ public:
static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
static bool InternalOnly_BufferIsSKP(SkReadBuffer*, SkPictInfo*);
+#ifdef SK_SUPPORT_LEGACY_PICTURE_GPUVETO
/** Return true if the picture is suitable for rendering on the GPU. */
bool suitableForGpuRasterization(GrContext*, const char** whyNot = NULL) const;
+#endif
// Sent via SkMessageBus from destructor.
struct DeletionMessage { int32_t fUniqueID; }; // TODO: -> uint32_t?
@@ -190,6 +192,7 @@ private:
friend class SkPictureData;
virtual int numSlowPaths() const = 0;
+ friend class SkPictureGpuAnalyzer;
friend struct SkPathCounter;
// V35: Store SkRect (rather then width & height) in header
diff --git a/include/core/SkPictureAnalyzer.h b/include/core/SkPictureAnalyzer.h
new file mode 100644
index 0000000000..fa8cdb1fd1
--- /dev/null
+++ b/include/core/SkPictureAnalyzer.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkPictureAnalyzer_DEFINED
+#define SkPictureAnalyzer_DEFINED
+
+#include "SkRefCnt.h"
+#include "SkTypes.h"
+
+#if SK_SUPPORT_GPU
+#include "GrContext.h"
+
+class SkPicture;
+
+/** \class SkPictureGpuAnalyzer
+
+ Gathers GPU-related statistics for one or more SkPictures.
+*/
+class SK_API SkPictureGpuAnalyzer final : public SkNoncopyable {
+public:
+ explicit SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> = nullptr);
+ explicit SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture,
+ sk_sp<GrContextThreadSafeProxy> = nullptr);
+
+ /**
+ * Process the given picture and accumulate its stats.
+ */
+ void analyze(const SkPicture*);
+
+ /**
+ * Reset all accumulated stats.
+ */
+ void reset();
+
+ /**
+ * Returns true if the analyzed pictures are suitable for rendering on the GPU.
+ */
+ bool suitableForGpuRasterization(const char** whyNot = nullptr) const;
+
+private:
+ uint32_t fNumSlowPaths;
+
+ typedef SkNoncopyable INHERITED;
+};
+
+#endif // SK_SUPPORT_GPU
+
+#endif // SkPictureAnalyzer_DEFINED