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