Line data Source code
1 : /*
2 : * Copyright 2014 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 SkPictureContentInfo_DEFINED
9 : #define SkPictureContentInfo_DEFINED
10 :
11 : #include "SkPaint.h"
12 : #include "SkTDArray.h"
13 :
14 : class GrContext;
15 :
16 0 : class SkPictureContentInfo {
17 : public:
18 0 : SkPictureContentInfo() { this->reset(); }
19 : SkPictureContentInfo(const SkPictureContentInfo& src) { this->set(src); }
20 :
21 : int numOperations() const { return fNumOperations; }
22 : bool hasText() const { return fNumTexts > 0; }
23 :
24 0 : int numLayers() const { return fNumLayers; }
25 : int numInteriorLayers() const { return fNumInteriorLayers; }
26 : int numLeafLayers() const { return fNumLeafLayers; }
27 :
28 : bool suitableForGpuRasterization(GrContext* context, const char **reason,
29 : int sampleCount) const;
30 :
31 0 : void addOperation() { ++fNumOperations; }
32 :
33 : void onDrawPoints(size_t count, const SkPaint& paint);
34 : void onDrawPath(const SkPath& path, const SkPaint& paint);
35 : void onAddPaintPtr(const SkPaint* paint);
36 0 : void onDrawText() { ++fNumTexts; }
37 :
38 : void onSaveLayer();
39 : void onSave();
40 : void onRestore();
41 : void rescindLastSave();
42 : void rescindLastSaveLayer();
43 :
44 : void set(const SkPictureContentInfo& src);
45 : void reset();
46 : void swap(SkPictureContentInfo* other);
47 :
48 : private:
49 : // Raw count of operations in the picture
50 : int fNumOperations;
51 : // Count of all forms of drawText
52 : int fNumTexts;
53 :
54 : // This field is incremented every time a paint with a path effect is
55 : // used (i.e., it is not a de-duplicated count)
56 : int fNumPaintWithPathEffectUses;
57 : // This field is incremented every time a paint with a path effect that is
58 : // dashed, we are drawing a line, and we can use the gpu fast path
59 : int fNumFastPathDashEffects;
60 : // This field is incremented every time an anti-aliased drawPath call is
61 : // issued with a concave path
62 : int fNumAAConcavePaths;
63 : // This field is incremented every time a drawPath call is
64 : // issued for a hairline stroked concave path.
65 : int fNumAAHairlineConcavePaths;
66 : // This field is incremented every time a drawPath call is
67 : // issued for a concave path that can be rendered with distance fields
68 : int fNumAADFEligibleConcavePaths;
69 : // These fields track the different layer flavors. fNumLayers is just
70 : // a count of all saveLayers, fNumInteriorLayers is the number of layers
71 : // with a layer inside them, fNumLeafLayers is the number of layers with
72 : // no layer inside them.
73 : int fNumLayers;
74 : int fNumInteriorLayers;
75 : int fNumLeafLayers;
76 :
77 : enum Flags {
78 : kSave_Flag = 0x1,
79 : kSaveLayer_Flag = 0x2,
80 :
81 : // Did the current save or saveLayer contain another saveLayer.
82 : // Percolated back down the save stack.
83 : kContainedSaveLayer_Flag = 0x4
84 : };
85 :
86 : // Stack of save vs saveLayer information to track nesting
87 : SkTDArray<uint32_t> fSaveStack;
88 : };
89 :
90 : #endif
|