| 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 |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkDrawable.h" | 12 #include "SkDrawable.h" |
| 13 #include "SkPathPriv.h" | 13 #include "SkPathPriv.h" |
| 14 #include "SkPicture.h" | 14 #include "SkPicture.h" |
| 15 #include "SkRSXform.h" |
| 15 #include "SkTextBlob.h" | 16 #include "SkTextBlob.h" |
| 16 | 17 |
| 17 namespace SkRecords { | 18 namespace SkRecords { |
| 18 | 19 |
| 19 // A list of all the types of canvas calls we can record. | 20 // A list of all the types of canvas calls we can record. |
| 20 // Each of these is reified into a struct below. | 21 // Each of these is reified into a struct below. |
| 21 // | 22 // |
| 22 // (We're using the macro-of-macro trick here to do several different things wit
h the same list.) | 23 // (We're using the macro-of-macro trick here to do several different things wit
h the same list.) |
| 23 // | 24 // |
| 24 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope
rate on SkRecords | 25 // We leave this SK_RECORD_TYPES macro defined for use by code that wants to ope
rate on SkRecords |
| (...skipping 26 matching lines...) Expand all Loading... |
| 51 M(DrawPicture) \ | 52 M(DrawPicture) \ |
| 52 M(DrawPoints) \ | 53 M(DrawPoints) \ |
| 53 M(DrawPosText) \ | 54 M(DrawPosText) \ |
| 54 M(DrawPosTextH) \ | 55 M(DrawPosTextH) \ |
| 55 M(DrawText) \ | 56 M(DrawText) \ |
| 56 M(DrawTextOnPath) \ | 57 M(DrawTextOnPath) \ |
| 57 M(DrawRRect) \ | 58 M(DrawRRect) \ |
| 58 M(DrawRect) \ | 59 M(DrawRect) \ |
| 59 M(DrawSprite) \ | 60 M(DrawSprite) \ |
| 60 M(DrawTextBlob) \ | 61 M(DrawTextBlob) \ |
| 62 M(DrawAtlas) \ |
| 61 M(DrawVertices) | 63 M(DrawVertices) |
| 62 | 64 |
| 63 // Defines SkRecords::Type, an enum of all record types. | 65 // Defines SkRecords::Type, an enum of all record types. |
| 64 #define ENUM(T) T##_Type, | 66 #define ENUM(T) T##_Type, |
| 65 enum Type { SK_RECORD_TYPES(ENUM) }; | 67 enum Type { SK_RECORD_TYPES(ENUM) }; |
| 66 #undef ENUM | 68 #undef ENUM |
| 67 | 69 |
| 68 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar
gs, 2 args, etc. | 70 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar
gs, 2 args, etc. |
| 69 // These should be clearer when you look at their use below. | 71 // These should be clearer when you look at their use below. |
| 70 #define RECORD0(T) \ | 72 #define RECORD0(T) \ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 116 |
| 115 #define RECORD5(T, A, a, B, b, C, c, D, d, E, e) \ | 117 #define RECORD5(T, A, a, B, b, C, c, D, d, E, e) \ |
| 116 struct T { \ | 118 struct T { \ |
| 117 static const Type kType = T##_Type; \ | 119 static const Type kType = T##_Type; \ |
| 118 T() {} \ | 120 T() {} \ |
| 119 template <typename Z, typename Y, typename X, typename W, typename V> \ | 121 template <typename Z, typename Y, typename X, typename W, typename V> \ |
| 120 T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {} \ | 122 T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {} \ |
| 121 A a; B b; C c; D d; E e; \ | 123 A a; B b; C c; D d; E e; \ |
| 122 }; | 124 }; |
| 123 | 125 |
| 126 #define RECORD8(T, A, a, B, b, C, c, D, d, E, e, F, f, G, g, H, h) \ |
| 127 struct T { \ |
| 128 static const Type kType = T##_Type; \ |
| 129 T() {} \ |
| 130 template <typename Z, typename Y, typename X, typename W, typename V, typena
me U, typename S, typename R> \ |
| 131 T(Z a, Y b, X c, W d, V e, U f, S g, R h) : a(a), b(b), c(c), d(d), e(e), f(
f), g(g), h(h) {} \ |
| 132 A a; B b; C c; D d; E e; F f; G g; H h; \ |
| 133 }; |
| 134 |
| 124 #define ACT_AS_PTR(ptr) \ | 135 #define ACT_AS_PTR(ptr) \ |
| 125 operator T*() const { return ptr; } \ | 136 operator T*() const { return ptr; } \ |
| 126 T* operator->() const { return ptr; } | 137 T* operator->() const { return ptr; } |
| 127 | 138 |
| 128 template <typename T> | 139 template <typename T> |
| 129 class RefBox : SkNoncopyable { | 140 class RefBox : SkNoncopyable { |
| 130 public: | 141 public: |
| 131 RefBox() {} | 142 RefBox() {} |
| 132 RefBox(T* obj) : fObj(SkSafeRef(obj)) {} | 143 RefBox(T* obj) : fObj(SkSafeRef(obj)) {} |
| 133 ~RefBox() { SkSafeUnref(fObj); } | 144 ~RefBox() { SkSafeUnref(fObj); } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 size_t, byteLength, | 321 size_t, byteLength, |
| 311 PreCachedPath, path, | 322 PreCachedPath, path, |
| 312 TypedMatrix, matrix); | 323 TypedMatrix, matrix); |
| 313 | 324 |
| 314 RECORD5(DrawPatch, SkPaint, paint, | 325 RECORD5(DrawPatch, SkPaint, paint, |
| 315 PODArray<SkPoint>, cubics, | 326 PODArray<SkPoint>, cubics, |
| 316 PODArray<SkColor>, colors, | 327 PODArray<SkColor>, colors, |
| 317 PODArray<SkPoint>, texCoords, | 328 PODArray<SkPoint>, texCoords, |
| 318 RefBox<SkXfermode>, xmode); | 329 RefBox<SkXfermode>, xmode); |
| 319 | 330 |
| 331 RECORD8(DrawAtlas, Optional<SkPaint>, paint, |
| 332 RefBox<const SkImage>, atlas, |
| 333 PODArray<SkRSXform>, xforms, |
| 334 PODArray<SkRect>, texs, |
| 335 PODArray<SkColor>, colors, |
| 336 int, count, |
| 337 SkXfermode::Mode, mode, |
| 338 Optional<SkRect>, cull); |
| 339 |
| 320 // This guy is so ugly we just write it manually. | 340 // This guy is so ugly we just write it manually. |
| 321 struct DrawVertices { | 341 struct DrawVertices { |
| 322 static const Type kType = DrawVertices_Type; | 342 static const Type kType = DrawVertices_Type; |
| 323 | 343 |
| 324 DrawVertices(const SkPaint& paint, | 344 DrawVertices(const SkPaint& paint, |
| 325 SkCanvas::VertexMode vmode, | 345 SkCanvas::VertexMode vmode, |
| 326 int vertexCount, | 346 int vertexCount, |
| 327 SkPoint* vertices, | 347 SkPoint* vertices, |
| 328 SkPoint* texs, | 348 SkPoint* texs, |
| 329 SkColor* colors, | 349 SkColor* colors, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 350 PODArray<uint16_t> indices; | 370 PODArray<uint16_t> indices; |
| 351 int indexCount; | 371 int indexCount; |
| 352 }; | 372 }; |
| 353 | 373 |
| 354 #undef RECORD0 | 374 #undef RECORD0 |
| 355 #undef RECORD1 | 375 #undef RECORD1 |
| 356 #undef RECORD2 | 376 #undef RECORD2 |
| 357 #undef RECORD3 | 377 #undef RECORD3 |
| 358 #undef RECORD4 | 378 #undef RECORD4 |
| 359 #undef RECORD5 | 379 #undef RECORD5 |
| 380 #undef RECORD8 |
| 360 | 381 |
| 361 } // namespace SkRecords | 382 } // namespace SkRecords |
| 362 | 383 |
| 363 #endif//SkRecords_DEFINED | 384 #endif//SkRecords_DEFINED |
| OLD | NEW |