OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 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 SkPipeFormat_DEFINED | |
9 #define SkPipeFormat_DEFINED | |
10 | |
11 #include "SkTypes.h" | |
12 | |
13 #define kDefinePicture_ExtPipeVerb SkSetFourByteTag('s', 'k', 'p', 'i') | |
14 #define kDefineImage_ExtPipeVerb SkSetFourByteTag('s', 'k', 'i', 'm') | |
15 | |
16 enum class SkPipeVerb : uint8_t { | |
17 kSave, // extra == 0 | |
18 kSaveLayer, | |
19 kRestore, // extra == 0 | |
20 kConcat, // extra == SkMatrix::MaskType | |
21 | |
22 kClipRect, // extra == (SkRegion::Op << 1) | isAntiAlias:1 | |
23 kClipRRect, // extra == (SkRegion::Op << 1) | isAntiAlias:1 | |
24 kClipPath, // extra == (SkRegion::Op << 1) | isAntiAlias:1 | |
25 kClipRegion, // extra == (SkRegion::Op << 1) | |
26 | |
27 kDrawArc, // extra == useCenter | |
28 kDrawAtlas, // extra == has_colors | has_cull | has_paint | mode | |
29 kDrawDRRect, | |
30 kDrawText, // extra == byteLength:24 else next 32 | |
31 kDrawPosText, // extra == byteLength:24 else next 32 | |
32 kDrawPosTextH, // extra == byteLength:24 else next 32 | |
33 kDrawRegion, // extra == size:24 of region, or 0 means next 32 | |
34 kDrawTextOnPath, | |
35 kDrawTextBlob, | |
36 kDrawTextRSXform, // extra == (byteLength:23 << 1) else next 32 | has_cull _rect:1 | |
37 kDrawPatch, | |
38 kDrawPaint, // extra == 0 | |
39 kDrawPoints, // extra == PointMode | |
40 kDrawRect, // extra == 0 | |
41 kDrawPath, // extra == 0 | |
42 kDrawOval, // extra == 0 | |
43 kDrawRRect, // extra == 0 | |
44 | |
45 kDrawImage, // extra == has_paint:1 | |
46 kDrawImageRect, // extra == constraint | has_src_rect | has_paint | |
47 kDrawImageNine, // extra == has_paint:1 | |
48 kDrawImageLattice, // extra == x_count:8 | y_count:8 | has_paint:1 | |
49 | |
50 kDrawVertices, | |
51 | |
52 kDrawPicture, // extra == picture_index | |
53 kDrawAnnotation, // extra == (key_len_plus_1:23 << 1) else next 32 | has_ data:1 | |
54 | |
55 kDefineImage, // extra == image_index | |
56 kDefineTypeface, | |
57 kDefineFactory, // extra == factory_index (followed by padded getTypeNam e string) | |
58 kDefinePicture, // extra == 0 or forget_index + 1 (0 means we're definin g a new picture) | |
59 kEndPicture, // extra == picture_index | |
60 }; | |
61 | |
62 enum PaintUsage { | |
63 kText_PaintUsage = 1 << 0, | |
64 kTextBlob_PaintUsage = 1 << 1, | |
65 kGeometry_PaintUsage = 1 << 2, | |
66 kImage_PaintUsage = 1 << 3, | |
67 kSaveLayer_PaintUsage = 1 << 4, | |
68 kDrawPaint_PaintUsage = 1 << 5, | |
69 kVertices_PaintUsage = 1 << 6, | |
70 kRespectsStroke_PaintUsage = 1 << 7, | |
71 kUnknown_PaintUsage = 0xFF, | |
72 }; | |
73 | |
74 // must sum to <= 32 | |
75 enum BitsPerField { | |
76 kFlags_BPF = 16, | |
77 kFilter_BPF = 2, | |
78 kStyle_BPF = 2, | |
79 kCaps_BPF = 2, | |
80 kJoins_BPF = 2, | |
81 kHint_BPF = 2, | |
82 kAlign_BPF = 2, | |
83 kEncoding_BPF = 2, | |
84 }; | |
85 | |
86 enum { | |
87 kTextSize_NonDef = 1 << 0, | |
88 kTextScaleX_NonDef = 1 << 1, | |
89 kTextSkewX_NonDef = 1 << 2, | |
90 kStrokeWidth_NonDef = 1 << 3, | |
91 kStrokeMiter_NonDef = 1 << 4, | |
92 kColor_NonDef = 1 << 5, | |
93 kTypeface_NonDef = 1 << 6, | |
94 kPathEffect_NonDef = 1 << 7, | |
95 kShader_NonDef = 1 << 8, | |
96 kXfermode_NonDef = 1 << 9, | |
97 kMaskFilter_NonDef = 1 << 10, | |
98 kColorFilter_NonDef = 1 << 11, | |
99 kRasterizer_NonDef = 1 << 12, | |
100 kImageFilter_NonDef = 1 << 13, | |
101 kDrawLooper_NonDef = 1 << 14, | |
102 }; | |
103 | |
104 enum { | |
105 kFlags_SaveLayerMask = 0xFF, | |
106 kHasBounds_SaveLayerMask = 1 << 8, | |
107 kHasPaint_SaveLayerMask = 1 << 9, | |
108 kHasBackdrop_SaveLayerMask = 1 << 10, | |
109 kDontClipToLayer_SaveLayerMask = 1 << 11, | |
110 }; | |
111 | |
112 enum { | |
113 kDefineObjectBits = 20, | |
114 kIndex_DefineObjectMask = ((1 << kDefineObjectBits) - 1), | |
115 kForget_DefineObjectMask = 1 << 23, | |
116 kUser_DefineObjectMask = 0x7 << kDefineObjectBits, | |
117 // (Forget:1 | User:3 | Index:20) must fit in extra:24 | |
118 }; | |
119 | |
120 enum { | |
121 kTypeMask_ConcatMask = 0xF, | |
122 kSetMatrix_ConcatMask = 1 << 4, | |
123 }; | |
124 | |
125 enum { | |
126 kMode_DrawAtlasMask = 0xFF, | |
127 kHasColors_DrawAtlasMask = 1 << 8, | |
128 kHasCull_DrawAtlasMask = 1 << 9, | |
129 kHasPaint_DrawAtlasMask = 1 << 10, | |
130 }; | |
131 | |
132 enum { | |
133 kConstraint_DrawImageRectMask = 1 << 0, | |
134 kHasPaint_DrawImageRectMask = 1 << 1, | |
135 kHasSrcRect_DrawImageRectMask = 1 << 2, | |
136 }; | |
137 | |
138 enum { | |
139 kHasMatrix_DrawPictureExtra = 1 << 21, | |
mtklein_C
2016/09/12 19:47:59
Are these mean to fit in the 3 user bits above? W
reed1
2016/09/13 14:23:44
Done.
| |
140 kHasPaint_DrawPictureExtra = 1 << 22, | |
141 }; | |
142 | |
143 enum { | |
144 kIndex_DefineFactoryExtraBits = 10, | |
145 kNameLength_DefineFactoryExtraBits = 14, // includes trailing 0 | |
146 kNameLength_DefineFactoryExtraMask = (1 << kNameLength_DefineFactoryExtraBi ts) - 1, | |
147 }; | |
148 | |
149 enum { | |
150 kModeEnum_DrawPatchExtraMask = 0xFF, | |
151 kExplicitXfer_DrawPatchExtraValue = 0xFF, | |
152 kHasColors_DrawPatchExtraMask = 0x100, | |
153 kHasTexture_DrawPatchExtraMask = 0x200, | |
154 }; | |
155 | |
156 enum { | |
157 // if we store a zero for VCount, then read an int after the packedverb for the vcount | |
158 kVCount_DrawVerticesMask = (1 << 11) - 1, | |
159 | |
160 kVMode_DrawVerticesShift = 11, | |
161 kVMode_DrawVerticesMask = 3 << kVMode_DrawVerticesShift, | |
162 | |
163 kXMode_DrawVerticesShift = 13, | |
164 kXMode_DrawVerticesMask = 0xFF << kXMode_DrawVerticesShift, | |
165 | |
166 kHasTex_DrawVerticesMask = 1 << 21, | |
167 kHasColors_DrawVerticesMask = 1 << 22, | |
168 kHasIndices_DrawVerticesMask = 1 << 23, | |
169 }; | |
170 | |
171 enum { | |
172 kTextLength_DrawTextOnPathMask = (1 << 16) - 1, | |
173 kMatrixType_DrawTextOnPathShift = 16, | |
174 kMatrixType_DrawTextOnPathMask = 0xF << kMatrixType_DrawTextOnPathShift , | |
175 }; | |
176 | |
177 enum { | |
178 kHasPaint_DrawImageLatticeMask = 1 << 0, | |
179 kHasFlags_DrawImageLatticeMask = 1 << 1, | |
180 kXCount_DrawImageLatticeShift = 2, // bits 2:9 are xcount or FF m eans 32bits follow | |
181 kYCount_DrawImageLatticeShift = 10, // bits 10:17 are ycount or FF m eans 32bits follow | |
182 kCount_DrawImageLatticeMask = 0xFF, // sentinel for 32bits follow, | |
mtklein_C
2016/09/12 19:47:59
Let's use 0?
| |
183 // thus max inline count is 254 | |
184 }; | |
185 | |
186 //////////////////////////////////////////////////////////////////////////////// /////////////////// | |
187 | |
188 static inline bool fits_in(int value, int bits) { | |
189 return value >= 0 && value < (1 << bits); | |
190 } | |
191 | |
192 static inline void ASSERT_FITS_IN(int value, int bits) { | |
193 SkASSERT(fits_in(value, bits)); | |
194 } | |
195 | |
196 static inline uint32_t pack_verb(SkPipeVerb verb, unsigned extra = 0) { | |
197 //SkDebugf("pack [%d] %d\n", verb, extra); | |
198 ASSERT_FITS_IN((unsigned)verb, 8); | |
199 ASSERT_FITS_IN(extra, 24); | |
200 return ((uint32_t)verb << 24) | extra; | |
201 } | |
202 | |
203 static inline SkPipeVerb unpack_verb(uint32_t data) { | |
204 return (SkPipeVerb)(data >> 24); | |
205 } | |
206 | |
207 static inline unsigned unpack_verb_extra(uint32_t data) { | |
208 return data & 0xFFFFFF; | |
209 } | |
210 | |
211 #endif | |
OLD | NEW |