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