blob: 64830a48c76049fae32e3c6b7c15a8dd5573e003 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001/*
2 * Copyright 2012 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
8#ifndef SKDRAWCOMMAND_H_
9#define SKDRAWCOMMAND_H_
10
Florin Malitaab244f02017-05-03 19:16:58 +000011#include "SkBitmap.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000012#include "SkCanvas.h"
Mike Reed086a4272017-07-18 10:53:11 -040013#include "SkFlattenable.h"
bungemand3ebb482015-08-05 13:57:49 -070014#include "SkTLazy.h"
15#include "SkPath.h"
Mike Reed267be7f2017-02-13 09:32:54 -050016#include "SkRegion.h"
bungemand3ebb482015-08-05 13:57:49 -070017#include "SkRRect.h"
reed45561a02016-07-07 12:47:17 -070018#include "SkRSXform.h"
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000019#include "SkString.h"
bungemand3ebb482015-08-05 13:57:49 -070020#include "SkTDArray.h"
Mike Reedfed9cfd2017-03-17 12:09:04 -040021#include "SkVertices.h"
ethannicholas50a8dd02016-02-10 05:40:46 -080022#include "SkJSONCPP.h"
ethannicholasf62a8b72016-02-11 10:35:21 -080023#include "UrlDataManager.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000024
Mike Klein0f61faa2016-10-11 16:26:57 -040025class SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000026public:
robertphillips9bafc302015-02-13 11:13:00 -080027 enum OpType {
fmalita160ebb22015-04-01 20:58:37 -070028 kBeginDrawPicture_OpType,
Brian Osmanc25e2692018-03-12 10:57:28 -040029 kClear_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080030 kClipPath_OpType,
31 kClipRegion_OpType,
32 kClipRect_OpType,
33 kClipRRect_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080034 kConcat_OpType,
reed97660cc2016-06-28 18:54:19 -070035 kDrawAnnotation_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080036 kDrawBitmap_OpType,
37 kDrawBitmapNine_OpType,
38 kDrawBitmapRect_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080039 kDrawDRRect_OpType,
fmalita651c9202015-07-22 10:23:01 -070040 kDrawImage_OpType,
Stan Ilievac42aeb2017-01-12 16:20:50 -050041 kDrawImageLattice_OpType,
Brian Osmanc25e2692018-03-12 10:57:28 -040042 kDrawImageNine_OpType,
fmalita651c9202015-07-22 10:23:01 -070043 kDrawImageRect_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080044 kDrawOval_OpType,
Brian Osmanc25e2692018-03-12 10:57:28 -040045 kDrawArc_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080046 kDrawPaint_OpType,
47 kDrawPatch_OpType,
48 kDrawPath_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080049 kDrawPoints_OpType,
50 kDrawPosText_OpType,
51 kDrawPosTextH_OpType,
52 kDrawRect_OpType,
53 kDrawRRect_OpType,
Brian Osmanc25e2692018-03-12 10:57:28 -040054 kDrawRegion_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080055 kDrawText_OpType,
56 kDrawTextBlob_OpType,
57 kDrawTextOnPath_OpType,
reed45561a02016-07-07 12:47:17 -070058 kDrawTextRSXform_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080059 kDrawVertices_OpType,
fmalita160ebb22015-04-01 20:58:37 -070060 kEndDrawPicture_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080061 kRestore_OpType,
62 kSave_OpType,
63 kSaveLayer_OpType,
64 kSetMatrix_OpType,
robertphillips72942b82015-02-12 06:37:12 -080065
Jim Van Verth343fe492017-05-02 16:49:24 -040066 kLast_OpType = kSetMatrix_OpType
robertphillips9bafc302015-02-13 11:13:00 -080067 };
68
69 static const int kOpTypeCount = kLast_OpType + 1;
70
halcanarya73d76a2016-10-17 13:19:02 -070071 static void WritePNG(const uint8_t* rgba, unsigned width, unsigned height,
msaretta5cf4f42016-06-30 10:06:51 -070072 SkWStream& out, bool isOpaque);
ethannicholasf67531f2016-03-21 10:19:39 -070073
robertphillips9bafc302015-02-13 11:13:00 -080074 SkDrawCommand(OpType opType);
chudy@google.com902ebe52012-06-29 14:21:22 +000075
Brian Osman255735e2018-04-06 14:51:42 -040076 virtual ~SkDrawCommand() {}
chudy@google.com902ebe52012-06-29 14:21:22 +000077
chudy@google.com0b5bbb02012-07-31 19:55:32 +000078 bool isVisible() const {
79 return fVisible;
80 }
81
82 void setVisible(bool toggle) {
83 fVisible = toggle;
84 }
chudy@google.com902ebe52012-06-29 14:21:22 +000085
fmalita8c89c522014-11-08 16:18:56 -080086 virtual void execute(SkCanvas*) const = 0;
chudy@google.com902ebe52012-06-29 14:21:22 +000087
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000088 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000089
ethannicholasf62a8b72016-02-11 10:35:21 -080090 virtual Json::Value toJSON(UrlDataManager& urlDataManager) const;
ethannicholas50a8dd02016-02-10 05:40:46 -080091
92 /* Converts a JSON representation of a command into a newly-allocated SkDrawCommand object. It
93 * is the caller's responsibility to delete this object. This method may return null if an error
94 * occurs.
95 */
ethannicholasf62a8b72016-02-11 10:35:21 -080096 static SkDrawCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -080097
robertphillips9bafc302015-02-13 11:13:00 -080098 static const char* GetCommandString(OpType type);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000099
joshualittbd724132016-03-03 11:39:38 -0800100 // Helper methods for converting things to JSON
brianosmanfad98562016-05-04 11:06:28 -0700101 static Json::Value MakeJsonColor(const SkColor color);
brianosman97bbf822016-09-25 13:15:58 -0700102 static Json::Value MakeJsonColor4f(const SkColor4f& color);
brianosmanfad98562016-05-04 11:06:28 -0700103 static Json::Value MakeJsonPoint(const SkPoint& point);
104 static Json::Value MakeJsonPoint(SkScalar x, SkScalar y);
105 static Json::Value MakeJsonRect(const SkRect& rect);
joshualittbd724132016-03-03 11:39:38 -0800106 static Json::Value MakeJsonIRect(const SkIRect&);
107 static Json::Value MakeJsonMatrix(const SkMatrix&);
vjiaoblacke5de1302016-07-13 14:05:28 -0700108 static Json::Value MakeJsonScalar(SkScalar);
brianosmanfad98562016-05-04 11:06:28 -0700109 static Json::Value MakeJsonPath(const SkPath& path);
110 static Json::Value MakeJsonRegion(const SkRegion& region);
111 static Json::Value MakeJsonPaint(const SkPaint& paint, UrlDataManager& urlDataManager);
Stan Ilievac42aeb2017-01-12 16:20:50 -0500112 static Json::Value MakeJsonLattice(const SkCanvas::Lattice& lattice);
brianosmanfad98562016-05-04 11:06:28 -0700113
114 static void flatten(const SkFlattenable* flattenable, Json::Value* target,
115 UrlDataManager& urlDataManager);
116 static bool flatten(const SkImage& image, Json::Value* target,
117 UrlDataManager& urlDataManager);
118 static bool flatten(const SkBitmap& bitmap, Json::Value* target,
119 UrlDataManager& urlDataManager);
joshualittbd724132016-03-03 11:39:38 -0800120
chudy@google.com902ebe52012-06-29 14:21:22 +0000121private:
robertphillips9bafc302015-02-13 11:13:00 -0800122 OpType fOpType;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000123 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +0000124};
125
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000126class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000127public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000128 SkRestoreCommand();
mtklein36352bf2015-03-25 18:17:31 -0700129 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800130 static SkRestoreCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000131
132private:
133 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000134};
135
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000136class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000137public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000138 SkClearCommand(SkColor color);
mtklein36352bf2015-03-25 18:17:31 -0700139 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800140 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
141 static SkClearCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800142
chudy@google.com902ebe52012-06-29 14:21:22 +0000143private:
144 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000145
146 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000147};
148
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000149class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000150public:
Mike Reedc1f77742016-12-09 09:00:50 -0500151 SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700152 void execute(SkCanvas* canvas) const override;
153 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800154 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
155 static SkClipPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800156
chudy@google.com902ebe52012-06-29 14:21:22 +0000157private:
Mike Reedc1f77742016-12-09 09:00:50 -0500158 SkPath fPath;
159 SkClipOp fOp;
160 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000161
162 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000163};
164
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000165class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000166public:
Mike Reedc1f77742016-12-09 09:00:50 -0500167 SkClipRegionCommand(const SkRegion& region, SkClipOp op);
mtklein36352bf2015-03-25 18:17:31 -0700168 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800169 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
170 static SkClipRegionCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800171
chudy@google.com902ebe52012-06-29 14:21:22 +0000172private:
Mike Reedc1f77742016-12-09 09:00:50 -0500173 SkRegion fRegion;
174 SkClipOp fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000175
176 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000177};
178
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000179class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000180public:
Mike Reedc1f77742016-12-09 09:00:50 -0500181 SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700182 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800183 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
184 static SkClipRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000185
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000186 const SkRect& rect() const { return fRect; }
Mike Reedc1f77742016-12-09 09:00:50 -0500187 SkClipOp op() const { return fOp; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000188 bool doAA() const { return fDoAA; }
189
chudy@google.com902ebe52012-06-29 14:21:22 +0000190private:
Mike Reedc1f77742016-12-09 09:00:50 -0500191 SkRect fRect;
192 SkClipOp fOp;
193 bool fDoAA;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000194
195 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000196};
197
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000198class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000199public:
Mike Reedc1f77742016-12-09 09:00:50 -0500200 SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700201 void execute(SkCanvas* canvas) const override;
202 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800203 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
204 static SkClipRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000205
206 const SkRRect& rrect() const { return fRRect; }
Mike Reedc1f77742016-12-09 09:00:50 -0500207 SkClipOp op() const { return fOp; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000208 bool doAA() const { return fDoAA; }
209
robertphillips@google.com67baba42013-01-02 20:20:31 +0000210private:
Mike Reedc1f77742016-12-09 09:00:50 -0500211 SkRRect fRRect;
212 SkClipOp fOp;
213 bool fDoAA;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000214
215 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000216};
217
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000218class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000219public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000220 SkConcatCommand(const SkMatrix& matrix);
mtklein36352bf2015-03-25 18:17:31 -0700221 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800222 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
223 static SkConcatCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800224
chudy@google.com902ebe52012-06-29 14:21:22 +0000225private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000226 SkMatrix fMatrix;
227
228 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000229};
230
reed97660cc2016-06-28 18:54:19 -0700231class SkDrawAnnotationCommand : public SkDrawCommand {
232public:
233 SkDrawAnnotationCommand(const SkRect&, const char key[], sk_sp<SkData> value);
234 void execute(SkCanvas* canvas) const override;
235 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
236 static SkDrawAnnotationCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
237
238private:
239 SkRect fRect;
240 SkString fKey;
241 sk_sp<SkData> fValue;
242
243 typedef SkDrawCommand INHERITED;
244};
245
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000246class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000247public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000248 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000249 const SkPaint* paint);
mtklein36352bf2015-03-25 18:17:31 -0700250 void execute(SkCanvas* canvas) const override;
251 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800252 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
253 static SkDrawBitmapCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800254
chudy@google.com902ebe52012-06-29 14:21:22 +0000255private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000256 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000257 SkScalar fLeft;
258 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000259 SkPaint fPaint;
260 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000261
262 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000263};
264
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000265class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000266public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000267 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000268 const SkRect& dst, const SkPaint* paint);
mtklein36352bf2015-03-25 18:17:31 -0700269 void execute(SkCanvas* canvas) const override;
270 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800271 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
272 static SkDrawBitmapNineCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800273
chudy@google.com902ebe52012-06-29 14:21:22 +0000274private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000275 SkBitmap fBitmap;
276 SkIRect fCenter;
277 SkRect fDst;
278 SkPaint fPaint;
279 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000280
281 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000282};
283
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000284class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000285public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000286 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000287 const SkRect& dst, const SkPaint* paint,
reeda5517e22015-07-14 10:54:12 -0700288 SkCanvas::SrcRectConstraint);
mtklein36352bf2015-03-25 18:17:31 -0700289 void execute(SkCanvas* canvas) const override;
290 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800291 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
292 static SkDrawBitmapRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000293
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000294 const SkBitmap& bitmap() const { return fBitmap; }
295
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000296 // The non-const 'paint' method allows modification of this object's
297 // SkPaint. For this reason the ctor and setPaint method make a local copy.
298 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
299 // (since only an SkPaint* is passed into the ctor).
300 const SkPaint* paint() const { return fPaintPtr; }
301 SkPaint* paint() { return fPaintPtr; }
302
303 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
304
halcanary96fcdcc2015-08-27 07:41:13 -0700305 const SkRect* srcRect() const { return fSrc.isEmpty() ? nullptr : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000306 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000307
308 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000309 void setDstRect(const SkRect& dst) { fDst = dst; }
310
reeda5517e22015-07-14 10:54:12 -0700311 SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
312 void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000313
chudy@google.com902ebe52012-06-29 14:21:22 +0000314private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000315 SkBitmap fBitmap;
316 SkRect fSrc;
317 SkRect fDst;
318 SkPaint fPaint;
319 SkPaint* fPaintPtr;
reeda5517e22015-07-14 10:54:12 -0700320 SkCanvas::SrcRectConstraint fConstraint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000321
322 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000323};
324
fmalita651c9202015-07-22 10:23:01 -0700325class SkDrawImageCommand : public SkDrawCommand {
326public:
327 SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);
328 void execute(SkCanvas* canvas) const override;
329 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800330 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
331 static SkDrawImageCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800332
fmalita651c9202015-07-22 10:23:01 -0700333private:
Hal Canary1b612a82016-11-03 16:26:13 -0400334 sk_sp<const SkImage> fImage;
335 SkScalar fLeft;
336 SkScalar fTop;
337 SkTLazy<SkPaint> fPaint;
fmalita651c9202015-07-22 10:23:01 -0700338
339 typedef SkDrawCommand INHERITED;
340};
341
Stan Ilievac42aeb2017-01-12 16:20:50 -0500342class SkDrawImageLatticeCommand : public SkDrawCommand {
343public:
344 SkDrawImageLatticeCommand(const SkImage* image, const SkCanvas::Lattice& lattice,
345 const SkRect& dst, const SkPaint* paint);
346 void execute(SkCanvas* canvas) const override;
347 bool render(SkCanvas* canvas) const override;
348 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
Brian Osmanc25e2692018-03-12 10:57:28 -0400349 static SkDrawImageLatticeCommand* fromJSON(Json::Value& command,
350 UrlDataManager& urlDataManager);
Stan Ilievac42aeb2017-01-12 16:20:50 -0500351
352private:
353 sk_sp<const SkImage> fImage;
354 SkCanvas::Lattice fLattice;
355 SkRect fDst;
356 SkTLazy<SkPaint> fPaint;
357
358 typedef SkDrawCommand INHERITED;
359};
360
Brian Osmanc25e2692018-03-12 10:57:28 -0400361class SkDrawImageNineCommand : public SkDrawCommand {
362public:
363 SkDrawImageNineCommand(const SkImage* image, const SkIRect& center,
364 const SkRect& dst, const SkPaint* paint);
365 void execute(SkCanvas* canvas) const override;
366 bool render(SkCanvas* canvas) const override;
367 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
368 static SkDrawImageNineCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
369
370private:
371 sk_sp<const SkImage> fImage;
372 SkIRect fCenter;
373 SkRect fDst;
374 SkPaint fPaint;
375 SkPaint* fPaintPtr;
376
377 typedef SkDrawCommand INHERITED;
378};
379
fmalita651c9202015-07-22 10:23:01 -0700380class SkDrawImageRectCommand : public SkDrawCommand {
381public:
382 SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect& dst,
383 const SkPaint* paint, SkCanvas::SrcRectConstraint constraint);
384 void execute(SkCanvas* canvas) const override;
385 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800386 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
387 static SkDrawImageRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800388
fmalita651c9202015-07-22 10:23:01 -0700389private:
Hal Canary1b612a82016-11-03 16:26:13 -0400390 sk_sp<const SkImage> fImage;
fmalita651c9202015-07-22 10:23:01 -0700391 SkTLazy<SkRect> fSrc;
392 SkRect fDst;
393 SkTLazy<SkPaint> fPaint;
394 SkCanvas::SrcRectConstraint fConstraint;
395
396 typedef SkDrawCommand INHERITED;
397};
398
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000399class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000400public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000401 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700402 void execute(SkCanvas* canvas) const override;
403 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800404 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
405 static SkDrawOvalCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800406
robertphillips@google.com67baba42013-01-02 20:20:31 +0000407private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000408 SkRect fOval;
409 SkPaint fPaint;
410
411 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000412};
413
bsalomonac3aa242016-08-19 11:25:19 -0700414class SkDrawArcCommand : public SkDrawCommand {
415public:
416 SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
417 const SkPaint& paint);
418 void execute(SkCanvas* canvas) const override;
419 bool render(SkCanvas* canvas) const override;
420 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
421 static SkDrawArcCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
422
423private:
424 SkRect fOval;
425 SkScalar fStartAngle;
426 SkScalar fSweepAngle;
427 bool fUseCenter;
428 SkPaint fPaint;
429
430 typedef SkDrawCommand INHERITED;
431};
432
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000433class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000434public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000435 SkDrawPaintCommand(const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700436 void execute(SkCanvas* canvas) const override;
437 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800438 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
439 static SkDrawPaintCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800440
chudy@google.com902ebe52012-06-29 14:21:22 +0000441private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000442 SkPaint fPaint;
443
444 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000445};
446
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000447class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000448public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000449 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700450 void execute(SkCanvas* canvas) const override;
451 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800452 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
453 static SkDrawPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000454
chudy@google.com902ebe52012-06-29 14:21:22 +0000455private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000456 SkPath fPath;
457 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000458
459 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000460};
461
fmalita160ebb22015-04-01 20:58:37 -0700462class SkBeginDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000463public:
fmalita160ebb22015-04-01 20:58:37 -0700464 SkBeginDrawPictureCommand(const SkPicture* picture,
465 const SkMatrix* matrix,
466 const SkPaint* paint);
467
mtklein36352bf2015-03-25 18:17:31 -0700468 void execute(SkCanvas* canvas) const override;
469 bool render(SkCanvas* canvas) const override;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000470
chudy@google.com902ebe52012-06-29 14:21:22 +0000471private:
Hal Canary1b612a82016-11-03 16:26:13 -0400472 sk_sp<const SkPicture> fPicture;
473 SkTLazy<SkMatrix> fMatrix;
474 SkTLazy<SkPaint> fPaint;
fmalita160ebb22015-04-01 20:58:37 -0700475
476 typedef SkDrawCommand INHERITED;
477};
478
479class SkEndDrawPictureCommand : public SkDrawCommand {
480public:
481 SkEndDrawPictureCommand(bool restore);
482
483 void execute(SkCanvas* canvas) const override;
484
485private:
486 bool fRestore;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000487
488 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000489};
490
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000491class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000492public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000493 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000494 const SkPaint& paint);
Brian Salomond3b65972017-03-22 12:05:03 -0400495 ~SkDrawPointsCommand() override { delete [] fPts; }
mtklein36352bf2015-03-25 18:17:31 -0700496 void execute(SkCanvas* canvas) const override;
497 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800498 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
499 static SkDrawPointsCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800500
chudy@google.com902ebe52012-06-29 14:21:22 +0000501private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000502 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000503 size_t fCount;
504 SkPoint* fPts;
505 SkPaint fPaint;
506
507 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000508};
509
Brian Osmanc25e2692018-03-12 10:57:28 -0400510class SkDrawRegionCommand : public SkDrawCommand {
511public:
512 SkDrawRegionCommand(const SkRegion& region, const SkPaint& paint);
513 void execute(SkCanvas* canvas) const override;
514 bool render(SkCanvas* canvas) const override;
515 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
516 static SkDrawRegionCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
517
518private:
519 SkRegion fRegion;
520 SkPaint fPaint;
521
522 typedef SkDrawCommand INHERITED;
523};
524
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000525class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000526public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000527 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000528 const SkPaint& paint);
Brian Salomond3b65972017-03-22 12:05:03 -0400529 ~SkDrawTextCommand() override { delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700530 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800531 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
532 static SkDrawTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800533
chudy@google.com902ebe52012-06-29 14:21:22 +0000534private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000535 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000536 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000537 SkScalar fX;
538 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000539 SkPaint fPaint;
540
541 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000542};
543
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000544class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000545public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000546 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
547 const SkPaint& paint);
Brian Salomond3b65972017-03-22 12:05:03 -0400548 ~SkDrawPosTextCommand() override { delete [] fPos; delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700549 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800550 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
551 static SkDrawPosTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800552
chudy@google.com902ebe52012-06-29 14:21:22 +0000553private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000554 char* fText;
555 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000556 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000557 SkPaint fPaint;
558
559 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000560};
561
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000562class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000563public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000564 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
565 const SkMatrix* matrix, const SkPaint& paint);
Brian Salomond3b65972017-03-22 12:05:03 -0400566 ~SkDrawTextOnPathCommand() override { delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700567 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800568 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
569 static SkDrawTextOnPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800570
chudy@google.com902ebe52012-06-29 14:21:22 +0000571private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000572 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000573 size_t fByteLength;
574 SkPath fPath;
575 SkMatrix fMatrix;
576 SkPaint fPaint;
577
578 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000579};
580
reed45561a02016-07-07 12:47:17 -0700581class SkDrawTextRSXformCommand : public SkDrawCommand {
582public:
583 SkDrawTextRSXformCommand(const void* text, size_t byteLength, const SkRSXform[],
584 const SkRect*, const SkPaint& paint);
585 ~SkDrawTextRSXformCommand() override { delete[] fText; delete[] fXform; }
586 void execute(SkCanvas* canvas) const override;
587 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
588 static SkDrawTextRSXformCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
589
590private:
591 char* fText;
592 size_t fByteLength;
593 SkRSXform* fXform;
594 SkRect* fCull;
595 SkRect fCullStorage;
596 SkPaint fPaint;
597
598 typedef SkDrawCommand INHERITED;
599};
600
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000601class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000602public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000603 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
604 SkScalar constY, const SkPaint& paint);
Brian Salomond3b65972017-03-22 12:05:03 -0400605 ~SkDrawPosTextHCommand() override { delete [] fXpos; delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700606 void execute(SkCanvas* canvas) const override;
bungeman51190df2016-03-09 07:42:54 -0800607 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
608 static SkDrawPosTextHCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800609
chudy@google.com902ebe52012-06-29 14:21:22 +0000610private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000611 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000612 char* fText;
613 size_t fByteLength;
614 SkScalar fConstY;
615 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000616
617 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000618};
619
fmalitab7425172014-08-26 07:56:44 -0700620class SkDrawTextBlobCommand : public SkDrawCommand {
621public:
fmalita37283c22016-09-13 10:00:23 -0700622 SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y, const SkPaint& paint);
fmalitab7425172014-08-26 07:56:44 -0700623
mtklein36352bf2015-03-25 18:17:31 -0700624 void execute(SkCanvas* canvas) const override;
625 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800626 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
627 static SkDrawTextBlobCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
fmalitab7425172014-08-26 07:56:44 -0700628
629private:
fmalita37283c22016-09-13 10:00:23 -0700630 sk_sp<SkTextBlob> fBlob;
631 SkScalar fXPos;
632 SkScalar fYPos;
633 SkPaint fPaint;
fmalitab7425172014-08-26 07:56:44 -0700634
635 typedef SkDrawCommand INHERITED;
636};
637
robertphillips9bafc302015-02-13 11:13:00 -0800638class SkDrawPatchCommand : public SkDrawCommand {
639public:
640 SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
Mike Reed7d954ad2016-10-28 15:42:34 -0400641 const SkPoint texCoords[4], SkBlendMode bmode,
robertphillips9bafc302015-02-13 11:13:00 -0800642 const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700643 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800644 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
645 static SkDrawPatchCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips9bafc302015-02-13 11:13:00 -0800646
647private:
648 SkPoint fCubics[12];
ethannicholas1446a9a2016-02-10 14:05:02 -0800649 SkColor* fColorsPtr;
650 SkColor fColors[4];
651 SkPoint* fTexCoordsPtr;
652 SkPoint fTexCoords[4];
Mike Reed7d954ad2016-10-28 15:42:34 -0400653 SkBlendMode fBlendMode;
robertphillips9bafc302015-02-13 11:13:00 -0800654 SkPaint fPaint;
655
656 typedef SkDrawCommand INHERITED;
657};
658
659
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000660class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000661public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000662 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700663 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800664 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
665 static SkDrawRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000666
robertphillips@google.com91217d02013-03-17 18:33:46 +0000667 const SkRect& rect() const { return fRect; }
668 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000669private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000670 SkRect fRect;
671 SkPaint fPaint;
672
673 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000674};
675
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000676class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000677public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000678 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700679 void execute(SkCanvas* canvas) const override;
680 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800681 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
682 static SkDrawRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800683
robertphillips@google.com67baba42013-01-02 20:20:31 +0000684private:
685 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000686 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000687
688 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000689};
690
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000691class SkDrawDRRectCommand : public SkDrawCommand {
692public:
693 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
694 const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700695 void execute(SkCanvas* canvas) const override;
696 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800697 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
698 static SkDrawDRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800699
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000700private:
701 SkRRect fOuter;
702 SkRRect fInner;
703 SkPaint fPaint;
704
705 typedef SkDrawCommand INHERITED;
706};
707
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000708class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000709public:
Mike Reedfed9cfd2017-03-17 12:09:04 -0400710 SkDrawVerticesCommand(sk_sp<SkVertices>, SkBlendMode, const SkPaint&);
711
mtklein36352bf2015-03-25 18:17:31 -0700712 void execute(SkCanvas* canvas) const override;
ethannicholas50a8dd02016-02-10 05:40:46 -0800713
chudy@google.com902ebe52012-06-29 14:21:22 +0000714private:
Mike Reedfed9cfd2017-03-17 12:09:04 -0400715 sk_sp<SkVertices> fVertices;
716 SkBlendMode fBlendMode;
717 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000718
719 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000720};
721
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000722class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000723public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400724 SkSaveCommand();
mtklein36352bf2015-03-25 18:17:31 -0700725 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800726 static SkSaveCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800727
chudy@google.com902ebe52012-06-29 14:21:22 +0000728private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000729 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000730};
731
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000732class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000733public:
reed4960eee2015-12-18 07:09:18 -0800734 SkSaveLayerCommand(const SkCanvas::SaveLayerRec&);
Brian Salomond3b65972017-03-22 12:05:03 -0400735 ~SkSaveLayerCommand() override;
mtklein36352bf2015-03-25 18:17:31 -0700736 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800737 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
738 static SkSaveLayerCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000739
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000740 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000741
chudy@google.com902ebe52012-06-29 14:21:22 +0000742private:
ethannicholas50a8dd02016-02-10 05:40:46 -0800743 SkRect fBounds;
744 SkPaint fPaint;
745 SkPaint* fPaintPtr;
746 const SkImageFilter* fBackdrop;
747 uint32_t fSaveLayerFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000748
749 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000750};
751
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000752class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000753public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000754 SkSetMatrixCommand(const SkMatrix& matrix);
mtklein36352bf2015-03-25 18:17:31 -0700755 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800756 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
757 static SkSetMatrixCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800758
chudy@google.com902ebe52012-06-29 14:21:22 +0000759private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000760 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000761
762 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000763};
chudy@google.com902ebe52012-06-29 14:21:22 +0000764#endif
vjiaoblacke6f5d562016-08-25 06:30:23 -0700765