1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkPictureAnalyzer_DEFINED 9 #define SkPictureAnalyzer_DEFINED 10 11 #include "SkCanvas.h" 12 #include "SkRefCnt.h" 13 #include "SkRegion.h" 14 #include "SkTypes.h" 15 16 #if SK_SUPPORT_GPU 17 #include "GrContext.h" 18 19 class SkPath; 20 class SkPicture; 21 22 /** \class SkPictureGpuAnalyzer 23 24 Gathers GPU-related statistics for one or more SkPictures. 25 */ 26 class SK_API SkPictureGpuAnalyzer final : public SkNoncopyable { 27 public: 28 explicit SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> = nullptr); 29 explicit SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture, 30 sk_sp<GrContextThreadSafeProxy> = nullptr); 31 32 /** 33 * Process the given picture and accumulate its stats. 34 */ 35 void analyzePicture(const SkPicture*); 36 37 /** 38 * Process an explicit clipPath op. 39 */ 40 void analyzeClipPath(const SkPath&, SkClipOp, bool doAntiAlias); 41 42 /** 43 * Reset all accumulated stats. 44 */ 45 void reset(); 46 47 /** 48 * Returns true if the analyzed pictures are suitable for rendering on the GPU. 49 */ 50 bool suitableForGpuRasterization(const char** whyNot = nullptr) const; 51 52 /** 53 * Returns the number of commands which are slow to draw on the GPU, capped at the predicate 54 * max. 55 */ numSlowGpuCommands()56 uint32_t numSlowGpuCommands() { return fNumSlowPaths; } 57 58 private: 59 uint32_t fNumSlowPaths; 60 61 typedef SkNoncopyable INHERITED; 62 }; 63 64 #endif // SK_SUPPORT_GPU 65 66 #endif // SkPictureAnalyzer_DEFINED 67