blob: c111db6606f0282c94f27cff31becadaec84d89e [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 "SkRecorder.h"
reede8f30622016-03-23 18:59:25 -070014#include "SkSurface.h"
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000015
reed3cb38402015-02-06 08:36:15 -080016SkDrawableList::~SkDrawableList() {
reed1bdfd3f2014-11-24 14:41:51 -080017 fArray.unrefAll();
18}
19
mtklein9db912c2015-05-19 11:11:26 -070020SkBigPicture::SnapshotArray* SkDrawableList::newDrawableSnapshot() {
reed1bdfd3f2014-11-24 14:41:51 -080021 const int count = fArray.count();
22 if (0 == count) {
halcanary96fcdcc2015-08-27 07:41:13 -070023 return nullptr;
reed1bdfd3f2014-11-24 14:41:51 -080024 }
25 SkAutoTMalloc<const SkPicture*> pics(count);
26 for (int i = 0; i < count; ++i) {
27 pics[i] = fArray[i]->newPictureSnapshot();
28 }
mtklein18300a32016-03-16 13:53:35 -070029 return new SkBigPicture::SnapshotArray(pics.release(), count);
reed1bdfd3f2014-11-24 14:41:51 -080030}
31
reed3cb38402015-02-06 08:36:15 -080032void SkDrawableList::append(SkDrawable* drawable) {
reed1bdfd3f2014-11-24 14:41:51 -080033 *fArray.append() = SkRef(drawable);
34}
35
36///////////////////////////////////////////////////////////////////////////////////////////////
37
mtklein9db912c2015-05-19 11:11:26 -070038SkRecorder::SkRecorder(SkRecord* record, int width, int height, SkMiniRecorder* mr)
Florin Malita439ace92016-12-02 12:05:41 -050039 : SkNoDrawCanvas(width, height)
mtkleind711d112015-07-01 07:04:37 -070040 , fDrawPictureMode(Record_DrawPictureMode)
mtklein98b84852015-04-21 15:23:59 -070041 , fApproxBytesUsedBySubPictures(0)
mtklein9db912c2015-05-19 11:11:26 -070042 , fRecord(record)
43 , fMiniRecorder(mr) {}
reed78e27682014-11-19 08:04:34 -080044
mtklein9db912c2015-05-19 11:11:26 -070045SkRecorder::SkRecorder(SkRecord* record, const SkRect& bounds, SkMiniRecorder* mr)
Florin Malita439ace92016-12-02 12:05:41 -050046 : SkNoDrawCanvas(bounds.roundOut())
mtkleind711d112015-07-01 07:04:37 -070047 , fDrawPictureMode(Record_DrawPictureMode)
mtklein98b84852015-04-21 15:23:59 -070048 , fApproxBytesUsedBySubPictures(0)
mtklein9db912c2015-05-19 11:11:26 -070049 , fRecord(record)
50 , fMiniRecorder(mr) {}
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +000051
mtkleind711d112015-07-01 07:04:37 -070052void SkRecorder::reset(SkRecord* record, const SkRect& bounds,
53 DrawPictureMode dpm, SkMiniRecorder* mr) {
mtkleinfeaadee2015-04-08 11:25:48 -070054 this->forgetRecord();
mtkleind711d112015-07-01 07:04:37 -070055 fDrawPictureMode = dpm;
mtkleinfeaadee2015-04-08 11:25:48 -070056 fRecord = record;
Adrienne Walker6a280a52017-05-01 13:45:01 -070057 SkIRect rounded = bounds.roundOut();
58 this->resetCanvas(rounded.right(), rounded.bottom());
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
Florin Malita439ace92016-12-02 12:05:41 -050078// For methods which must call back into SkNoDrawCanvas.
79#define INHERITED(method, ...) this->SkNoDrawCanvas::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
msarett44df6512016-08-25 13:54:30 -0700148void SkRecorder::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
149 APPEND(DrawRegion, paint, region);
150}
151
reed41af9662015-01-05 07:49:08 -0800152void SkRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700153 APPEND(DrawOval, paint, oval);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000154}
155
bsalomonac3aa242016-08-19 11:25:19 -0700156void SkRecorder::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
157 bool useCenter, const SkPaint& paint) {
158 APPEND(DrawArc, paint, oval, startAngle, sweepAngle, useCenter);
159}
160
reed41af9662015-01-05 07:49:08 -0800161void SkRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700162 APPEND(DrawRRect, paint, rrect);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000163}
164
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000165void SkRecorder::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700166 APPEND(DrawDRRect, paint, outer, inner);
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000167}
168
reeda8db7282015-07-07 10:22:31 -0700169void SkRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
djsollenaa6f7392015-11-17 06:18:31 -0800170 if (fDrawPictureMode == Record_DrawPictureMode) {
171 if (!fDrawableList) {
172 fDrawableList.reset(new SkDrawableList);
173 }
174 fDrawableList->append(drawable);
175 APPEND(DrawDrawable, this->copy(matrix), drawable->getBounds(), fDrawableList->count() - 1);
176 } else {
177 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
178 drawable->draw(this, matrix);
reed1bdfd3f2014-11-24 14:41:51 -0800179 }
reed6be2aa92014-11-18 11:08:05 -0800180}
181
reed41af9662015-01-05 07:49:08 -0800182void SkRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
mtklein9db912c2015-05-19 11:11:26 -0700183 TRY_MINIRECORDER(drawPath, path, paint);
mtkleinc845fa02015-06-30 09:49:49 -0700184 APPEND(DrawPath, paint, path);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000185}
186
reed41af9662015-01-05 07:49:08 -0800187void SkRecorder::onDrawBitmap(const SkBitmap& bitmap,
188 SkScalar left,
189 SkScalar top,
190 const SkPaint* paint) {
reed9b84f8c2016-07-28 14:26:13 -0700191 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
reed56179002015-07-07 06:11:19 -0700192 if (image) {
reed9b84f8c2016-07-28 14:26:13 -0700193 this->onDrawImage(image.get(), left, top, paint);
reed56179002015-07-07 06:11:19 -0700194 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000195}
196
reed41af9662015-01-05 07:49:08 -0800197void SkRecorder::onDrawBitmapRect(const SkBitmap& bitmap,
198 const SkRect* src,
199 const SkRect& dst,
200 const SkPaint* paint,
reed562fe472015-07-28 07:35:14 -0700201 SrcRectConstraint constraint) {
reed9b84f8c2016-07-28 14:26:13 -0700202 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
reed56179002015-07-07 06:11:19 -0700203 if (image) {
reed9b84f8c2016-07-28 14:26:13 -0700204 this->onDrawImageRect(image.get(), src, dst, paint, constraint);
reed56179002015-07-07 06:11:19 -0700205 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000206}
207
reed41af9662015-01-05 07:49:08 -0800208void SkRecorder::onDrawBitmapNine(const SkBitmap& bitmap,
209 const SkIRect& center,
210 const SkRect& dst,
211 const SkPaint* paint) {
reed9b84f8c2016-07-28 14:26:13 -0700212 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
reed56179002015-07-07 06:11:19 -0700213 if (image) {
reed9b84f8c2016-07-28 14:26:13 -0700214 this->onDrawImageNine(image.get(), center, dst, paint);
reed56179002015-07-07 06:11:19 -0700215 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000216}
217
msarett16882062016-08-16 09:31:08 -0700218void SkRecorder::onDrawBitmapLattice(const SkBitmap& bitmap, const Lattice& lattice,
219 const SkRect& dst, const SkPaint* paint) {
220 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap);
221 this->onDrawImageLattice(image.get(), lattice, dst, paint);
222}
223
reed41af9662015-01-05 07:49:08 -0800224void SkRecorder::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
225 const SkPaint* paint) {
mtkleinda574d12016-08-01 11:24:03 -0700226 APPEND(DrawImage, this->copy(paint), sk_ref_sp(image), left, top);
piotaixr65151752014-10-16 11:58:39 -0700227}
228
reed562fe472015-07-28 07:35:14 -0700229void SkRecorder::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
230 const SkPaint* paint, SrcRectConstraint constraint) {
mtkleinda574d12016-08-01 11:24:03 -0700231 APPEND(DrawImageRect, this->copy(paint), sk_ref_sp(image), this->copy(src), dst, constraint);
piotaixr65151752014-10-16 11:58:39 -0700232}
233
reed4c21dc52015-06-25 12:32:03 -0700234void SkRecorder::onDrawImageNine(const SkImage* image, const SkIRect& center,
235 const SkRect& dst, const SkPaint* paint) {
mtkleinda574d12016-08-01 11:24:03 -0700236 APPEND(DrawImageNine, this->copy(paint), sk_ref_sp(image), center, dst);
reed4c21dc52015-06-25 12:32:03 -0700237}
238
msarett16882062016-08-16 09:31:08 -0700239void SkRecorder::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
240 const SkPaint* paint) {
msarett0764efe2016-09-02 11:24:30 -0700241 int flagCount = lattice.fFlags ? (lattice.fXCount + 1) * (lattice.fYCount + 1) : 0;
msarett71df2d72016-09-30 12:41:42 -0700242 SkASSERT(lattice.fBounds);
msarett16882062016-08-16 09:31:08 -0700243 APPEND(DrawImageLattice, this->copy(paint), sk_ref_sp(image),
244 lattice.fXCount, this->copy(lattice.fXDivs, lattice.fXCount),
msarett0764efe2016-09-02 11:24:30 -0700245 lattice.fYCount, this->copy(lattice.fYDivs, lattice.fYCount),
msarett71df2d72016-09-30 12:41:42 -0700246 flagCount, this->copy(lattice.fFlags, flagCount), *lattice.fBounds, dst);
msarett16882062016-08-16 09:31:08 -0700247}
248
reed@google.come0d9ce82014-04-23 04:00:17 +0000249void SkRecorder::onDrawText(const void* text, size_t byteLength,
250 SkScalar x, SkScalar y, const SkPaint& paint) {
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000251 APPEND(DrawText,
mtkleinc845fa02015-06-30 09:49:49 -0700252 paint, this->copy((const char*)text, byteLength), byteLength, x, y);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000253}
254
reed@google.come0d9ce82014-04-23 04:00:17 +0000255void SkRecorder::onDrawPosText(const void* text, size_t byteLength,
256 const SkPoint pos[], const SkPaint& paint) {
mtkleinc6ad06a2015-08-19 09:51:00 -0700257 const int points = paint.countText(text, byteLength);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000258 APPEND(DrawPosText,
mtkleinc845fa02015-06-30 09:49:49 -0700259 paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000260 this->copy((const char*)text, byteLength),
261 byteLength,
262 this->copy(pos, points));
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000263}
264
reed@google.come0d9ce82014-04-23 04:00:17 +0000265void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength,
266 const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
mtkleinc6ad06a2015-08-19 09:51:00 -0700267 const int points = paint.countText(text, byteLength);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000268 APPEND(DrawPosTextH,
mtkleinc845fa02015-06-30 09:49:49 -0700269 paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000270 this->copy((const char*)text, byteLength),
mtklein42ddcd42014-11-21 08:48:35 -0800271 SkToUInt(byteLength),
272 constY,
273 this->copy(xpos, points));
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000274}
275
reed@google.come0d9ce82014-04-23 04:00:17 +0000276void SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
277 const SkMatrix* matrix, const SkPaint& paint) {
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000278 APPEND(DrawTextOnPath,
mtkleinc845fa02015-06-30 09:49:49 -0700279 paint,
commit-bot@chromium.org37f6e622014-05-07 22:59:38 +0000280 this->copy((const char*)text, byteLength),
281 byteLength,
mtkleinc845fa02015-06-30 09:49:49 -0700282 path,
mtkleinaf579032014-12-01 11:03:37 -0800283 matrix ? *matrix : SkMatrix::I());
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000284}
285
reed45561a02016-07-07 12:47:17 -0700286void SkRecorder::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
287 const SkRect* cull, const SkPaint& paint) {
288 APPEND(DrawTextRSXform,
289 paint,
290 this->copy((const char*)text, byteLength),
291 byteLength,
292 this->copy(xform, paint.countText(text, byteLength)),
293 this->copy(cull));
294}
295
fmalita00d5c2c2014-08-21 08:53:26 -0700296void SkRecorder::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
297 const SkPaint& paint) {
mtklein9db912c2015-05-19 11:11:26 -0700298 TRY_MINIRECORDER(drawTextBlob, blob, x, y, paint);
mtkleinda574d12016-08-01 11:24:03 -0700299 APPEND(DrawTextBlob, paint, sk_ref_sp(blob), x, y);
fmalita00d5c2c2014-08-21 08:53:26 -0700300}
301
reedd5fa1a42014-08-09 11:08:05 -0700302void SkRecorder::onDrawPicture(const SkPicture* pic, const SkMatrix* matrix, const SkPaint* paint) {
mtkleind711d112015-07-01 07:04:37 -0700303 if (fDrawPictureMode == Record_DrawPictureMode) {
Mike Reed90b20052017-03-08 10:39:02 -0500304 fApproxBytesUsedBySubPictures += pic->approximateBytesUsed();
mtkleinda574d12016-08-01 11:24:03 -0700305 APPEND(DrawPicture, this->copy(paint), sk_ref_sp(pic), matrix ? *matrix : SkMatrix::I());
mtkleind711d112015-07-01 07:04:37 -0700306 } else {
307 SkASSERT(fDrawPictureMode == Playback_DrawPictureMode);
308 SkAutoCanvasMatrixPaint acmp(this, matrix, paint, pic->cullRect());
309 pic->playback(this);
310 }
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000311}
312
Mike Reede88a1cb2017-03-17 09:50:46 -0400313void SkRecorder::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmode,
314 const SkPaint& paint) {
315 APPEND(DrawVertices, paint, sk_ref_sp(const_cast<SkVertices*>(vertices)), bmode);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000316}
317
dandovb3c9d1c2014-08-12 08:34:29 -0700318void SkRecorder::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
Mike Reedfaba3712016-11-03 14:45:31 -0400319 const SkPoint texCoords[4], SkBlendMode bmode,
Mike Reed7d954ad2016-10-28 15:42:34 -0400320 const SkPaint& paint) {
mtkleinc845fa02015-06-30 09:49:49 -0700321 APPEND(DrawPatch, paint,
halcanary96fcdcc2015-08-27 07:41:13 -0700322 cubics ? this->copy(cubics, SkPatchUtils::kNumCtrlPts) : nullptr,
323 colors ? this->copy(colors, SkPatchUtils::kNumCorners) : nullptr,
324 texCoords ? this->copy(texCoords, SkPatchUtils::kNumCorners) : nullptr,
Mike Reed7d954ad2016-10-28 15:42:34 -0400325 bmode);
dandov963137b2014-08-07 07:49:53 -0700326}
327
reed71c3c762015-06-24 10:29:17 -0700328void SkRecorder::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
Mike Reedfaba3712016-11-03 14:45:31 -0400329 const SkColor colors[], int count, SkBlendMode mode,
reed71c3c762015-06-24 10:29:17 -0700330 const SkRect* cull, const SkPaint* paint) {
331 APPEND(DrawAtlas, this->copy(paint),
mtkleinda574d12016-08-01 11:24:03 -0700332 sk_ref_sp(atlas),
reed71c3c762015-06-24 10:29:17 -0700333 this->copy(xform, count),
334 this->copy(tex, count),
335 this->copy(colors, count),
336 count,
Mike Reedfaba3712016-11-03 14:45:31 -0400337 mode,
reed71c3c762015-06-24 10:29:17 -0700338 this->copy(cull));
339}
340
reedf70b5312016-03-04 16:36:20 -0800341void SkRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
mtkleinda574d12016-08-01 11:24:03 -0700342 APPEND(DrawAnnotation, rect, SkString(key), sk_ref_sp(value));
reedf70b5312016-03-04 16:36:20 -0800343}
344
Florin Malita5f6102d2014-06-30 10:13:28 -0400345void SkRecorder::willSave() {
346 APPEND(Save);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000347}
348
reed4960eee2015-12-18 07:09:18 -0800349SkCanvas::SaveLayerStrategy SkRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
mtkleinda574d12016-08-01 11:24:03 -0700350 APPEND(SaveLayer, this->copy(rec.fBounds)
351 , this->copy(rec.fPaint)
352 , sk_ref_sp(rec.fBackdrop)
Mike Kleinb34ab042017-05-01 21:34:14 +0000353 , sk_ref_sp(rec.fClipMask)
Florin Malita53f77bd2017-04-28 13:48:37 -0400354 , this->copy(rec.fClipMatrix)
mtkleinda574d12016-08-01 11:24:03 -0700355 , rec.fSaveLayerFlags);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000356 return SkCanvas::kNoLayer_SaveLayerStrategy;
357}
358
mtklein6cfa73a2014-08-13 13:33:49 -0700359void SkRecorder::didRestore() {
Mike Reed42e8c532017-01-23 14:09:13 -0500360 APPEND(Restore, this->getDeviceClipBounds(), this->getTotalMatrix());
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000361}
362
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000363void SkRecorder::didConcat(const SkMatrix& matrix) {
mtkleine9d20522015-11-19 12:08:24 -0800364 APPEND(Concat, matrix);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000365}
366
367void SkRecorder::didSetMatrix(const SkMatrix& matrix) {
368 APPEND(SetMatrix, matrix);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000369}
370
mtkleincbdf0072016-08-19 09:05:27 -0700371void SkRecorder::didTranslate(SkScalar dx, SkScalar dy) {
372 APPEND(Translate, dx, dy);
373}
374
vjiaoblack95302da2016-07-21 10:25:54 -0700375void SkRecorder::didTranslateZ(SkScalar z) {
376#ifdef SK_EXPERIMENTAL_SHADOWING
vjiaoblacke5de1302016-07-13 14:05:28 -0700377 APPEND(TranslateZ, z);
vjiaoblack95302da2016-07-21 10:25:54 -0700378#endif
vjiaoblacke5de1302016-07-13 14:05:28 -0700379}
380
Mike Reedc1f77742016-12-09 09:00:50 -0500381void SkRecorder::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000382 INHERITED(onClipRect, rect, op, edgeStyle);
reed73603f32016-09-20 08:42:38 -0700383 SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
Mike Reed42e8c532017-01-23 14:09:13 -0500384 APPEND(ClipRect, this->getDeviceClipBounds(), rect, opAA);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000385}
386
Mike Reedc1f77742016-12-09 09:00:50 -0500387void SkRecorder::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
reedd9544982014-09-09 18:46:22 -0700388 INHERITED(onClipRRect, rrect, op, edgeStyle);
reed73603f32016-09-20 08:42:38 -0700389 SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
Mike Reed42e8c532017-01-23 14:09:13 -0500390 APPEND(ClipRRect, this->getDeviceClipBounds(), rrect, opAA);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000391}
392
Mike Reedc1f77742016-12-09 09:00:50 -0500393void SkRecorder::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
reedd9544982014-09-09 18:46:22 -0700394 INHERITED(onClipPath, path, op, edgeStyle);
reed73603f32016-09-20 08:42:38 -0700395 SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
Mike Reed42e8c532017-01-23 14:09:13 -0500396 APPEND(ClipPath, this->getDeviceClipBounds(), path, opAA);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000397}
398
Mike Reedc1f77742016-12-09 09:00:50 -0500399void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
commit-bot@chromium.orgd9ce2be2014-04-09 23:30:28 +0000400 INHERITED(onClipRegion, deviceRgn, op);
Mike Reed42e8c532017-01-23 14:09:13 -0500401 APPEND(ClipRegion, this->getDeviceClipBounds(), deviceRgn, op);
commit-bot@chromium.orge3ff5582014-04-01 16:24:06 +0000402}
mtklein5f0e8222014-08-22 11:44:26 -0700403
reede8f30622016-03-23 18:59:25 -0700404sk_sp<SkSurface> SkRecorder::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) {
405 return nullptr;
406}