From 796e365999220f53acc58ba91ed55bb35900c8bc Mon Sep 17 00:00:00 2001 From: fmalita Date: Fri, 13 May 2016 11:40:07 -0700 Subject: 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 --- include/core/SkPicture.h | 3 +++ include/core/SkPictureAnalyzer.h | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 include/core/SkPictureAnalyzer.h (limited to 'include') 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 = nullptr); + explicit SkPictureGpuAnalyzer(const sk_sp& picture, + sk_sp = 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 -- cgit v1.2.3