Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: src/pipe/SkPipeFormat.h

Issue 2201323003: add pipecanvas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add test for writeImage Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 kObjectDefinitionBits = 20,
114 kIndex_ObjectDefinitionMask = ((1 << kObjectDefinitionBits) - 1),
115 kUser_ObjectDefinitionMask = 0x7 << kObjectDefinitionBits,
116 kUndef_ObjectDefinitionMask = 1 << 23,
117 // (Undef: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 kHasPaint_DrawImageMask = 1 << 0,
134 };
135
136 enum {
137 kConstraint_DrawImageRectMask = 1 << 0,
138 kHasPaint_DrawImageRectMask = 1 << 1,
139 kHasSrcRect_DrawImageRectMask = 1 << 2,
140 };
141
142 enum {
143 kHasPaint_DrawImageNineMask = 1 << 0,
144 };
145
146 enum {
147 // picture_index takes the first kObjectDefinitionBits bits
148 kHasMatrix_DrawPictureExtra = 1 << 21,
149 kHasPaint_DrawPictureExtra = 1 << 22,
150 };
151
152 enum {
153 kIndex_DefineFactoryExtraBits = 10,
154 kNameLength_DefineFactoryExtraBits = 14, // includes trailing 0
155 kNameLength_DefineFactoryExtraMask = (1 << kNameLength_DefineFactoryExtraBi ts) - 1,
156 };
157
158 enum {
159 kModeEnum_DrawPatchExtraMask = 0xFF,
160 kExplicitXfer_DrawPatchExtraValue = 0xFF,
161 kHasColors_DrawPatchExtraMask = 0x100,
162 kHasTexture_DrawPatchExtraMask = 0x200,
163 };
164
165 enum {
166 // if we store a zero for VCount, then read an int after the packedverb for the vcount
167 kVCount_DrawVerticesMask = (1 << 11) - 1,
168
169 kVMode_DrawVerticesShift = 11,
170 kVMode_DrawVerticesMask = 3 << kVMode_DrawVerticesShift,
171
172 kXMode_DrawVerticesShift = 13,
173 kXMode_DrawVerticesMask = 0xFF << kXMode_DrawVerticesShift,
174
175 kHasTex_DrawVerticesMask = 1 << 21,
176 kHasColors_DrawVerticesMask = 1 << 22,
177 kHasIndices_DrawVerticesMask = 1 << 23,
178 };
179
180 enum {
181 kTextLength_DrawTextOnPathMask = (1 << 16) - 1,
182 kMatrixType_DrawTextOnPathShift = 16,
183 kMatrixType_DrawTextOnPathMask = 0xF << kMatrixType_DrawTextOnPathShift ,
184 };
185
186 enum {
187 kHasPaint_DrawImageLatticeMask = 1 << 0,
188 kHasFlags_DrawImageLatticeMask = 1 << 1,
189 kXCount_DrawImageLatticeShift = 2, // bits 2:9 are xcount or FF m eans 32bits follow
190 kYCount_DrawImageLatticeShift = 10, // bits 10:17 are ycount or FF m eans 32bits follow
191 kCount_DrawImageLatticeMask = 0xFF, // sentinel for 32bits follow,
192 // thus max inline count is 254
193 };
194
195 //////////////////////////////////////////////////////////////////////////////// ///////////////////
196
197 static inline bool fits_in(int value, int bits) {
198 return value >= 0 && value < (1 << bits);
199 }
200
201 static inline void ASSERT_FITS_IN(int value, int bits) {
202 SkASSERT(fits_in(value, bits));
203 }
204
205 static inline uint32_t pack_verb(SkPipeVerb verb, unsigned extra = 0) {
206 //SkDebugf("pack [%d] %d\n", verb, extra);
207 ASSERT_FITS_IN((unsigned)verb, 8);
208 ASSERT_FITS_IN(extra, 24);
209 return ((uint32_t)verb << 24) | extra;
210 }
211
212 static inline SkPipeVerb unpack_verb(uint32_t data) {
213 return (SkPipeVerb)(data >> 24);
214 }
215
216 static inline unsigned unpack_verb_extra(uint32_t data) {
217 return data & 0xFFFFFF;
218 }
219
220 #endif
OLDNEW
« src/core/SkPipe.h ('K') | « src/pipe/SkPipeCanvas.cpp ('k') | src/pipe/SkPipeReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698