blob: b961c7d1e79a0a186af157c669e3645f24805d8c [file] [log] [blame]
commit-bot@chromium.orgc4b21e62014-04-11 18:33:31 +00001/*
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
mtklein9db912c2015-05-19 11:11:26 -07008#include "SkBigPicture.h"
mtkleind711d112015-07-01 07:04:37 -07009#include "SkCanvasPriv.h"
reed9b84f8c2016-07-28 14:26:13 -070010#include "SkImage.h"
dandovb3c9d1c2014-08-12 08:34:29 -070011#include "SkPatchUtils.h"
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000012#include "SkPicture.h"
mtklein98b84852015-04-21 15:23:59 -070013#include "SkPictureUtils.h"
14#include "SkRecorder.h"
reede8f30622016-03-23 18:59:25 -070015#include "SkSurface.h"
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000016
reed3cb38402015-02-06 08:36:15 -080017SkDrawableList::~SkDrawableList() {
reed1bdfd3f2014-11-24 14:41:51 -080018 fArray.unrefAll();
19}
20
mtklein9db912c2015-05-19 11:11:26 -070021SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() {
reed1bdfd3f2014-11-24 14:41:51 -080022 const int count = fArray.count();
23 if (0 == count) {
halcanary96fcdcc2015-08-27 07:41:13 -070024 return nullptr;
reed1bdfd3f2014-11-24 14:41:51 -080025 }
26 SkAutoTMalloc<const SkPicture*> pics(count);
27 for (int i = 0; i < count; ++i) {
28 pics[i] = fArray[i]->newPictureSnapshot();
29 }
mtklein18300a32016-03-16 13:53:35 -070030 return new SkBigPicture::SnapshotArray(pics.release(), count);
reed1bdfd3f2014-11-24 14:41:51 -080031}
32
reed3cb38402015-02-06 08:36:15 -080033void SkDrawableList::append(SkDrawable* drawable) {
reed1bdfd3f2014-11-24 14:41:51 -080034 *fArray.append() = SkRef(drawable);
35}
36
37///////////////////////////////////////////////////////////////////////////////////////////////
38
mtklein9db912c2015-05-19 11:11:26 -070039SkRecorder::SkRecorder(SkRecord* record, int width, int height, SkMiniRecorder* mr)
reed78e27682014-11-19 08:04:34 -080040 : SkCanvas(SkIRect::MakeWH(width, height), SkCanvas::kConservativeRasterClip_InitFlag)
mtkleind711d112015-07-01 07:04:37 -070041 , fDrawPictureMode(Record_DrawPictureMode)
mtklein98b84852015-04-21 15:23:59 -070042 , fApproxBytesUsedBySubPictures(0)
mtklein9db912c2015-05-19 11:11:26 -070043 , fRecord(record)
44 , fMiniRecorder(mr) {}
reed78e27682014-11-19 08:04:34 -080045
mtklein9db912c2015-05-19 11:11:26 -070046SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds, SkMiniRecorder* mr)
reed78e27682014-11-19 08:04:34 -080047 : SkCanvas(bounds.roundOut(), SkCanvas::kConservativeRasterClip_InitFlag)
mtkleind711d112015-07-01 07:04:37 -070048 , fDrawPictureMode(Record_DrawPictureMode)
mtklein98b84852015-04-21 15:23:59 -070049 , fApproxBytesUsedBySubPictures(0)
mtklein9db912c2015-05-19 11:11:26 -070050 , fRecord(record)
51 , fMiniRecorder(mr) {}
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000052
mtkleind711d112015-07-01 07:04:37 -070053void SkRecorder::reset(SkRecord* record, const SkRect& bounds,
54 DrawPictureMode dpm, SkMiniRecorder* mr) {
mtkleinfeaadee2015-04-08 11:25:48 -070055 this->forgetRecord();
mtkleind711d112015-07-01 07:04:37 -070056 fDrawPictureMode = dpm;
mtkleinfeaadee2015-04-08 11:25:48 -070057 fRecord = record;
58 this->resetForNextPicture(bounds.roundOut());
mtklein9db912c2015-05-19 11:11:26 -070059 fMiniRecorder = mr;
mtkleinfeaadee2015-04-08 11:25:48 -070060}
61
commit-bot@chromium.org732bd662014-04-24 15:22:55 +000062void SkRecorder::forgetRecord() {
halcanary96fcdcc2015-08-27 07:41:13 -070063 fDrawableList.reset(nullptr);
mtklein98b84852015-04-21 15:23:59 -070064 fApproxBytesUsedBySubPictures = 0;
halcanary96fcdcc2015-08-27 07:41:13 -070065 fRecord = nullptr;
commit-bot@chromium.org732bd662014-04-24 15:22:55 +000066}
67
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000068// To make appending to fRecord a little less verbose.
halcanary385fe4d2015-08-26 13:07:48 -070069#define APPEND(T, ...) \
70 if (fMiniRecorder) { \
71 this->flushMiniRecorder(); \
72 } \
mtklein449d9b72015-09-28 10:33:02 -070073 new (fRecord->append<SkRecords::T>()) SkRecords::T{__VA_ARGS__}
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000074
mtklein9db912c2015-05-19 11:11:26 -070075#define TRY_MINIRECORDER(method, ...) \
76 if (fMiniRecorder && fMiniRecorder->method(__VA_ARGS__)) { return; }
77
commit-bot@chromium.orga0950412014-05-29 16:52:40 +000078// For methods which must call back into SkCanvas.
79#define INHERITED(method, ...) this->SkCanvas::method(__VA_ARGS__)
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +000080
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000081// Use copy() only for optional arguments, to be copied if present or skipped if not.
82// (For most types we just pass by value and let copy constructors do their thing.)
83template <typename T>
84T* SkRecorder::copy(const T* src) {
halcanary96fcdcc2015-08-27 07:41:13 -070085 if (nullptr == src) {
86 return nullptr;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000087 }
halcanary385fe4d2015-08-26 13:07:48 -070088 return new (fRecord->alloc<T>()) T(*src);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000089}
90
91// This copy() is for arrays.
92// It will work with POD or non-POD, though currently we only use it for POD.
93template <typename T>
reed2347b622014-08-07 12:19:50 -070094T* SkRecorder::copy(const T src[], size_t count) {
halcanary96fcdcc2015-08-27 07:41:13 -070095 if (nullptr == src) {
96 return nullptr;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000097 }
98 T* dst = fRecord->alloc<T>(count);
reed2347b622014-08-07 12:19:50 -070099 for (size_t i = 0; i < count; i++) {
halcanary385fe4d2015-08-26 13:07:48 -0700100 new (dst + i) T(src[i]);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000101 }
102 return dst;
103}
104
105// Specialization for copying strings, using memcpy.
106// This measured around 2x faster for copying code points,
107// but I found no corresponding speedup for other arrays.
108template <>
reed2347b622014-08-07 12:19:50 -0700109char* SkRecorder::copy(const char src[], size_t count) {
halcanary96fcdcc2015-08-27 07:41:13 -0700110 if (nullptr == src) {
111 return nullptr;
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000112 }
113 char* dst = fRecord->alloc<char>(count);
114 memcpy(dst, src, count);
115 return dst;
116}
117
mtklein5f0e8222014-08-22 11:44:26 -0700118// As above, assuming and copying a terminating \0.
119template <>
120char* SkRecorder::copy(const char* src) {
121 return this->copy(src, strlen(src)+1);
122}
123
mtklein9db912c2015-05-19 11:11:26 -0700124void SkRecorder::flushMiniRecorder() {
125 if (fMiniRecorder) {
126 SkMiniRecorder* mr = fMiniRecorder;
mtkleind41ea1d2015-05-20 10:16:49 -0700127 fMiniRecorder = nullptr; // Needs to happen before flushAndReset() or we recurse forever.
128 mr->flushAndReset(this);
mtklein9db912c2015-05-19 11:11:26 -0700129 }
130}
mtklein5f0e8222014-08-22 11:44:26 -0700131
reed41af9662015-01-05 07:49:08 -0800132void SkRecorder::onDrawPaint(const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700133 APPEND(DrawPaint, paint);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000134}
135
reed41af9662015-01-05 07:49:08 -0800136void SkRecorder::onDrawPoints(PointMode mode,
137 size_t count,
138 const SkPoint pts[],
139 const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700140 APPEND(DrawPoints, paint, mode, SkToUInt(count), this->copy(pts, count));
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000141}
142
reed41af9662015-01-05 07:49:08 -0800143void SkRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) {
mtklein9db912c2015-05-19 11:11:26 -0700144 TRY_MINIRECORDER(drawRect, rect, paint);
mtkleinc845fa02015-06-30 09:49:49 -0700145 APPEND(DrawRect, paint, rect);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000146}
147
reed41af9662015-01-05 07:49:08 -0800148void SkRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700149 APPEND(DrawOval, paint, oval);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000150}
151
reed41af9662015-01-05 07:49:08 -0800152void SkRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700153 APPEND(DrawRRect, paint, rrect);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000154}
155
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000156void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700157 APPEND(DrawDRRect, paint, outer, inner);
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000158}
159
reeda8db7282015-07-07 10:22:31 -0700160void SkRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
djsollenaa6f7392015-11-17 06:18:31 -0800161 if (fDrawPictureMode == Record_DrawPictureMode) {
162 if (!fDrawableList) {
163 fDrawableList.reset(new SkDrawableList);
164 }
165 fDrawableList->append(drawable);
166 APPEND(DrawDrawable, this->copy(matrix), drawable->getBounds(), fDrawableList->count() - 1);
167 } else {
168 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
169 drawable->draw(this, matrix);
reed1bdfd3f2014-11-24 14:41:51 -0800170 }
reed6be2aa92014-11-18 11:08:05 -0800171}
172
reed41af9662015-01-05 07:49:08 -0800173void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
mtklein9db912c2015-05-19 11:11:26 -0700174 TRY_MINIRECORDER(drawPath, path, paint);
mtkleinc845fa02015-06-30 09:49:49 -0700175 APPEND(DrawPath, paint, path);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000176}
177
reed41af9662015-01-05 07:49:08 -0800178void SkRecorder::onDrawBitmap(const SkBitmap& bitmap,
179 SkScalar left,
180 SkScalar top,
181 const SkPaint* paint) {
reed9b84f8c2016-07-28 14:26:13 -0700182 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
reed56179002015-07-07 06:11:19 -0700183 if (image) {
reed9b84f8c2016-07-28 14:26:13 -0700184 this->onDrawImage(image.get(), left, top, paint);
reed56179002015-07-07 06:11:19 -0700185 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000186}
187
reed41af9662015-01-05 07:49:08 -0800188void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap,
189 const SkRect* src,
190 const SkRect& dst,
191 const SkPaint* paint,
reed562fe472015-07-28 07:35:14 -0700192 SrcRectConstraint constraint) {
reed9b84f8c2016-07-28 14:26:13 -0700193 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
reed56179002015-07-07 06:11:19 -0700194 if (image) {
reed9b84f8c2016-07-28 14:26:13 -0700195 this->onDrawImageRect(image.get(), src, dst, paint, constraint);
reed56179002015-07-07 06:11:19 -0700196 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000197}
198
reed41af9662015-01-05 07:49:08 -0800199void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap,
200 const SkIRect& center,
201 const SkRect& dst,
202 const SkPaint* paint) {
reed9b84f8c2016-07-28 14:26:13 -0700203 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
reed56179002015-07-07 06:11:19 -0700204 if (image) {
reed9b84f8c2016-07-28 14:26:13 -0700205 this->onDrawImageNine(image.get(), center, dst, paint);
reed56179002015-07-07 06:11:19 -0700206 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000207}
208
msarett16882062016-08-16 09:31:08 -0700209void SkRecorder::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice,
210 const SkRect& dst, const SkPaint* paint) {
211 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
212 this->onDrawImageLattice(image.get(), lattice, dst, paint);
213}
214
reed41af9662015-01-05 07:49:08 -0800215void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
216 const SkPaint* paint) {
mtkleinda574d12016-08-01 11:24:03 -0700217 APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top);
piotaixr65151752014-10-16 11:58:39 -0700218}
219
reed562fe472015-07-28 07:35:14 -0700220void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
221 const SkPaint* paint, SrcRectConstraint constraint) {
mtkleinda574d12016-08-01 11:24:03 -0700222 APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint);
piotaixr65151752014-10-16 11:58:39 -0700223}
224
reed4c21dc52015-06-25 12:32:03 -0700225void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center,
226 const SkRect& dst, const SkPaint* paint) {
mtkleinda574d12016-08-01 11:24:03 -0700227 APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst);
reed4c21dc52015-06-25 12:32:03 -0700228}
229
msarett16882062016-08-16 09:31:08 -0700230void SkRecorder::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
231 const SkPaint* paint) {
232 APPEND(DrawImageLattice, this->copy(paint), sk_ref_sp(image),
233 lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
234 lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount), dst);
235}
236
reed@google.come0d9ce82014-04-23 04:00:17 +0000237void SkRecorder::onDrawText(const void* text, size_t byteLength,
238 SkScalar x, SkScalar y, const SkPaint& paint) {
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000239 APPEND(DrawText,
mtkleinc845fa02015-06-30 09:49:49 -0700240 paint, this->copy((const char*)text, byteLength), byteLength, x, y);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000241}
242
reed@google.come0d9ce82014-04-23 04:00:17 +0000243void SkRecorder::onDrawPosText(const void* text, size_t byteLength,
244 const SkPoint pos[], const SkPaint& paint) {
mtkleinc6ad06a2015-08-19 09:51:00 -0700245 const int points = paint.countText(text, byteLength);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000246 APPEND(DrawPosText,
mtkleinc845fa02015-06-30 09:49:49 -0700247 paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000248 this->copy((const char*)text, byteLength),
249 byteLength,
250 this->copy(pos, points));
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000251}
252
reed@google.come0d9ce82014-04-23 04:00:17 +0000253void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength,
254 const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
mtkleinc6ad06a2015-08-19 09:51:00 -0700255 const int points = paint.countText(text, byteLength);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000256 APPEND(DrawPosTextH,
mtkleinc845fa02015-06-30 09:49:49 -0700257 paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000258 this->copy((const char*)text, byteLength),
mtklein42ddcd42014-11-21 08:48:35 -0800259 SkToUInt(byteLength),
260 constY,
261 this->copy(xpos, points));
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000262}
263
reed@google.come0d9ce82014-04-23 04:00:17 +0000264void SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
265 const SkMatrix* matrix, const SkPaint& paint) {
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000266 APPEND(DrawTextOnPath,
mtkleinc845fa02015-06-30 09:49:49 -0700267 paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000268 this->copy((const char*)text, byteLength),
269 byteLength,
mtkleinc845fa02015-06-30 09:49:49 -0700270 path,
mtkleinaf579032014-12-01 11:03:37 -0800271 matrix ? *matrix : SkMatrix::I());
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000272}
273
reed45561a02016-07-07 12:47:17 -0700274void SkRecorder::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
275 const SkRect* cull, const SkPaint& paint) {
276 APPEND(DrawTextRSXform,
277 paint,
278 this->copy((const char*)text, byteLength),
279 byteLength,
280 this->copy(xform, paint.countText(text, byteLength)),
281 this->copy(cull));
282}
283
fmalita00d5c2c2014-08-21 08:53:26 -0700284void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
285 const SkPaint& paint) {
mtklein9db912c2015-05-19 11:11:26 -0700286 TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint);
mtkleinda574d12016-08-01 11:24:03 -0700287 APPEND(DrawTextBlob, paint, sk_ref_sp(blob), x, y);
fmalita00d5c2c2014-08-21 08:53:26 -0700288}
289
reedd5fa1a42014-08-09 11:08:05 -0700290void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) {
mtkleind711d112015-07-01 07:04:37 -0700291 if (fDrawPictureMode == Record_DrawPictureMode) {
292 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic);
mtkleinda574d12016-08-01 11:24:03 -0700293 APPEND(DrawPicture, this->copy(paint), sk_ref_sp(pic), matrix ? *matrix : SkMatrix::I());
mtkleind711d112015-07-01 07:04:37 -0700294 } else {
295 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
296 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
297 pic->playback(this);
298 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000299}
300
vjiaoblack95302da2016-07-21 10:25:54 -0700301void SkRecorder::onDrawShadowedPicture(const SkPicture* pic,
302 const SkMatrix* matrix,
303 const SkPaint* paint) {
304 if (fDrawPictureMode == Record_DrawPictureMode) {
305 fApproxBytesUsedBySubPictures += SkPictureUtils::ApproximateBytesUsed(pic);
mtkleinda574d12016-08-01 11:24:03 -0700306 APPEND(DrawShadowedPicture, this->copy(paint),
307 sk_ref_sp(pic),
308 matrix ? *matrix : SkMatrix::I());
vjiaoblack95302da2016-07-21 10:25:54 -0700309 } else {
310 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
311 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
312 pic->playback(this);
313 }
314}
315
316
reed41af9662015-01-05 07:49:08 -0800317void SkRecorder::onDrawVertices(VertexMode vmode,
318 int vertexCount, const SkPoint vertices[],
319 const SkPoint texs[], const SkColor colors[],
320 SkXfermode* xmode,
321 const uint16_t indices[], int indexCount, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700322 APPEND(DrawVertices, paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000323 vmode,
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000324 vertexCount,
325 this->copy(vertices, vertexCount),
halcanary96fcdcc2015-08-27 07:41:13 -0700326 texs ? this->copy(texs, vertexCount) : nullptr,
327 colors ? this->copy(colors, vertexCount) : nullptr,
mtkleinda574d12016-08-01 11:24:03 -0700328 sk_ref_sp(xmode),
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000329 this->copy(indices, indexCount),
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000330 indexCount);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000331}
332
dandovb3c9d1c2014-08-12 08:34:29 -0700333void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
334 const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700335 APPEND(DrawPatch, paint,
halcanary96fcdcc2015-08-27 07:41:13 -0700336 cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : nullptr,
337 colors ? this->copy(colors, SkPatchUtils::kNumCorners) : nullptr,
338 texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : nullptr,
mtkleinda574d12016-08-01 11:24:03 -0700339 sk_ref_sp(xmode));
dandov963137b2014-08-07 07:49:53 -0700340}
341
reed71c3c762015-06-24 10:29:17 -0700342void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
343 const SkColor colors[], int count, SkXfermode::Mode mode,
344 const SkRect* cull, const SkPaint* paint) {
345 APPEND(DrawAtlas, this->copy(paint),
mtkleinda574d12016-08-01 11:24:03 -0700346 sk_ref_sp(atlas),
reed71c3c762015-06-24 10:29:17 -0700347 this->copy(xform, count),
348 this->copy(tex, count),
349 this->copy(colors, count),
350 count,
351 mode,
352 this->copy(cull));
353}
354
reedf70b5312016-03-04 16:36:20 -0800355void SkRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
mtkleinda574d12016-08-01 11:24:03 -0700356 APPEND(DrawAnnotation, rect, SkString(key), sk_ref_sp(value));
reedf70b5312016-03-04 16:36:20 -0800357}
358
Florin Malita5f6102d2014-06-30 10:13:28 -0400359void SkRecorder::willSave() {
360 APPEND(Save);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000361}
362
reed4960eee2015-12-18 07:09:18 -0800363SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
mtkleinda574d12016-08-01 11:24:03 -0700364 APPEND(SaveLayer, this->copy(rec.fBounds)
365 , this->copy(rec.fPaint)
366 , sk_ref_sp(rec.fBackdrop)
367 , rec.fSaveLayerFlags);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000368 return SkCanvas::kNoLayer_SaveLayerStrategy;
369}
370
mtklein6cfa73a2014-08-13 13:33:49 -0700371void SkRecorder::didRestore() {
mtkleina723b572014-08-15 11:49:49 -0700372 APPEND(Restore, this->devBounds(), this->getTotalMatrix());
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000373}
374
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000375void SkRecorder::didConcat(const SkMatrix& matrix) {
mtkleine9d20522015-11-19 12:08:24 -0800376 APPEND(Concat, matrix);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000377}
378
379void SkRecorder::didSetMatrix(const SkMatrix& matrix) {
380 APPEND(SetMatrix, matrix);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000381}
382
vjiaoblack95302da2016-07-21 10:25:54 -0700383void SkRecorder::didTranslateZ(SkScalar z) {
384#ifdef SK_EXPERIMENTAL_SHADOWING
vjiaoblacke5de1302016-07-13 14:05:28 -0700385 APPEND(TranslateZ, z);
vjiaoblack95302da2016-07-21 10:25:54 -0700386#endif
vjiaoblacke5de1302016-07-13 14:05:28 -0700387}
388
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000389void SkRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000390 INHERITED(onClipRect, rect, op, edgeStyle);
mtkleincdeeb092014-11-20 09:14:28 -0800391 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
392 APPEND(ClipRect, this->devBounds(), rect, opAA);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000393}
394
395void SkRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
reedd9544982014-09-09 18:46:22 -0700396 INHERITED(onClipRRect, rrect, op, edgeStyle);
mtkleincdeeb092014-11-20 09:14:28 -0800397 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
398 APPEND(ClipRRect, this->devBounds(), rrect, opAA);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000399}
400
401void SkRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
reedd9544982014-09-09 18:46:22 -0700402 INHERITED(onClipPath, path, op, edgeStyle);
mtkleincdeeb092014-11-20 09:14:28 -0800403 SkRecords::RegionOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
mtkleinc845fa02015-06-30 09:49:49 -0700404 APPEND(ClipPath, this->devBounds(), path, opAA);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000405}
406
407void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000408 INHERITED(onClipRegion, deviceRgn, op);
mtkleinc845fa02015-06-30 09:49:49 -0700409 APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000410}
mtklein5f0e8222014-08-22 11:44:26 -0700411
reede8f30622016-03-23 18:59:25 -0700412sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) {
413 return nullptr;
414}