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