commit-bot@chromium.org | c4b21e6 | 2014-04-11 18:33:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 8 | #ifndef SkRecords_DEFINED |
| 9 | #define SkRecords_DEFINED |
| 10 | |
| 11 | #include "SkCanvas.h" |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame] | 12 | #include "SkDrawable.h" |
reed | 026beb5 | 2015-06-10 14:23:15 -0700 | [diff] [blame] | 13 | #include "SkPathPriv.h" |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 14 | #include "SkPicture.h" |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 15 | #include "SkRSXform.h" |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 16 | #include "SkTextBlob.h" |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 17 | |
| 18 | namespace SkRecords { |
| 19 | |
| 20 | // A list of all the types of canvas calls we can record. |
| 21 | // Each of these is reified into a struct below. |
| 22 | // |
| 23 | // (We're using the macro-of-macro trick here to do several different things with the same list.) |
| 24 | // |
| 25 | // We leave this SK_RECORD_TYPES macro defined for use by code that wants to operate on SkRecords |
| 26 | // types polymorphically. (See SkRecord::Record::{visit,mutate} for an example.) |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 27 | // |
| 28 | // Order doesn't technically matter here, but the compiler can generally generate better code if |
| 29 | // you keep them semantically grouped, especially the Draws. It's also nice to leave NoOp at 0. |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 30 | #define SK_RECORD_TYPES(M) \ |
| 31 | M(NoOp) \ |
| 32 | M(Restore) \ |
| 33 | M(Save) \ |
| 34 | M(SaveLayer) \ |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 35 | M(SetMatrix) \ |
| 36 | M(ClipPath) \ |
| 37 | M(ClipRRect) \ |
| 38 | M(ClipRect) \ |
| 39 | M(ClipRegion) \ |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 40 | M(DrawBitmap) \ |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 41 | M(DrawBitmapNine) \ |
| 42 | M(DrawBitmapRectToRect) \ |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 43 | M(DrawBitmapRectToRectBleed) \ |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 44 | M(DrawDrawable) \ |
piotaixr | 6515175 | 2014-10-16 11:58:39 -0700 | [diff] [blame] | 45 | M(DrawImage) \ |
| 46 | M(DrawImageRect) \ |
reed | 4c21dc5 | 2015-06-25 12:32:03 -0700 | [diff] [blame] | 47 | M(DrawImageNine) \ |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 48 | M(DrawDRRect) \ |
| 49 | M(DrawOval) \ |
| 50 | M(DrawPaint) \ |
| 51 | M(DrawPath) \ |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 52 | M(DrawPatch) \ |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 53 | M(DrawPicture) \ |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 54 | M(DrawPoints) \ |
| 55 | M(DrawPosText) \ |
| 56 | M(DrawPosTextH) \ |
mtklein | c551d9f | 2014-08-20 08:09:46 -0700 | [diff] [blame] | 57 | M(DrawText) \ |
| 58 | M(DrawTextOnPath) \ |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 59 | M(DrawRRect) \ |
| 60 | M(DrawRect) \ |
| 61 | M(DrawSprite) \ |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 62 | M(DrawTextBlob) \ |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 63 | M(DrawAtlas) \ |
mtklein | f4078ad | 2014-08-08 10:05:19 -0700 | [diff] [blame] | 64 | M(DrawVertices) |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 65 | |
| 66 | // Defines SkRecords::Type, an enum of all record types. |
| 67 | #define ENUM(T) T##_Type, |
| 68 | enum Type { SK_RECORD_TYPES(ENUM) }; |
| 69 | #undef ENUM |
| 70 | |
| 71 | // Macros to make it easier to define a record for a draw call with 0 args, 1 args, 2 args, etc. |
| 72 | // These should be clearer when you look at their use below. |
| 73 | #define RECORD0(T) \ |
| 74 | struct T { \ |
| 75 | static const Type kType = T##_Type; \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 78 | // Instead of requring the exact type A here, we take any type Z which implicitly casts to A. |
| 79 | // This lets our wrappers like ImmutableBitmap work seamlessly. |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 80 | |
| 81 | #define RECORD1(T, A, a) \ |
| 82 | struct T { \ |
| 83 | static const Type kType = T##_Type; \ |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 84 | T() {} \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 85 | template <typename Z> \ |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 86 | T(const Z& a) : a(a) {} \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 87 | A a; \ |
| 88 | }; |
| 89 | |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 90 | #define RECORD2(T, A, a, B, b) \ |
| 91 | struct T { \ |
| 92 | static const Type kType = T##_Type; \ |
| 93 | T() {} \ |
| 94 | template <typename Z, typename Y> \ |
| 95 | T(const Z& a, const Y& b) : a(a), b(b) {} \ |
| 96 | A a; B b; \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 99 | #define RECORD3(T, A, a, B, b, C, c) \ |
| 100 | struct T { \ |
| 101 | static const Type kType = T##_Type; \ |
| 102 | T() {} \ |
| 103 | template <typename Z, typename Y, typename X> \ |
| 104 | T(const Z& a, const Y& b, const X& c) : a(a), b(b), c(c) {} \ |
| 105 | A a; B b; C c; \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 108 | #define RECORD4(T, A, a, B, b, C, c, D, d) \ |
| 109 | struct T { \ |
| 110 | static const Type kType = T##_Type; \ |
| 111 | T() {} \ |
| 112 | template <typename Z, typename Y, typename X, typename W> \ |
| 113 | T(const Z& a, const Y& b, const X& c, const W& d) : a(a), b(b), c(c), d(d) {} \ |
| 114 | A a; B b; C c; D d; \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | #define RECORD5(T, A, a, B, b, C, c, D, d, E, e) \ |
| 118 | struct T { \ |
| 119 | static const Type kType = T##_Type; \ |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 120 | T() {} \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 121 | template <typename Z, typename Y, typename X, typename W, typename V> \ |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 122 | T(const Z& a, const Y& b, const X& c, const W& d, const V& e) \ |
| 123 | : a(a), b(b), c(c), d(d), e(e) {} \ |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 124 | A a; B b; C c; D d; E e; \ |
| 125 | }; |
| 126 | |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 127 | #define RECORD8(T, A, a, B, b, C, c, D, d, E, e, F, f, G, g, H, h) \ |
| 128 | struct T { \ |
| 129 | static const Type kType = T##_Type; \ |
| 130 | T() {} \ |
| 131 | template <typename Z, typename Y, typename X, typename W, \ |
| 132 | typename V, typename U, typename S, typename R> \ |
| 133 | T(const Z& a, const Y& b, const X& c, const W& d, \ |
| 134 | const V& e, const U& f, const S& g, const R& h) \ |
| 135 | : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {} \ |
| 136 | A a; B b; C c; D d; E e; F f; G g; H h; \ |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 137 | }; |
mtklein | c845fa0 | 2015-06-30 09:49:49 -0700 | [diff] [blame^] | 138 | |
mtklein | 9b222a5 | 2014-09-18 11:16:31 -0700 | [diff] [blame] | 139 | #define ACT_AS_PTR(ptr) \ |
| 140 | operator T*() const { return ptr; } \ |
| 141 | T* operator->() const { return ptr; } |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 142 | |
mtklein | 53fecfb | 2014-08-21 09:11:37 -0700 | [diff] [blame] | 143 | template <typename T> |
| 144 | class RefBox : SkNoncopyable { |
| 145 | public: |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 146 | RefBox() {} |
mtklein | 9b222a5 | 2014-09-18 11:16:31 -0700 | [diff] [blame] | 147 | RefBox(T* obj) : fObj(SkSafeRef(obj)) {} |
| 148 | ~RefBox() { SkSafeUnref(fObj); } |
mtklein | 53fecfb | 2014-08-21 09:11:37 -0700 | [diff] [blame] | 149 | |
| 150 | ACT_AS_PTR(fObj); |
| 151 | |
| 152 | private: |
| 153 | T* fObj; |
| 154 | }; |
| 155 | |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 156 | // An Optional doesn't own the pointer's memory, but may need to destroy non-POD data. |
| 157 | template <typename T> |
| 158 | class Optional : SkNoncopyable { |
| 159 | public: |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 160 | Optional() : fPtr(nullptr) {} |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 161 | Optional(T* ptr) : fPtr(ptr) {} |
| 162 | ~Optional() { if (fPtr) fPtr->~T(); } |
| 163 | |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 164 | ACT_AS_PTR(fPtr); |
| 165 | private: |
| 166 | T* fPtr; |
| 167 | }; |
| 168 | |
| 169 | // Like Optional, but ptr must not be NULL. |
| 170 | template <typename T> |
| 171 | class Adopted : SkNoncopyable { |
| 172 | public: |
| 173 | Adopted(T* ptr) : fPtr(ptr) { SkASSERT(fPtr); } |
commit-bot@chromium.org | f0ae5e4 | 2014-04-24 15:33:48 +0000 | [diff] [blame] | 174 | Adopted(Adopted* source) { |
| 175 | // Transfer ownership from source to this. |
| 176 | fPtr = source->fPtr; |
| 177 | source->fPtr = NULL; |
| 178 | } |
| 179 | ~Adopted() { if (fPtr) fPtr->~T(); } |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 180 | |
| 181 | ACT_AS_PTR(fPtr); |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 182 | private: |
| 183 | T* fPtr; |
| 184 | }; |
| 185 | |
| 186 | // PODArray doesn't own the pointer's memory, and we assume the data is POD. |
| 187 | template <typename T> |
commit-bot@chromium.org | f0ae5e4 | 2014-04-24 15:33:48 +0000 | [diff] [blame] | 188 | class PODArray { |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 189 | public: |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 190 | PODArray() {} |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 191 | PODArray(T* ptr) : fPtr(ptr) {} |
commit-bot@chromium.org | f0ae5e4 | 2014-04-24 15:33:48 +0000 | [diff] [blame] | 192 | // Default copy and assign. |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 193 | |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 194 | ACT_AS_PTR(fPtr); |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 195 | private: |
| 196 | T* fPtr; |
| 197 | }; |
| 198 | |
commit-bot@chromium.org | 16307bd | 2014-04-22 18:32:58 +0000 | [diff] [blame] | 199 | #undef ACT_AS_PTR |
| 200 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 201 | // Like SkBitmap, but deep copies pixels if they're not immutable. |
| 202 | // Using this, we guarantee the immutability of all bitmaps we record. |
mtklein | f55c314 | 2014-12-11 12:43:04 -0800 | [diff] [blame] | 203 | class ImmutableBitmap : SkNoncopyable { |
| 204 | public: |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 205 | ImmutableBitmap() {} |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 206 | explicit ImmutableBitmap(const SkBitmap& bitmap) { |
| 207 | if (bitmap.isImmutable()) { |
mtklein | f55c314 | 2014-12-11 12:43:04 -0800 | [diff] [blame] | 208 | fBitmap = bitmap; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 209 | } else { |
mtklein | f55c314 | 2014-12-11 12:43:04 -0800 | [diff] [blame] | 210 | bitmap.copyTo(&fBitmap); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 211 | } |
mtklein | f55c314 | 2014-12-11 12:43:04 -0800 | [diff] [blame] | 212 | fBitmap.setImmutable(); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 213 | } |
mtklein | f55c314 | 2014-12-11 12:43:04 -0800 | [diff] [blame] | 214 | |
| 215 | int width() const { return fBitmap.width(); } |
| 216 | int height() const { return fBitmap.height(); } |
| 217 | |
| 218 | // While the pixels are immutable, SkBitmap itself is not thread-safe, so return a copy. |
| 219 | SkBitmap shallowCopy() const { return fBitmap; } |
| 220 | private: |
| 221 | SkBitmap fBitmap; |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 222 | }; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 223 | |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 224 | // SkPath::getBounds() isn't thread safe unless we precache the bounds in a singlethreaded context. |
mtklein | 14ed0fd | 2015-01-20 13:47:19 -0800 | [diff] [blame] | 225 | // SkPath::cheapComputeDirection() is similar. |
| 226 | // Recording is a convenient time to cache these, or we can delay it to between record and playback. |
| 227 | struct PreCachedPath : public SkPath { |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 228 | PreCachedPath() {} |
mtklein | 14ed0fd | 2015-01-20 13:47:19 -0800 | [diff] [blame] | 229 | explicit PreCachedPath(const SkPath& path) : SkPath(path) { |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 230 | this->updateBoundsCache(); |
mtklein | 256cc89 | 2015-06-15 12:27:20 -0700 | [diff] [blame] | 231 | #if 0 // Disabled to see if we ever really race on this. It costs time, chromium:496982. |
reed | 026beb5 | 2015-06-10 14:23:15 -0700 | [diff] [blame] | 232 | SkPathPriv::FirstDirection junk; |
| 233 | (void)SkPathPriv::CheapComputeFirstDirection(*this, &junk); |
mtklein | 256cc89 | 2015-06-15 12:27:20 -0700 | [diff] [blame] | 234 | #endif |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 235 | } |
| 236 | }; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 237 | |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 238 | // Like SkPath::getBounds(), SkMatrix::getType() isn't thread safe unless we precache it. |
| 239 | // This may not cover all SkMatrices used by the picture (e.g. some could be hiding in a shader). |
| 240 | struct TypedMatrix : public SkMatrix { |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 241 | TypedMatrix() {} |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 242 | explicit TypedMatrix(const SkMatrix& matrix) : SkMatrix(matrix) { |
| 243 | (void)this->getType(); |
| 244 | } |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 245 | }; |
| 246 | |
commit-bot@chromium.org | 88c3e27 | 2014-04-22 16:57:20 +0000 | [diff] [blame] | 247 | RECORD0(NoOp); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 248 | |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 249 | RECORD2(Restore, SkIRect, devBounds, TypedMatrix, matrix); |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 250 | RECORD0(Save); |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 251 | RECORD3(SaveLayer, Optional<SkRect>, bounds, Optional<SkPaint>, paint, SkCanvas::SaveFlags, flags); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 252 | |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 253 | RECORD1(SetMatrix, TypedMatrix, matrix); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 254 | |
mtklein | cdeeb09 | 2014-11-20 09:14:28 -0800 | [diff] [blame] | 255 | struct RegionOpAndAA { |
mtklein | 9db912c | 2015-05-19 11:11:26 -0700 | [diff] [blame] | 256 | RegionOpAndAA() {} |
mtklein | cdeeb09 | 2014-11-20 09:14:28 -0800 | [diff] [blame] | 257 | RegionOpAndAA(SkRegion::Op op, bool aa) : op(op), aa(aa) {} |
| 258 | SkRegion::Op op : 31; // This really only needs to be 3, but there's no win today to do so. |
| 259 | unsigned aa : 1; // MSVC won't pack an enum with an bool, so we call this an unsigned. |
| 260 | }; |
| 261 | SK_COMPILE_ASSERT(sizeof(RegionOpAndAA) == 4, RegionOpAndAASize); |
| 262 | |
mtklein | 14ed0fd | 2015-01-20 13:47:19 -0800 | [diff] [blame] | 263 | RECORD3(ClipPath, SkIRect, devBounds, PreCachedPath, path, RegionOpAndAA, opAA); |
| 264 | RECORD3(ClipRRect, SkIRect, devBounds, SkRRect, rrect, RegionOpAndAA, opAA); |
| 265 | RECORD3(ClipRect, SkIRect, devBounds, SkRect, rect, RegionOpAndAA, opAA); |
| 266 | RECORD3(ClipRegion, SkIRect, devBounds, SkRegion, region, SkRegion::Op, op); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 267 | |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 268 | // While not strictly required, if you have an SkPaint, it's fastest to put it first. |
| 269 | RECORD4(DrawBitmap, Optional<SkPaint>, paint, |
| 270 | ImmutableBitmap, bitmap, |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 271 | SkScalar, left, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 272 | SkScalar, top); |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 273 | RECORD4(DrawBitmapNine, Optional<SkPaint>, paint, |
| 274 | ImmutableBitmap, bitmap, |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 275 | SkIRect, center, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 276 | SkRect, dst); |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 277 | RECORD4(DrawBitmapRectToRect, Optional<SkPaint>, paint, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 278 | ImmutableBitmap, bitmap, |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 279 | Optional<SkRect>, src, |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 280 | SkRect, dst); |
| 281 | RECORD4(DrawBitmapRectToRectBleed, Optional<SkPaint>, paint, |
| 282 | ImmutableBitmap, bitmap, |
| 283 | Optional<SkRect>, src, |
| 284 | SkRect, dst); |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 285 | RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner); |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 286 | RECORD2(DrawDrawable, SkRect, worstCaseBounds, int32_t, index); |
piotaixr | 6515175 | 2014-10-16 11:58:39 -0700 | [diff] [blame] | 287 | RECORD4(DrawImage, Optional<SkPaint>, paint, |
| 288 | RefBox<const SkImage>, image, |
| 289 | SkScalar, left, |
| 290 | SkScalar, top); |
| 291 | RECORD4(DrawImageRect, Optional<SkPaint>, paint, |
| 292 | RefBox<const SkImage>, image, |
| 293 | Optional<SkRect>, src, |
| 294 | SkRect, dst); |
reed | 4c21dc5 | 2015-06-25 12:32:03 -0700 | [diff] [blame] | 295 | RECORD4(DrawImageNine, Optional<SkPaint>, paint, |
| 296 | RefBox<const SkImage>, image, |
| 297 | SkIRect, center, |
| 298 | SkRect, dst); |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 299 | RECORD2(DrawOval, SkPaint, paint, SkRect, oval); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 300 | RECORD1(DrawPaint, SkPaint, paint); |
mtklein | 14ed0fd | 2015-01-20 13:47:19 -0800 | [diff] [blame] | 301 | RECORD2(DrawPath, SkPaint, paint, PreCachedPath, path); |
mtklein | 53fecfb | 2014-08-21 09:11:37 -0700 | [diff] [blame] | 302 | RECORD3(DrawPicture, Optional<SkPaint>, paint, |
| 303 | RefBox<const SkPicture>, picture, |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 304 | TypedMatrix, matrix); |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 305 | RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, unsigned, count, SkPoint*, pts); |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 306 | RECORD4(DrawPosText, SkPaint, paint, |
| 307 | PODArray<char>, text, |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 308 | size_t, byteLength, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 309 | PODArray<SkPoint>, pos); |
| 310 | RECORD5(DrawPosTextH, SkPaint, paint, |
| 311 | PODArray<char>, text, |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 312 | unsigned, byteLength, |
| 313 | SkScalar, y, |
| 314 | PODArray<SkScalar>, xpos); |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 315 | RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect); |
| 316 | RECORD2(DrawRect, SkPaint, paint, SkRect, rect); |
| 317 | RECORD4(DrawSprite, Optional<SkPaint>, paint, ImmutableBitmap, bitmap, int, left, int, top); |
| 318 | RECORD5(DrawText, SkPaint, paint, |
| 319 | PODArray<char>, text, |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 320 | size_t, byteLength, |
| 321 | SkScalar, x, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 322 | SkScalar, y); |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 323 | RECORD4(DrawTextBlob, SkPaint, paint, |
mtklein | 53fecfb | 2014-08-21 09:11:37 -0700 | [diff] [blame] | 324 | RefBox<const SkTextBlob>, blob, |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 325 | SkScalar, x, |
| 326 | SkScalar, y); |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 327 | RECORD5(DrawTextOnPath, SkPaint, paint, |
| 328 | PODArray<char>, text, |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 329 | size_t, byteLength, |
mtklein | 14ed0fd | 2015-01-20 13:47:19 -0800 | [diff] [blame] | 330 | PreCachedPath, path, |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 331 | TypedMatrix, matrix); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 332 | |
mtklein | 9b222a5 | 2014-09-18 11:16:31 -0700 | [diff] [blame] | 333 | RECORD5(DrawPatch, SkPaint, paint, |
| 334 | PODArray<SkPoint>, cubics, |
| 335 | PODArray<SkColor>, colors, |
| 336 | PODArray<SkPoint>, texCoords, |
| 337 | RefBox<SkXfermode>, xmode); |
| 338 | |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 339 | RECORD8(DrawAtlas, Optional<SkPaint>, paint, |
| 340 | RefBox<const SkImage>, atlas, |
| 341 | PODArray<SkRSXform>, xforms, |
| 342 | PODArray<SkRect>, texs, |
| 343 | PODArray<SkColor>, colors, |
| 344 | int, count, |
| 345 | SkXfermode::Mode, mode, |
| 346 | Optional<SkRect>, cull); |
| 347 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 348 | // This guy is so ugly we just write it manually. |
| 349 | struct DrawVertices { |
| 350 | static const Type kType = DrawVertices_Type; |
| 351 | |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 352 | DrawVertices(const SkPaint& paint, |
| 353 | SkCanvas::VertexMode vmode, |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 354 | int vertexCount, |
| 355 | SkPoint* vertices, |
| 356 | SkPoint* texs, |
| 357 | SkColor* colors, |
| 358 | SkXfermode* xmode, |
| 359 | uint16_t* indices, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 360 | int indexCount) |
| 361 | : paint(paint) |
| 362 | , vmode(vmode) |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 363 | , vertexCount(vertexCount) |
| 364 | , vertices(vertices) |
| 365 | , texs(texs) |
| 366 | , colors(colors) |
| 367 | , xmode(SkSafeRef(xmode)) |
| 368 | , indices(indices) |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 369 | , indexCount(indexCount) {} |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 370 | |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 371 | SkPaint paint; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 372 | SkCanvas::VertexMode vmode; |
| 373 | int vertexCount; |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 374 | PODArray<SkPoint> vertices; |
| 375 | PODArray<SkPoint> texs; |
| 376 | PODArray<SkColor> colors; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 377 | SkAutoTUnref<SkXfermode> xmode; |
commit-bot@chromium.org | 653d518 | 2014-04-15 14:27:14 +0000 | [diff] [blame] | 378 | PODArray<uint16_t> indices; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 379 | int indexCount; |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 380 | }; |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 381 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 382 | #undef RECORD0 |
| 383 | #undef RECORD1 |
| 384 | #undef RECORD2 |
| 385 | #undef RECORD3 |
| 386 | #undef RECORD4 |
| 387 | #undef RECORD5 |
reed | 71c3c76 | 2015-06-24 10:29:17 -0700 | [diff] [blame] | 388 | #undef RECORD8 |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 389 | |
| 390 | } // namespace SkRecords |
| 391 | |
| 392 | #endif//SkRecords_DEFINED |