OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkPictureData_DEFINED | 8 #ifndef SkPictureData_DEFINED |
9 #define SkPictureData_DEFINED | 9 #define SkPictureData_DEFINED |
10 | 10 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkPathHeap.h" | 12 #include "SkPathHeap.h" |
13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
| 14 #include "SkPictureContentInfo.h" |
14 #include "SkPictureFlat.h" | 15 #include "SkPictureFlat.h" |
15 #include "SkPictureStateTree.h" | 16 #include "SkPictureStateTree.h" |
16 | 17 |
17 class SkData; | 18 class SkData; |
18 class SkPictureRecord; | 19 class SkPictureRecord; |
19 class SkReader32; | 20 class SkReader32; |
20 class SkStream; | 21 class SkStream; |
21 class SkWStream; | 22 class SkWStream; |
22 class SkBBoxHierarchy; | 23 class SkBBoxHierarchy; |
23 class SkMatrix; | 24 class SkMatrix; |
(...skipping 24 matching lines...) Expand all Loading... |
48 // This tag specifies the size of the ReadBuffer, needed for the following tags | 49 // This tag specifies the size of the ReadBuffer, needed for the following tags |
49 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') | 50 #define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y') |
50 // these are all inside the ARRAYS tag | 51 // these are all inside the ARRAYS tag |
51 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') | 52 #define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p') |
52 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') | 53 #define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ') |
53 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') | 54 #define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ') |
54 | 55 |
55 // Always write this guy last (with no length field afterwards) | 56 // Always write this guy last (with no length field afterwards) |
56 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') | 57 #define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ') |
57 | 58 |
58 // SkPictureContentInfo is not serialized! It is intended solely for use | |
59 // with suitableForGpuRasterization. | |
60 class SkPictureContentInfo { | |
61 public: | |
62 SkPictureContentInfo() { this->reset(); } | |
63 | |
64 SkPictureContentInfo(const SkPictureContentInfo& src) { this->set(src); } | |
65 | |
66 void set(const SkPictureContentInfo& src) { | |
67 fNumPaintWithPathEffectUses = src.fNumPaintWithPathEffectUses; | |
68 fNumFastPathDashEffects = src.fNumFastPathDashEffects; | |
69 fNumAAConcavePaths = src.fNumAAConcavePaths; | |
70 fNumAAHairlineConcavePaths = src.fNumAAHairlineConcavePaths; | |
71 } | |
72 | |
73 void reset() { | |
74 fNumPaintWithPathEffectUses = 0; | |
75 fNumFastPathDashEffects = 0; | |
76 fNumAAConcavePaths = 0; | |
77 fNumAAHairlineConcavePaths = 0; | |
78 } | |
79 | |
80 void swap(SkPictureContentInfo* other) { | |
81 SkTSwap(fNumPaintWithPathEffectUses, other->fNumPaintWithPathEffectUses)
; | |
82 SkTSwap(fNumFastPathDashEffects, other->fNumFastPathDashEffects); | |
83 SkTSwap(fNumAAConcavePaths, other->fNumAAConcavePaths); | |
84 SkTSwap(fNumAAHairlineConcavePaths, other->fNumAAHairlineConcavePaths); | |
85 } | |
86 | |
87 void incPaintWithPathEffectUses() { ++fNumPaintWithPathEffectUses; } | |
88 int numPaintWithPathEffectUses() const { return fNumPaintWithPathEffectUses;
} | |
89 | |
90 void incFastPathDashEffects() { ++fNumFastPathDashEffects; } | |
91 int numFastPathDashEffects() const { return fNumFastPathDashEffects; } | |
92 | |
93 void incAAConcavePaths() { ++fNumAAConcavePaths; } | |
94 int numAAConcavePaths() const { return fNumAAConcavePaths; } | |
95 | |
96 void incAAHairlineConcavePaths() { | |
97 ++fNumAAHairlineConcavePaths; | |
98 SkASSERT(fNumAAHairlineConcavePaths <= fNumAAConcavePaths); | |
99 } | |
100 int numAAHairlineConcavePaths() const { return fNumAAHairlineConcavePaths; } | |
101 | |
102 private: | |
103 // This field is incremented every time a paint with a path effect is | |
104 // used (i.e., it is not a de-duplicated count) | |
105 int fNumPaintWithPathEffectUses; | |
106 // This field is incremented every time a paint with a path effect that is | |
107 // dashed, we are drawing a line, and we can use the gpu fast path | |
108 int fNumFastPathDashEffects; | |
109 // This field is incremented every time an anti-aliased drawPath call is | |
110 // issued with a concave path | |
111 int fNumAAConcavePaths; | |
112 // This field is incremented every time a drawPath call is | |
113 // issued for a hairline stroked concave path. | |
114 int fNumAAHairlineConcavePaths; | |
115 }; | |
116 | |
117 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE | 59 #ifdef SK_SUPPORT_LEGACY_PICTURE_CLONE |
118 /** | 60 /** |
119 * Container for data that is needed to deep copy a SkPicture. The container | 61 * Container for data that is needed to deep copy a SkPicture. The container |
120 * enables the data to be generated once and reused for subsequent copies. | 62 * enables the data to be generated once and reused for subsequent copies. |
121 */ | 63 */ |
122 struct SkPictCopyInfo { | 64 struct SkPictCopyInfo { |
123 SkPictCopyInfo() : controller(1024) {} | 65 SkPictCopyInfo() : controller(1024) {} |
124 | 66 |
125 SkChunkFlatController controller; | 67 SkChunkFlatController controller; |
126 SkTDArray<SkFlatData*> paintData; | 68 SkTDArray<SkFlatData*> paintData; |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 220 |
279 const SkPictInfo fInfo; | 221 const SkPictInfo fInfo; |
280 | 222 |
281 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 223 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
282 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 224 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
283 | 225 |
284 void initForPlayback() const; | 226 void initForPlayback() const; |
285 }; | 227 }; |
286 | 228 |
287 #endif | 229 #endif |
OLD | NEW |