blob: c46ca1e85436999cd2c89138f42640878c3e56d2 [file] [log] [blame]
fmalita796e3652016-05-13 11:40:07 -07001/*
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 "SkRefCnt.h"
fmalitab5fc58e2016-05-25 11:31:04 -070012#include "SkRegion.h"
fmalita796e3652016-05-13 11:40:07 -070013#include "SkTypes.h"
14
15#if SK_SUPPORT_GPU
16#include "GrContext.h"
17
fmalitab5fc58e2016-05-25 11:31:04 -070018class SkPath;
fmalita796e3652016-05-13 11:40:07 -070019class SkPicture;
20
21/** \class SkPictureGpuAnalyzer
22
23 Gathers GPU-related statistics for one or more SkPictures.
24*/
25class SK_API SkPictureGpuAnalyzer final : public SkNoncopyable {
26public:
27 explicit SkPictureGpuAnalyzer(sk_sp<GrContextThreadSafeProxy> = nullptr);
28 explicit SkPictureGpuAnalyzer(const sk_sp<SkPicture>& picture,
29 sk_sp<GrContextThreadSafeProxy> = nullptr);
30
31 /**
32 * Process the given picture and accumulate its stats.
33 */
fmalitab5fc58e2016-05-25 11:31:04 -070034 void analyzePicture(const SkPicture*);
35
fmalitab5fc58e2016-05-25 11:31:04 -070036 /**
37 * Process an explicit clipPath op.
38 */
39 void analyzeClipPath(const SkPath&, SkRegion::Op, bool doAntiAlias);
fmalita796e3652016-05-13 11:40:07 -070040
41 /**
42 * Reset all accumulated stats.
43 */
44 void reset();
45
46 /**
47 * Returns true if the analyzed pictures are suitable for rendering on the GPU.
48 */
49 bool suitableForGpuRasterization(const char** whyNot = nullptr) const;
50
senorblancoea976732016-06-09 12:43:30 -070051 /**
52 * Returns the number of commands which are slow to draw on the GPU, capped at the predicate
53 * max.
54 */
55 uint32_t numSlowGpuCommands() { return fNumSlowPaths; }
56
fmalita796e3652016-05-13 11:40:07 -070057private:
58 uint32_t fNumSlowPaths;
59
60 typedef SkNoncopyable INHERITED;
61};
62
63#endif // SK_SUPPORT_GPU
64
65#endif // SkPictureAnalyzer_DEFINED