| 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 29 matching lines...) Expand all Loading... |
| 54 M(DrawPicture) \ | 55 M(DrawPicture) \ |
| 55 M(DrawPoints) \ | 56 M(DrawPoints) \ |
| 56 M(DrawPosText) \ | 57 M(DrawPosText) \ |
| 57 M(DrawPosTextH) \ | 58 M(DrawPosTextH) \ |
| 58 M(DrawText) \ | 59 M(DrawText) \ |
| 59 M(DrawTextOnPath) \ | 60 M(DrawTextOnPath) \ |
| 60 M(DrawRRect) \ | 61 M(DrawRRect) \ |
| 61 M(DrawRect) \ | 62 M(DrawRect) \ |
| 62 M(DrawSprite) \ | 63 M(DrawSprite) \ |
| 63 M(DrawTextBlob) \ | 64 M(DrawTextBlob) \ |
| 65 M(DrawAtlas) \ |
| 64 M(DrawVertices) | 66 M(DrawVertices) |
| 65 | 67 |
| 66 // Defines SkRecords::Type, an enum of all record types. | 68 // Defines SkRecords::Type, an enum of all record types. |
| 67 #define ENUM(T) T##_Type, | 69 #define ENUM(T) T##_Type, |
| 68 enum Type { SK_RECORD_TYPES(ENUM) }; | 70 enum Type { SK_RECORD_TYPES(ENUM) }; |
| 69 #undef ENUM | 71 #undef ENUM |
| 70 | 72 |
| 71 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar
gs, 2 args, etc. | 73 // Macros to make it easier to define a record for a draw call with 0 args, 1 ar
gs, 2 args, etc. |
| 72 // These should be clearer when you look at their use below. | 74 // These should be clearer when you look at their use below. |
| 73 #define RECORD0(T) \ | 75 #define RECORD0(T) \ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 119 |
| 118 #define RECORD5(T, A, a, B, b, C, c, D, d, E, e) \ | 120 #define RECORD5(T, A, a, B, b, C, c, D, d, E, e) \ |
| 119 struct T { \ | 121 struct T { \ |
| 120 static const Type kType = T##_Type; \ | 122 static const Type kType = T##_Type; \ |
| 121 T() {} \ | 123 T() {} \ |
| 122 template <typename Z, typename Y, typename X, typename W, typename V> \ | 124 template <typename Z, typename Y, typename X, typename W, typename V> \ |
| 123 T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {} \ | 125 T(Z a, Y b, X c, W d, V e) : a(a), b(b), c(c), d(d), e(e) {} \ |
| 124 A a; B b; C c; D d; E e; \ | 126 A a; B b; C c; D d; E e; \ |
| 125 }; | 127 }; |
| 126 | 128 |
| 129 #define RECORD7(T, A, a, B, b, C, c, D, d, E, e, F, f, G, g) \ |
| 130 struct T { \ |
| 131 static const Type kType = T##_Type; \ |
| 132 T() {} \ |
| 133 template <typename Z, typename Y, typename X, typename W, typename V, typena
me U, typename S> \ |
| 134 T(Z a, Y b, X c, W d, V e, U f, S g) : a(a), b(b), c(c), d(d), e(e), f(f), g
(g) {} \ |
| 135 A a; B b; C c; D d; E e; F f; G g; \ |
| 136 }; |
| 137 |
| 127 #define ACT_AS_PTR(ptr) \ | 138 #define ACT_AS_PTR(ptr) \ |
| 128 operator T*() const { return ptr; } \ | 139 operator T*() const { return ptr; } \ |
| 129 T* operator->() const { return ptr; } | 140 T* operator->() const { return ptr; } |
| 130 | 141 |
| 131 template <typename T> | 142 template <typename T> |
| 132 class RefBox : SkNoncopyable { | 143 class RefBox : SkNoncopyable { |
| 133 public: | 144 public: |
| 134 RefBox() {} | 145 RefBox() {} |
| 135 RefBox(T* obj) : fObj(SkSafeRef(obj)) {} | 146 RefBox(T* obj) : fObj(SkSafeRef(obj)) {} |
| 136 ~RefBox() { SkSafeUnref(fObj); } | 147 ~RefBox() { SkSafeUnref(fObj); } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 size_t, byteLength, | 326 size_t, byteLength, |
| 316 PreCachedPath, path, | 327 PreCachedPath, path, |
| 317 TypedMatrix, matrix); | 328 TypedMatrix, matrix); |
| 318 | 329 |
| 319 RECORD5(DrawPatch, SkPaint, paint, | 330 RECORD5(DrawPatch, SkPaint, paint, |
| 320 PODArray<SkPoint>, cubics, | 331 PODArray<SkPoint>, cubics, |
| 321 PODArray<SkColor>, colors, | 332 PODArray<SkColor>, colors, |
| 322 PODArray<SkPoint>, texCoords, | 333 PODArray<SkPoint>, texCoords, |
| 323 RefBox<SkXfermode>, xmode); | 334 RefBox<SkXfermode>, xmode); |
| 324 | 335 |
| 336 RECORD7(DrawAtlas, Optional<SkPaint>, paint, |
| 337 RefBox<const SkImage>, atlas, |
| 338 PODArray<SkRSXform>, xforms, |
| 339 PODArray<SkRect>, texs, |
| 340 PODArray<SkColor>, colors, |
| 341 int, count, |
| 342 Optional<SkRect>, cull); |
| 343 |
| 325 // This guy is so ugly we just write it manually. | 344 // This guy is so ugly we just write it manually. |
| 326 struct DrawVertices { | 345 struct DrawVertices { |
| 327 static const Type kType = DrawVertices_Type; | 346 static const Type kType = DrawVertices_Type; |
| 328 | 347 |
| 329 DrawVertices(const SkPaint& paint, | 348 DrawVertices(const SkPaint& paint, |
| 330 SkCanvas::VertexMode vmode, | 349 SkCanvas::VertexMode vmode, |
| 331 int vertexCount, | 350 int vertexCount, |
| 332 SkPoint* vertices, | 351 SkPoint* vertices, |
| 333 SkPoint* texs, | 352 SkPoint* texs, |
| 334 SkColor* colors, | 353 SkColor* colors, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 359 #undef RECORD0 | 378 #undef RECORD0 |
| 360 #undef RECORD1 | 379 #undef RECORD1 |
| 361 #undef RECORD2 | 380 #undef RECORD2 |
| 362 #undef RECORD3 | 381 #undef RECORD3 |
| 363 #undef RECORD4 | 382 #undef RECORD4 |
| 364 #undef RECORD5 | 383 #undef RECORD5 |
| 365 | 384 |
| 366 } // namespace SkRecords | 385 } // namespace SkRecords |
| 367 | 386 |
| 368 #endif//SkRecords_DEFINED | 387 #endif//SkRecords_DEFINED |
| OLD | NEW |