| 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 SkRecords_DEFINED | 8 #ifndef SkRecords_DEFINED |
| 9 #define SkRecords_DEFINED | 9 #define SkRecords_DEFINED |
| 10 | 10 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // This may not cover all SkMatrices used by the picture (e.g. some could be hid
ing in a shader). | 146 // This may not cover all SkMatrices used by the picture (e.g. some could be hid
ing in a shader). |
| 147 struct TypedMatrix : public SkMatrix { | 147 struct TypedMatrix : public SkMatrix { |
| 148 TypedMatrix() {} | 148 TypedMatrix() {} |
| 149 TypedMatrix(const SkMatrix& matrix); | 149 TypedMatrix(const SkMatrix& matrix); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 enum Tags { | 152 enum Tags { |
| 153 kDraw_Tag = 1, // May draw something (usually named DrawFoo). | 153 kDraw_Tag = 1, // May draw something (usually named DrawFoo). |
| 154 kHasImage_Tag = 2, // Contains an SkImage or SkBitmap. | 154 kHasImage_Tag = 2, // Contains an SkImage or SkBitmap. |
| 155 kHasText_Tag = 4, // Contains text. | 155 kHasText_Tag = 4, // Contains text. |
| 156 kHasPaint_Tag = 8, // May have an SkPaint field, at least optionally. |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 // A macro to make it a little easier to define a struct that can be stored in S
kRecord. | 159 // A macro to make it a little easier to define a struct that can be stored in S
kRecord. |
| 159 #define RECORD(T, tags, ...) \ | 160 #define RECORD(T, tags, ...) \ |
| 160 struct T { \ | 161 struct T { \ |
| 161 static const Type kType = T##_Type; \ | 162 static const Type kType = T##_Type; \ |
| 162 static const int kTags = tags; \ | 163 static const int kTags = tags; \ |
| 163 __VA_ARGS__; \ | 164 __VA_ARGS__; \ |
| 164 }; | 165 }; |
| 165 | 166 |
| 166 RECORD(NoOp, 0); | 167 RECORD(NoOp, 0); |
| 167 RECORD(Restore, 0, | 168 RECORD(Restore, 0, |
| 168 SkIRect devBounds; | 169 SkIRect devBounds; |
| 169 TypedMatrix matrix); | 170 TypedMatrix matrix); |
| 170 RECORD(Save, 0); | 171 RECORD(Save, 0); |
| 171 | 172 |
| 172 RECORD(SaveLayer, 0, | 173 RECORD(SaveLayer, kHasPaint_Tag, |
| 173 Optional<SkRect> bounds; | 174 Optional<SkRect> bounds; |
| 174 Optional<SkPaint> paint; | 175 Optional<SkPaint> paint; |
| 175 sk_sp<const SkImageFilter> backdrop; | 176 sk_sp<const SkImageFilter> backdrop; |
| 176 SkCanvas::SaveLayerFlags saveLayerFlags); | 177 SkCanvas::SaveLayerFlags saveLayerFlags); |
| 177 | 178 |
| 178 RECORD(SetMatrix, 0, | 179 RECORD(SetMatrix, 0, |
| 179 TypedMatrix matrix); | 180 TypedMatrix matrix); |
| 180 RECORD(Concat, 0, | 181 RECORD(Concat, 0, |
| 181 TypedMatrix matrix); | 182 TypedMatrix matrix); |
| 182 | 183 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 201 RECORD(ClipRect, 0, | 202 RECORD(ClipRect, 0, |
| 202 SkIRect devBounds; | 203 SkIRect devBounds; |
| 203 SkRect rect; | 204 SkRect rect; |
| 204 RegionOpAndAA opAA); | 205 RegionOpAndAA opAA); |
| 205 RECORD(ClipRegion, 0, | 206 RECORD(ClipRegion, 0, |
| 206 SkIRect devBounds; | 207 SkIRect devBounds; |
| 207 SkRegion region; | 208 SkRegion region; |
| 208 SkRegion::Op op); | 209 SkRegion::Op op); |
| 209 | 210 |
| 210 // While not strictly required, if you have an SkPaint, it's fastest to put it f
irst. | 211 // While not strictly required, if you have an SkPaint, it's fastest to put it f
irst. |
| 211 RECORD(DrawDRRect, kDraw_Tag, | 212 RECORD(DrawDRRect, kDraw_Tag|kHasPaint_Tag, |
| 212 SkPaint paint; | 213 SkPaint paint; |
| 213 SkRRect outer; | 214 SkRRect outer; |
| 214 SkRRect inner); | 215 SkRRect inner); |
| 215 RECORD(DrawDrawable, kDraw_Tag, | 216 RECORD(DrawDrawable, kDraw_Tag, |
| 216 Optional<SkMatrix> matrix; | 217 Optional<SkMatrix> matrix; |
| 217 SkRect worstCaseBounds; | 218 SkRect worstCaseBounds; |
| 218 int32_t index); | 219 int32_t index); |
| 219 RECORD(DrawImage, kDraw_Tag|kHasImage_Tag, | 220 RECORD(DrawImage, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag, |
| 220 Optional<SkPaint> paint; | 221 Optional<SkPaint> paint; |
| 221 sk_sp<const SkImage> image; | 222 sk_sp<const SkImage> image; |
| 222 SkScalar left; | 223 SkScalar left; |
| 223 SkScalar top); | 224 SkScalar top); |
| 224 RECORD(DrawImageRect, kDraw_Tag|kHasImage_Tag, | 225 RECORD(DrawImageRect, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag, |
| 225 Optional<SkPaint> paint; | 226 Optional<SkPaint> paint; |
| 226 sk_sp<const SkImage> image; | 227 sk_sp<const SkImage> image; |
| 227 Optional<SkRect> src; | 228 Optional<SkRect> src; |
| 228 SkRect dst; | 229 SkRect dst; |
| 229 SkCanvas::SrcRectConstraint constraint); | 230 SkCanvas::SrcRectConstraint constraint); |
| 230 RECORD(DrawImageNine, kDraw_Tag|kHasImage_Tag, | 231 RECORD(DrawImageNine, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag, |
| 231 Optional<SkPaint> paint; | 232 Optional<SkPaint> paint; |
| 232 sk_sp<const SkImage> image; | 233 sk_sp<const SkImage> image; |
| 233 SkIRect center; | 234 SkIRect center; |
| 234 SkRect dst); | 235 SkRect dst); |
| 235 RECORD(DrawOval, kDraw_Tag, | 236 RECORD(DrawOval, kDraw_Tag|kHasPaint_Tag, |
| 236 SkPaint paint; | 237 SkPaint paint; |
| 237 SkRect oval); | 238 SkRect oval); |
| 238 RECORD(DrawPaint, kDraw_Tag, | 239 RECORD(DrawPaint, kDraw_Tag|kHasPaint_Tag, |
| 239 SkPaint paint); | 240 SkPaint paint); |
| 240 RECORD(DrawPath, kDraw_Tag, | 241 RECORD(DrawPath, kDraw_Tag|kHasPaint_Tag, |
| 241 SkPaint paint; | 242 SkPaint paint; |
| 242 PreCachedPath path); | 243 PreCachedPath path); |
| 243 RECORD(DrawPicture, kDraw_Tag, | 244 RECORD(DrawPicture, kDraw_Tag|kHasPaint_Tag, |
| 244 Optional<SkPaint> paint; | 245 Optional<SkPaint> paint; |
| 245 sk_sp<const SkPicture> picture; | 246 sk_sp<const SkPicture> picture; |
| 246 TypedMatrix matrix); | 247 TypedMatrix matrix); |
| 247 RECORD(DrawShadowedPicture, kDraw_Tag, | 248 RECORD(DrawShadowedPicture, kDraw_Tag|kHasPaint_Tag, |
| 248 Optional<SkPaint> paint; | 249 Optional<SkPaint> paint; |
| 249 sk_sp<const SkPicture> picture; | 250 sk_sp<const SkPicture> picture; |
| 250 TypedMatrix matrix); | 251 TypedMatrix matrix); |
| 251 RECORD(DrawPoints, kDraw_Tag, | 252 RECORD(DrawPoints, kDraw_Tag|kHasPaint_Tag, |
| 252 SkPaint paint; | 253 SkPaint paint; |
| 253 SkCanvas::PointMode mode; | 254 SkCanvas::PointMode mode; |
| 254 unsigned count; | 255 unsigned count; |
| 255 SkPoint* pts); | 256 SkPoint* pts); |
| 256 RECORD(DrawPosText, kDraw_Tag|kHasText_Tag, | 257 RECORD(DrawPosText, kDraw_Tag|kHasText_Tag|kHasPaint_Tag, |
| 257 SkPaint paint; | 258 SkPaint paint; |
| 258 PODArray<char> text; | 259 PODArray<char> text; |
| 259 size_t byteLength; | 260 size_t byteLength; |
| 260 PODArray<SkPoint> pos); | 261 PODArray<SkPoint> pos); |
| 261 RECORD(DrawPosTextH, kDraw_Tag|kHasText_Tag, | 262 RECORD(DrawPosTextH, kDraw_Tag|kHasText_Tag|kHasPaint_Tag, |
| 262 SkPaint paint; | 263 SkPaint paint; |
| 263 PODArray<char> text; | 264 PODArray<char> text; |
| 264 unsigned byteLength; | 265 unsigned byteLength; |
| 265 SkScalar y; | 266 SkScalar y; |
| 266 PODArray<SkScalar> xpos); | 267 PODArray<SkScalar> xpos); |
| 267 RECORD(DrawRRect, kDraw_Tag, | 268 RECORD(DrawRRect, kDraw_Tag|kHasPaint_Tag, |
| 268 SkPaint paint; | 269 SkPaint paint; |
| 269 SkRRect rrect); | 270 SkRRect rrect); |
| 270 RECORD(DrawRect, kDraw_Tag, | 271 RECORD(DrawRect, kDraw_Tag|kHasPaint_Tag, |
| 271 SkPaint paint; | 272 SkPaint paint; |
| 272 SkRect rect); | 273 SkRect rect); |
| 273 RECORD(DrawText, kDraw_Tag|kHasText_Tag, | 274 RECORD(DrawText, kDraw_Tag|kHasText_Tag|kHasPaint_Tag, |
| 274 SkPaint paint; | 275 SkPaint paint; |
| 275 PODArray<char> text; | 276 PODArray<char> text; |
| 276 size_t byteLength; | 277 size_t byteLength; |
| 277 SkScalar x; | 278 SkScalar x; |
| 278 SkScalar y); | 279 SkScalar y); |
| 279 RECORD(DrawTextBlob, kDraw_Tag|kHasText_Tag, | 280 RECORD(DrawTextBlob, kDraw_Tag|kHasText_Tag|kHasPaint_Tag, |
| 280 SkPaint paint; | 281 SkPaint paint; |
| 281 sk_sp<const SkTextBlob> blob; | 282 sk_sp<const SkTextBlob> blob; |
| 282 SkScalar x; | 283 SkScalar x; |
| 283 SkScalar y); | 284 SkScalar y); |
| 284 RECORD(DrawTextOnPath, kDraw_Tag|kHasText_Tag, | 285 RECORD(DrawTextOnPath, kDraw_Tag|kHasText_Tag|kHasPaint_Tag, |
| 285 SkPaint paint; | 286 SkPaint paint; |
| 286 PODArray<char> text; | 287 PODArray<char> text; |
| 287 size_t byteLength; | 288 size_t byteLength; |
| 288 PreCachedPath path; | 289 PreCachedPath path; |
| 289 TypedMatrix matrix); | 290 TypedMatrix matrix); |
| 290 RECORD(DrawTextRSXform, kDraw_Tag|kHasText_Tag, | 291 RECORD(DrawTextRSXform, kDraw_Tag|kHasText_Tag|kHasPaint_Tag, |
| 291 SkPaint paint; | 292 SkPaint paint; |
| 292 PODArray<char> text; | 293 PODArray<char> text; |
| 293 size_t byteLength; | 294 size_t byteLength; |
| 294 PODArray<SkRSXform> xforms; | 295 PODArray<SkRSXform> xforms; |
| 295 Optional<SkRect> cull); | 296 Optional<SkRect> cull); |
| 296 RECORD(DrawPatch, kDraw_Tag, | 297 RECORD(DrawPatch, kDraw_Tag|kHasPaint_Tag, |
| 297 SkPaint paint; | 298 SkPaint paint; |
| 298 PODArray<SkPoint> cubics; | 299 PODArray<SkPoint> cubics; |
| 299 PODArray<SkColor> colors; | 300 PODArray<SkColor> colors; |
| 300 PODArray<SkPoint> texCoords; | 301 PODArray<SkPoint> texCoords; |
| 301 sk_sp<SkXfermode> xmode); | 302 sk_sp<SkXfermode> xmode); |
| 302 RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag, | 303 RECORD(DrawAtlas, kDraw_Tag|kHasImage_Tag|kHasPaint_Tag, |
| 303 Optional<SkPaint> paint; | 304 Optional<SkPaint> paint; |
| 304 sk_sp<const SkImage> atlas; | 305 sk_sp<const SkImage> atlas; |
| 305 PODArray<SkRSXform> xforms; | 306 PODArray<SkRSXform> xforms; |
| 306 PODArray<SkRect> texs; | 307 PODArray<SkRect> texs; |
| 307 PODArray<SkColor> colors; | 308 PODArray<SkColor> colors; |
| 308 int count; | 309 int count; |
| 309 SkXfermode::Mode mode; | 310 SkXfermode::Mode mode; |
| 310 Optional<SkRect> cull); | 311 Optional<SkRect> cull); |
| 311 RECORD(DrawVertices, kDraw_Tag, | 312 RECORD(DrawVertices, kDraw_Tag|kHasPaint_Tag, |
| 312 SkPaint paint; | 313 SkPaint paint; |
| 313 SkCanvas::VertexMode vmode; | 314 SkCanvas::VertexMode vmode; |
| 314 int vertexCount; | 315 int vertexCount; |
| 315 PODArray<SkPoint> vertices; | 316 PODArray<SkPoint> vertices; |
| 316 PODArray<SkPoint> texs; | 317 PODArray<SkPoint> texs; |
| 317 PODArray<SkColor> colors; | 318 PODArray<SkColor> colors; |
| 318 sk_sp<SkXfermode> xmode; | 319 sk_sp<SkXfermode> xmode; |
| 319 PODArray<uint16_t> indices; | 320 PODArray<uint16_t> indices; |
| 320 int indexCount); | 321 int indexCount); |
| 321 RECORD(DrawAnnotation, 0, | 322 RECORD(DrawAnnotation, 0, // TODO: kDraw_Tag, skia:5548 |
| 322 SkRect rect; | 323 SkRect rect; |
| 323 SkString key; | 324 SkString key; |
| 324 sk_sp<SkData> value); | 325 sk_sp<SkData> value); |
| 325 #undef RECORD | 326 #undef RECORD |
| 326 | 327 |
| 327 } // namespace SkRecords | 328 } // namespace SkRecords |
| 328 | 329 |
| 329 #endif//SkRecords_DEFINED | 330 #endif//SkRecords_DEFINED |
| OLD | NEW |