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