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