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 | #include "SkRecorder.h" |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 9 | #include "SkPatchUtils.h" |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 10 | #include "SkPicture.h" |
| 11 | |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame^] | 12 | SkDrawableList::~SkDrawableList() { |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 13 | fArray.unrefAll(); |
| 14 | } |
| 15 | |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame^] | 16 | SkPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() { |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 17 | const int count = fArray.count(); |
| 18 | if (0 == count) { |
| 19 | return NULL; |
| 20 | } |
| 21 | SkAutoTMalloc<const SkPicture*> pics(count); |
| 22 | for (int i = 0; i < count; ++i) { |
| 23 | pics[i] = fArray[i]->newPictureSnapshot(); |
| 24 | } |
| 25 | return SkNEW_ARGS(SkPicture::SnapshotArray, (pics.detach(), count)); |
| 26 | } |
| 27 | |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame^] | 28 | void SkDrawableList::append(SkDrawable* drawable) { |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 29 | *fArray.append() = SkRef(drawable); |
| 30 | } |
| 31 | |
| 32 | /////////////////////////////////////////////////////////////////////////////////////////////// |
| 33 | |
commit-bot@chromium.org | a095041 | 2014-05-29 16:52:40 +0000 | [diff] [blame] | 34 | SkRecorder::SkRecorder(SkRecord* record, int width, int height) |
reed | 78e2768 | 2014-11-19 08:04:34 -0800 | [diff] [blame] | 35 | : SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag) |
junov | 3fcc125 | 2014-12-15 11:34:06 -0800 | [diff] [blame] | 36 | , fRecord(record) {} |
reed | 78e2768 | 2014-11-19 08:04:34 -0800 | [diff] [blame] | 37 | |
| 38 | SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds) |
| 39 | : SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag) |
junov | 3fcc125 | 2014-12-15 11:34:06 -0800 | [diff] [blame] | 40 | , fRecord(record) {} |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 41 | |
commit-bot@chromium.org | 732bd66 | 2014-04-24 15:22:55 +0000 | [diff] [blame] | 42 | void SkRecorder::forgetRecord() { |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 43 | fDrawableList.reset(NULL); |
commit-bot@chromium.org | 732bd66 | 2014-04-24 15:22:55 +0000 | [diff] [blame] | 44 | fRecord = NULL; |
| 45 | } |
| 46 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 47 | // To make appending to fRecord a little less verbose. |
| 48 | #define APPEND(T, ...) \ |
| 49 | SkNEW_PLACEMENT_ARGS(fRecord->append<SkRecords::T>(), SkRecords::T, (__VA_ARGS__)) |
| 50 | |
commit-bot@chromium.org | a095041 | 2014-05-29 16:52:40 +0000 | [diff] [blame] | 51 | // For methods which must call back into SkCanvas. |
| 52 | #define INHERITED(method, ...) this->SkCanvas::method(__VA_ARGS__) |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 53 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 54 | // The structs we're creating all copy their constructor arguments. Given the way the SkRecords |
| 55 | // framework works, sometimes they happen to technically be copied twice, which is fine and elided |
| 56 | // into a single copy unless the class has a non-trivial copy constructor. For classes with |
| 57 | // non-trivial copy constructors, we skip the first copy (and its destruction) by wrapping the value |
| 58 | // with delay_copy(), forcing the argument to be passed by const&. |
| 59 | // |
| 60 | // This is used below for SkBitmap, SkPaint, SkPath, and SkRegion, which all have non-trivial copy |
| 61 | // constructors and destructors. You'll know you've got a good candidate T if you see ~T() show up |
| 62 | // unexpectedly on a profile of record time. Otherwise don't bother. |
| 63 | template <typename T> |
| 64 | class Reference { |
| 65 | public: |
| 66 | Reference(const T& x) : fX(x) {} |
| 67 | operator const T&() const { return fX; } |
| 68 | private: |
| 69 | const T& fX; |
| 70 | }; |
| 71 | |
| 72 | template <typename T> |
| 73 | static Reference<T> delay_copy(const T& x) { return Reference<T>(x); } |
| 74 | |
| 75 | // Use copy() only for optional arguments, to be copied if present or skipped if not. |
| 76 | // (For most types we just pass by value and let copy constructors do their thing.) |
| 77 | template <typename T> |
| 78 | T* SkRecorder::copy(const T* src) { |
| 79 | if (NULL == src) { |
| 80 | return NULL; |
| 81 | } |
| 82 | return SkNEW_PLACEMENT_ARGS(fRecord->alloc<T>(), T, (*src)); |
| 83 | } |
| 84 | |
| 85 | // This copy() is for arrays. |
| 86 | // It will work with POD or non-POD, though currently we only use it for POD. |
| 87 | template <typename T> |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 88 | T* SkRecorder::copy(const T src[], size_t count) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 89 | if (NULL == src) { |
| 90 | return NULL; |
| 91 | } |
| 92 | T* dst = fRecord->alloc<T>(count); |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 93 | for (size_t i = 0; i < count; i++) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 94 | SkNEW_PLACEMENT_ARGS(dst + i, T, (src[i])); |
| 95 | } |
| 96 | return dst; |
| 97 | } |
| 98 | |
| 99 | // Specialization for copying strings, using memcpy. |
| 100 | // This measured around 2x faster for copying code points, |
| 101 | // but I found no corresponding speedup for other arrays. |
| 102 | template <> |
reed | 2347b62 | 2014-08-07 12:19:50 -0700 | [diff] [blame] | 103 | char* SkRecorder::copy(const char src[], size_t count) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 104 | if (NULL == src) { |
| 105 | return NULL; |
| 106 | } |
| 107 | char* dst = fRecord->alloc<char>(count); |
| 108 | memcpy(dst, src, count); |
| 109 | return dst; |
| 110 | } |
| 111 | |
mtklein | 5f0e822 | 2014-08-22 11:44:26 -0700 | [diff] [blame] | 112 | // As above, assuming and copying a terminating \0. |
| 113 | template <> |
| 114 | char* SkRecorder::copy(const char* src) { |
| 115 | return this->copy(src, strlen(src)+1); |
| 116 | } |
| 117 | |
| 118 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 119 | void SkRecorder::onDrawPaint(const SkPaint& paint) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 120 | APPEND(DrawPaint, delay_copy(paint)); |
| 121 | } |
| 122 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 123 | void SkRecorder::onDrawPoints(PointMode mode, |
| 124 | size_t count, |
| 125 | const SkPoint pts[], |
| 126 | const SkPaint& paint) { |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 127 | APPEND(DrawPoints, delay_copy(paint), mode, SkToUInt(count), this->copy(pts, count)); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 128 | } |
| 129 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 130 | void SkRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 131 | APPEND(DrawRect, delay_copy(paint), rect); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 132 | } |
| 133 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 134 | void SkRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 135 | APPEND(DrawOval, delay_copy(paint), oval); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 136 | } |
| 137 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 138 | void SkRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 139 | APPEND(DrawRRect, delay_copy(paint), rrect); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 140 | } |
| 141 | |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 142 | void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 143 | APPEND(DrawDRRect, delay_copy(paint), outer, inner); |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 144 | } |
| 145 | |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame^] | 146 | void SkRecorder::onDrawDrawable(SkDrawable* drawable) { |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 147 | if (!fDrawableList) { |
reed | 3cb3840 | 2015-02-06 08:36:15 -0800 | [diff] [blame^] | 148 | fDrawableList.reset(SkNEW(SkDrawableList)); |
reed | 1bdfd3f | 2014-11-24 14:41:51 -0800 | [diff] [blame] | 149 | } |
| 150 | fDrawableList->append(drawable); |
| 151 | APPEND(DrawDrawable, drawable->getBounds(), fDrawableList->count() - 1); |
reed | 6be2aa9 | 2014-11-18 11:08:05 -0800 | [diff] [blame] | 152 | } |
| 153 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 154 | void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) { |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 155 | APPEND(DrawPath, delay_copy(paint), delay_copy(path)); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 156 | } |
| 157 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 158 | void SkRecorder::onDrawBitmap(const SkBitmap& bitmap, |
| 159 | SkScalar left, |
| 160 | SkScalar top, |
| 161 | const SkPaint* paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 162 | APPEND(DrawBitmap, this->copy(paint), delay_copy(bitmap), left, top); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 163 | } |
| 164 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 165 | void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap, |
| 166 | const SkRect* src, |
| 167 | const SkRect& dst, |
| 168 | const SkPaint* paint, |
| 169 | DrawBitmapRectFlags flags) { |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 170 | if (kBleed_DrawBitmapRectFlag == flags) { |
| 171 | APPEND(DrawBitmapRectToRectBleed, |
| 172 | this->copy(paint), delay_copy(bitmap), this->copy(src), dst); |
| 173 | return; |
| 174 | } |
| 175 | SkASSERT(kNone_DrawBitmapRectFlag == flags); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 176 | APPEND(DrawBitmapRectToRect, |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 177 | this->copy(paint), delay_copy(bitmap), this->copy(src), dst); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 178 | } |
| 179 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 180 | void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap, |
| 181 | const SkIRect& center, |
| 182 | const SkRect& dst, |
| 183 | const SkPaint* paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 184 | APPEND(DrawBitmapNine, this->copy(paint), delay_copy(bitmap), center, dst); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 185 | } |
| 186 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 187 | void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top, |
| 188 | const SkPaint* paint) { |
piotaixr | 6515175 | 2014-10-16 11:58:39 -0700 | [diff] [blame] | 189 | APPEND(DrawImage, this->copy(paint), image, left, top); |
| 190 | } |
| 191 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 192 | void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, |
| 193 | const SkRect& dst, |
| 194 | const SkPaint* paint) { |
piotaixr | 6515175 | 2014-10-16 11:58:39 -0700 | [diff] [blame] | 195 | APPEND(DrawImageRect, this->copy(paint), image, this->copy(src), dst); |
| 196 | } |
| 197 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 198 | void SkRecorder::onDrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 199 | APPEND(DrawSprite, this->copy(paint), delay_copy(bitmap), left, top); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 200 | } |
| 201 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 202 | void SkRecorder::onDrawText(const void* text, size_t byteLength, |
| 203 | SkScalar x, SkScalar y, const SkPaint& paint) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 204 | APPEND(DrawText, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 205 | delay_copy(paint), this->copy((const char*)text, byteLength), byteLength, x, y); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 206 | } |
| 207 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 208 | void SkRecorder::onDrawPosText(const void* text, size_t byteLength, |
| 209 | const SkPoint pos[], const SkPaint& paint) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 210 | const unsigned points = paint.countText(text, byteLength); |
| 211 | APPEND(DrawPosText, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 212 | delay_copy(paint), |
| 213 | this->copy((const char*)text, byteLength), |
| 214 | byteLength, |
| 215 | this->copy(pos, points)); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 216 | } |
| 217 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 218 | void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength, |
| 219 | const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 220 | const unsigned points = paint.countText(text, byteLength); |
| 221 | APPEND(DrawPosTextH, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 222 | delay_copy(paint), |
| 223 | this->copy((const char*)text, byteLength), |
mtklein | 42ddcd4 | 2014-11-21 08:48:35 -0800 | [diff] [blame] | 224 | SkToUInt(byteLength), |
| 225 | constY, |
| 226 | this->copy(xpos, points)); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 227 | } |
| 228 | |
reed@google.com | e0d9ce8 | 2014-04-23 04:00:17 +0000 | [diff] [blame] | 229 | void SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
| 230 | const SkMatrix* matrix, const SkPaint& paint) { |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 231 | APPEND(DrawTextOnPath, |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 232 | delay_copy(paint), |
| 233 | this->copy((const char*)text, byteLength), |
| 234 | byteLength, |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 235 | delay_copy(path), |
| 236 | matrix ? *matrix : SkMatrix::I()); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 237 | } |
| 238 | |
fmalita | 00d5c2c | 2014-08-21 08:53:26 -0700 | [diff] [blame] | 239 | void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
| 240 | const SkPaint& paint) { |
| 241 | APPEND(DrawTextBlob, delay_copy(paint), blob, x, y); |
| 242 | } |
| 243 | |
reed | d5fa1a4 | 2014-08-09 11:08:05 -0700 | [diff] [blame] | 244 | void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) { |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 245 | APPEND(DrawPicture, this->copy(paint), pic, matrix ? *matrix : SkMatrix::I()); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 246 | } |
| 247 | |
reed | 41af966 | 2015-01-05 07:49:08 -0800 | [diff] [blame] | 248 | void SkRecorder::onDrawVertices(VertexMode vmode, |
| 249 | int vertexCount, const SkPoint vertices[], |
| 250 | const SkPoint texs[], const SkColor colors[], |
| 251 | SkXfermode* xmode, |
| 252 | const uint16_t indices[], int indexCount, const SkPaint& paint) { |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 253 | APPEND(DrawVertices, delay_copy(paint), |
| 254 | vmode, |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 255 | vertexCount, |
| 256 | this->copy(vertices, vertexCount), |
| 257 | texs ? this->copy(texs, vertexCount) : NULL, |
| 258 | colors ? this->copy(colors, vertexCount) : NULL, |
| 259 | xmode, |
| 260 | this->copy(indices, indexCount), |
commit-bot@chromium.org | 37f6e62 | 2014-05-07 22:59:38 +0000 | [diff] [blame] | 261 | indexCount); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 262 | } |
| 263 | |
dandov | b3c9d1c | 2014-08-12 08:34:29 -0700 | [diff] [blame] | 264 | void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], |
| 265 | const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) { |
| 266 | APPEND(DrawPatch, delay_copy(paint), |
| 267 | cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : NULL, |
| 268 | colors ? this->copy(colors, SkPatchUtils::kNumCorners) : NULL, |
| 269 | texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : NULL, |
| 270 | xmode); |
dandov | 963137b | 2014-08-07 07:49:53 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Florin Malita | 5f6102d | 2014-06-30 10:13:28 -0400 | [diff] [blame] | 273 | void SkRecorder::willSave() { |
| 274 | APPEND(Save); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | SkCanvas::SaveLayerStrategy SkRecorder::willSaveLayer(const SkRect* bounds, |
| 278 | const SkPaint* paint, |
| 279 | SkCanvas::SaveFlags flags) { |
| 280 | APPEND(SaveLayer, this->copy(bounds), this->copy(paint), flags); |
| 281 | return SkCanvas::kNoLayer_SaveLayerStrategy; |
| 282 | } |
| 283 | |
mtklein | 6cfa73a | 2014-08-13 13:33:49 -0700 | [diff] [blame] | 284 | void SkRecorder::didRestore() { |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 285 | APPEND(Restore, this->devBounds(), this->getTotalMatrix()); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 286 | } |
| 287 | |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 288 | void SkRecorder::didConcat(const SkMatrix& matrix) { |
mtklein | 6332f1d | 2014-08-19 07:09:40 -0700 | [diff] [blame] | 289 | this->didSetMatrix(this->getTotalMatrix()); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | void SkRecorder::didSetMatrix(const SkMatrix& matrix) { |
mtklein | 46bc621 | 2014-08-20 09:44:28 -0700 | [diff] [blame] | 293 | SkDEVCODE(if (matrix != this->getTotalMatrix()) { |
mtklein | ec924b9 | 2014-08-20 09:22:28 -0700 | [diff] [blame] | 294 | matrix.dump(); |
| 295 | this->getTotalMatrix().dump(); |
| 296 | SkASSERT(matrix == this->getTotalMatrix()); |
| 297 | }) |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 298 | APPEND(SetMatrix, matrix); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | void SkRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 302 | INHERITED(onClipRect, rect, op, edgeStyle); |
mtklein | cdeeb09 | 2014-11-20 09:14:28 -0800 | [diff] [blame] | 303 | SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); |
| 304 | APPEND(ClipRect, this->devBounds(), rect, opAA); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | void SkRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
reed | d954498 | 2014-09-09 18:46:22 -0700 | [diff] [blame] | 308 | INHERITED(onClipRRect, rrect, op, edgeStyle); |
mtklein | cdeeb09 | 2014-11-20 09:14:28 -0800 | [diff] [blame] | 309 | SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); |
| 310 | APPEND(ClipRRect, this->devBounds(), rrect, opAA); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | void SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
reed | d954498 | 2014-09-09 18:46:22 -0700 | [diff] [blame] | 314 | INHERITED(onClipPath, path, op, edgeStyle); |
mtklein | cdeeb09 | 2014-11-20 09:14:28 -0800 | [diff] [blame] | 315 | SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle); |
mtklein | af57903 | 2014-12-01 11:03:37 -0800 | [diff] [blame] | 316 | APPEND(ClipPath, this->devBounds(), delay_copy(path), opAA); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
commit-bot@chromium.org | d9ce2be | 2014-04-09 23:30:28 +0000 | [diff] [blame] | 320 | INHERITED(onClipRegion, deviceRgn, op); |
mtklein | a723b57 | 2014-08-15 11:49:49 -0700 | [diff] [blame] | 321 | APPEND(ClipRegion, this->devBounds(), delay_copy(deviceRgn), op); |
commit-bot@chromium.org | e3ff558 | 2014-04-01 16:24:06 +0000 | [diff] [blame] | 322 | } |
mtklein | 5f0e822 | 2014-08-22 11:44:26 -0700 | [diff] [blame] | 323 | |
| 324 | void SkRecorder::beginCommentGroup(const char* description) { |
| 325 | APPEND(BeginCommentGroup, this->copy(description)); |
| 326 | } |
| 327 | |
| 328 | void SkRecorder::addComment(const char* key, const char* value) { |
| 329 | APPEND(AddComment, this->copy(key), this->copy(value)); |
| 330 | } |
| 331 | |
| 332 | void SkRecorder::endCommentGroup() { |
| 333 | APPEND(EndCommentGroup); |
| 334 | } |
mtklein | 29dfaa8 | 2014-09-04 14:12:44 -0700 | [diff] [blame] | 335 | |