blob: df50be8fdcdae02c6ead319f5af3444001c21f31 [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
ethannicholasf67531f2016-03-21 10:19:39 -070011#include "png.h"
12
chudy@google.com902ebe52012-06-29 14:21:22 +000013#include "SkCanvas.h"
bungemand3ebb482015-08-05 13:57:49 -070014#include "SkTLazy.h"
15#include "SkPath.h"
16#include "SkRRect.h"
reed45561a02016-07-07 12:47:17 -070017#include "SkRSXform.h"
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000018#include "SkString.h"
bungemand3ebb482015-08-05 13:57:49 -070019#include "SkTDArray.h"
ethannicholas50a8dd02016-02-10 05:40:46 -080020#include "SkJSONCPP.h"
ethannicholasf62a8b72016-02-11 10:35:21 -080021#include "UrlDataManager.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000022
fmalita@google.com86681b32013-06-13 20:59:14 +000023class SK_API SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000024public:
robertphillips9bafc302015-02-13 11:13:00 -080025 enum OpType {
fmalita160ebb22015-04-01 20:58:37 -070026 kBeginDrawPicture_OpType,
vjiaoblack95302da2016-07-21 10:25:54 -070027 kBeginDrawShadowedPicture_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080028 kClipPath_OpType,
29 kClipRegion_OpType,
30 kClipRect_OpType,
31 kClipRRect_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080032 kConcat_OpType,
reed97660cc2016-06-28 18:54:19 -070033 kDrawAnnotation_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080034 kDrawBitmap_OpType,
35 kDrawBitmapNine_OpType,
36 kDrawBitmapRect_OpType,
37 kDrawClear_OpType,
38 kDrawDRRect_OpType,
fmalita651c9202015-07-22 10:23:01 -070039 kDrawImage_OpType,
40 kDrawImageRect_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080041 kDrawOval_OpType,
42 kDrawPaint_OpType,
43 kDrawPatch_OpType,
44 kDrawPath_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080045 kDrawPoints_OpType,
46 kDrawPosText_OpType,
47 kDrawPosTextH_OpType,
48 kDrawRect_OpType,
49 kDrawRRect_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080050 kDrawText_OpType,
51 kDrawTextBlob_OpType,
52 kDrawTextOnPath_OpType,
reed45561a02016-07-07 12:47:17 -070053 kDrawTextRSXform_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080054 kDrawVertices_OpType,
fmalita160ebb22015-04-01 20:58:37 -070055 kEndDrawPicture_OpType,
vjiaoblack95302da2016-07-21 10:25:54 -070056 kEndDrawShadowedPicture_OpType,
robertphillips9bafc302015-02-13 11:13:00 -080057 kRestore_OpType,
58 kSave_OpType,
59 kSaveLayer_OpType,
60 kSetMatrix_OpType,
vjiaoblacke5de1302016-07-13 14:05:28 -070061 kTranslateZ_OpType,
robertphillips72942b82015-02-12 06:37:12 -080062
vjiaoblacke5de1302016-07-13 14:05:28 -070063 kLast_OpType = kTranslateZ_OpType
robertphillips9bafc302015-02-13 11:13:00 -080064 };
65
66 static const int kOpTypeCount = kLast_OpType + 1;
67
halcanary9d524f22016-03-29 09:03:52 -070068 static void WritePNG(const png_bytep rgba, png_uint_32 width, png_uint_32 height,
msaretta5cf4f42016-06-30 10:06:51 -070069 SkWStream& out, bool isOpaque);
ethannicholasf67531f2016-03-21 10:19:39 -070070
robertphillips9bafc302015-02-13 11:13:00 -080071 SkDrawCommand(OpType opType);
chudy@google.com902ebe52012-06-29 14:21:22 +000072
73 virtual ~SkDrawCommand();
74
fmalita8c89c522014-11-08 16:18:56 -080075 virtual SkString toString() const;
chudy@google.com902ebe52012-06-29 14:21:22 +000076
fmalita8c89c522014-11-08 16:18:56 -080077 virtual const char* toCString() const {
robertphillips9bafc302015-02-13 11:13:00 -080078 return GetCommandString(fOpType);
chudy@google.com902ebe52012-06-29 14:21:22 +000079 }
80
chudy@google.com0b5bbb02012-07-31 19:55:32 +000081 bool isVisible() const {
82 return fVisible;
83 }
84
85 void setVisible(bool toggle) {
86 fVisible = toggle;
87 }
chudy@google.com902ebe52012-06-29 14:21:22 +000088
fmalita8c89c522014-11-08 16:18:56 -080089 const SkTDArray<SkString*>* Info() const { return &fInfo; }
90 virtual void execute(SkCanvas*) const = 0;
91 virtual void vizExecute(SkCanvas*) const {}
robertphillips70171682014-10-16 14:28:28 -070092
fmalita8c89c522014-11-08 16:18:56 -080093 virtual void setUserMatrix(const SkMatrix&) {}
robertphillips70171682014-10-16 14:28:28 -070094
mtkleinf0f14112014-12-12 08:46:25 -080095 // The next "active" system is only used by save, saveLayer, and restore.
96 // It is used to determine which saveLayers are currently active (at a
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000097 // given point in the rendering).
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000098 // saves just return a kPushLayer action but don't track active state
99 // restores just return a kPopLayer action
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000100 // saveLayers return kPushLayer but also track the active state
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000101 enum Action {
102 kNone_Action,
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000103 kPopLayer_Action,
104 kPushLayer_Action,
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000105 };
106 virtual Action action() const { return kNone_Action; }
107 virtual void setActive(bool active) {}
108 virtual bool active() const { return false; }
109
robertphillips9bafc302015-02-13 11:13:00 -0800110 OpType getType() const { return fOpType; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000111
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000112 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000113
ethannicholasf62a8b72016-02-11 10:35:21 -0800114 virtual Json::Value toJSON(UrlDataManager& urlDataManager) const;
ethannicholas50a8dd02016-02-10 05:40:46 -0800115
116 /* Converts a JSON representation of a command into a newly-allocated SkDrawCommand object. It
117 * is the caller's responsibility to delete this object. This method may return null if an error
118 * occurs.
119 */
ethannicholasf62a8b72016-02-11 10:35:21 -0800120 static SkDrawCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800121
robertphillips9bafc302015-02-13 11:13:00 -0800122 static const char* GetCommandString(OpType type);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000123
joshualittbd724132016-03-03 11:39:38 -0800124 // Helper methods for converting things to JSON
brianosmanfad98562016-05-04 11:06:28 -0700125 static Json::Value MakeJsonColor(const SkColor color);
brianosman97bbf822016-09-25 13:15:58 -0700126 static Json::Value MakeJsonColor4f(const SkColor4f& color);
brianosmanfad98562016-05-04 11:06:28 -0700127 static Json::Value MakeJsonPoint(const SkPoint& point);
128 static Json::Value MakeJsonPoint(SkScalar x, SkScalar y);
129 static Json::Value MakeJsonRect(const SkRect& rect);
joshualittbd724132016-03-03 11:39:38 -0800130 static Json::Value MakeJsonIRect(const SkIRect&);
131 static Json::Value MakeJsonMatrix(const SkMatrix&);
vjiaoblacke5de1302016-07-13 14:05:28 -0700132 static Json::Value MakeJsonScalar(SkScalar);
brianosmanfad98562016-05-04 11:06:28 -0700133 static Json::Value MakeJsonPath(const SkPath& path);
134 static Json::Value MakeJsonRegion(const SkRegion& region);
135 static Json::Value MakeJsonPaint(const SkPaint& paint, UrlDataManager& urlDataManager);
136
137 static void flatten(const SkFlattenable* flattenable, Json::Value* target,
138 UrlDataManager& urlDataManager);
139 static bool flatten(const SkImage& image, Json::Value* target,
140 UrlDataManager& urlDataManager);
141 static bool flatten(const SkBitmap& bitmap, Json::Value* target,
142 UrlDataManager& urlDataManager);
joshualittbd724132016-03-03 11:39:38 -0800143
chudy@google.com902ebe52012-06-29 14:21:22 +0000144protected:
chudy@google.com97cee972012-08-07 20:41:37 +0000145 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +0000146
147private:
robertphillips9bafc302015-02-13 11:13:00 -0800148 OpType fOpType;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000149 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +0000150};
151
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000152class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000153public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000154 SkRestoreCommand();
mtklein36352bf2015-03-25 18:17:31 -0700155 void execute(SkCanvas* canvas) const override;
156 Action action() const override { return kPopLayer_Action; }
ethannicholasf62a8b72016-02-11 10:35:21 -0800157 static SkRestoreCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000158
159private:
160 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000161};
162
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000163class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000164public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000165 SkClearCommand(SkColor color);
mtklein36352bf2015-03-25 18:17:31 -0700166 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800167 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
168 static SkClearCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800169
chudy@google.com902ebe52012-06-29 14:21:22 +0000170private:
171 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000172
173 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000174};
175
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000176class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000177public:
reed73603f32016-09-20 08:42:38 -0700178 SkClipPathCommand(const SkPath& path, SkCanvas::ClipOp op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700179 void execute(SkCanvas* canvas) const override;
180 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800181 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
182 static SkClipPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800183
chudy@google.com902ebe52012-06-29 14:21:22 +0000184private:
reed73603f32016-09-20 08:42:38 -0700185 SkPath fPath;
186 SkCanvas::ClipOp fOp;
187 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000188
189 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000190};
191
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000192class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000193public:
reed73603f32016-09-20 08:42:38 -0700194 SkClipRegionCommand(const SkRegion& region, SkCanvas::ClipOp op);
mtklein36352bf2015-03-25 18:17:31 -0700195 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800196 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
197 static SkClipRegionCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800198
chudy@google.com902ebe52012-06-29 14:21:22 +0000199private:
reed73603f32016-09-20 08:42:38 -0700200 SkRegion fRegion;
201 SkCanvas::ClipOp fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000202
203 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000204};
205
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000206class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000207public:
reed73603f32016-09-20 08:42:38 -0700208 SkClipRectCommand(const SkRect& rect, SkCanvas::ClipOp op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700209 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800210 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
211 static SkClipRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000212
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000213 const SkRect& rect() const { return fRect; }
reed73603f32016-09-20 08:42:38 -0700214 SkCanvas::ClipOp op() const { return fOp; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000215 bool doAA() const { return fDoAA; }
216
chudy@google.com902ebe52012-06-29 14:21:22 +0000217private:
reed73603f32016-09-20 08:42:38 -0700218 SkRect fRect;
219 SkCanvas::ClipOp fOp;
220 bool fDoAA;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000221
222 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000223};
224
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000225class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000226public:
reed73603f32016-09-20 08:42:38 -0700227 SkClipRRectCommand(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700228 void execute(SkCanvas* canvas) const override;
229 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800230 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
231 static SkClipRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000232
233 const SkRRect& rrect() const { return fRRect; }
reed73603f32016-09-20 08:42:38 -0700234 SkCanvas::ClipOp op() const { return fOp; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000235 bool doAA() const { return fDoAA; }
236
robertphillips@google.com67baba42013-01-02 20:20:31 +0000237private:
reed73603f32016-09-20 08:42:38 -0700238 SkRRect fRRect;
239 SkCanvas::ClipOp fOp;
240 bool fDoAA;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000241
242 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000243};
244
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000245class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000246public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000247 SkConcatCommand(const SkMatrix& matrix);
mtklein36352bf2015-03-25 18:17:31 -0700248 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800249 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
250 static SkConcatCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800251
chudy@google.com902ebe52012-06-29 14:21:22 +0000252private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000253 SkMatrix fMatrix;
254
255 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000256};
257
reed97660cc2016-06-28 18:54:19 -0700258class SkDrawAnnotationCommand : public SkDrawCommand {
259public:
260 SkDrawAnnotationCommand(const SkRect&, const char key[], sk_sp<SkData> value);
261 void execute(SkCanvas* canvas) const override;
262 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
263 static SkDrawAnnotationCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
264
265private:
266 SkRect fRect;
267 SkString fKey;
268 sk_sp<SkData> fValue;
269
270 typedef SkDrawCommand INHERITED;
271};
272
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000273class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000274public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000275 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000276 const SkPaint* paint);
mtklein36352bf2015-03-25 18:17:31 -0700277 void execute(SkCanvas* canvas) const override;
278 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800279 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
280 static SkDrawBitmapCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800281
chudy@google.com902ebe52012-06-29 14:21:22 +0000282private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000283 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000284 SkScalar fLeft;
285 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000286 SkPaint fPaint;
287 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000288
289 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000290};
291
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000292class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000293public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000294 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000295 const SkRect& dst, const SkPaint* paint);
mtklein36352bf2015-03-25 18:17:31 -0700296 void execute(SkCanvas* canvas) const override;
297 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800298 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
299 static SkDrawBitmapNineCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800300
chudy@google.com902ebe52012-06-29 14:21:22 +0000301private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000302 SkBitmap fBitmap;
303 SkIRect fCenter;
304 SkRect fDst;
305 SkPaint fPaint;
306 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000307
308 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000309};
310
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000311class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000312public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000313 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000314 const SkRect& dst, const SkPaint* paint,
reeda5517e22015-07-14 10:54:12 -0700315 SkCanvas::SrcRectConstraint);
mtklein36352bf2015-03-25 18:17:31 -0700316 void execute(SkCanvas* canvas) const override;
317 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800318 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
319 static SkDrawBitmapRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000320
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000321 const SkBitmap& bitmap() const { return fBitmap; }
322
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000323 // The non-const 'paint' method allows modification of this object's
324 // SkPaint. For this reason the ctor and setPaint method make a local copy.
325 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
326 // (since only an SkPaint* is passed into the ctor).
327 const SkPaint* paint() const { return fPaintPtr; }
328 SkPaint* paint() { return fPaintPtr; }
329
330 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
331
halcanary96fcdcc2015-08-27 07:41:13 -0700332 const SkRect* srcRect() const { return fSrc.isEmpty() ? nullptr : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000333 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000334
335 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000336 void setDstRect(const SkRect& dst) { fDst = dst; }
337
reeda5517e22015-07-14 10:54:12 -0700338 SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
339 void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000340
chudy@google.com902ebe52012-06-29 14:21:22 +0000341private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000342 SkBitmap fBitmap;
343 SkRect fSrc;
344 SkRect fDst;
345 SkPaint fPaint;
346 SkPaint* fPaintPtr;
reeda5517e22015-07-14 10:54:12 -0700347 SkCanvas::SrcRectConstraint fConstraint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000348
349 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000350};
351
fmalita651c9202015-07-22 10:23:01 -0700352class SkDrawImageCommand : public SkDrawCommand {
353public:
354 SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);
355 void execute(SkCanvas* canvas) const override;
356 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800357 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
358 static SkDrawImageCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800359
fmalita651c9202015-07-22 10:23:01 -0700360private:
361 SkAutoTUnref<const SkImage> fImage;
362 SkScalar fLeft;
363 SkScalar fTop;
364 SkTLazy<SkPaint> fPaint;
365
366 typedef SkDrawCommand INHERITED;
367};
368
369class SkDrawImageRectCommand : public SkDrawCommand {
370public:
371 SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect& dst,
372 const SkPaint* paint, SkCanvas::SrcRectConstraint constraint);
373 void execute(SkCanvas* canvas) const override;
374 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800375 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
376 static SkDrawImageRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800377
fmalita651c9202015-07-22 10:23:01 -0700378private:
379 SkAutoTUnref<const SkImage> fImage;
380 SkTLazy<SkRect> fSrc;
381 SkRect fDst;
382 SkTLazy<SkPaint> fPaint;
383 SkCanvas::SrcRectConstraint fConstraint;
384
385 typedef SkDrawCommand INHERITED;
386};
387
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000388class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000389public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000390 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700391 void execute(SkCanvas* canvas) const override;
392 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800393 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
394 static SkDrawOvalCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800395
robertphillips@google.com67baba42013-01-02 20:20:31 +0000396private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000397 SkRect fOval;
398 SkPaint fPaint;
399
400 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000401};
402
bsalomonac3aa242016-08-19 11:25:19 -0700403class SkDrawArcCommand : public SkDrawCommand {
404public:
405 SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
406 const SkPaint& paint);
407 void execute(SkCanvas* canvas) const override;
408 bool render(SkCanvas* canvas) const override;
409 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
410 static SkDrawArcCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
411
412private:
413 SkRect fOval;
414 SkScalar fStartAngle;
415 SkScalar fSweepAngle;
416 bool fUseCenter;
417 SkPaint fPaint;
418
419 typedef SkDrawCommand INHERITED;
420};
421
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000422class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000423public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000424 SkDrawPaintCommand(const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700425 void execute(SkCanvas* canvas) const override;
426 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800427 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
428 static SkDrawPaintCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800429
chudy@google.com902ebe52012-06-29 14:21:22 +0000430private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000431 SkPaint fPaint;
432
433 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000434};
435
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000436class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000437public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000438 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700439 void execute(SkCanvas* canvas) const override;
440 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800441 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
442 static SkDrawPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000443
chudy@google.com902ebe52012-06-29 14:21:22 +0000444private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000445 SkPath fPath;
446 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000447
448 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000449};
450
fmalita160ebb22015-04-01 20:58:37 -0700451class SkBeginDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000452public:
fmalita160ebb22015-04-01 20:58:37 -0700453 SkBeginDrawPictureCommand(const SkPicture* picture,
454 const SkMatrix* matrix,
455 const SkPaint* paint);
456
mtklein36352bf2015-03-25 18:17:31 -0700457 void execute(SkCanvas* canvas) const override;
458 bool render(SkCanvas* canvas) const override;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000459
chudy@google.com902ebe52012-06-29 14:21:22 +0000460private:
robertphillips9b14f262014-06-04 05:40:44 -0700461 SkAutoTUnref<const SkPicture> fPicture;
fmalita160ebb22015-04-01 20:58:37 -0700462 SkTLazy<SkMatrix> fMatrix;
463 SkTLazy<SkPaint> fPaint;
464
465 typedef SkDrawCommand INHERITED;
466};
467
468class SkEndDrawPictureCommand : public SkDrawCommand {
469public:
470 SkEndDrawPictureCommand(bool restore);
471
472 void execute(SkCanvas* canvas) const override;
473
474private:
475 bool fRestore;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000476
477 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000478};
479
vjiaoblack95302da2016-07-21 10:25:54 -0700480class SkBeginDrawShadowedPictureCommand : public SkDrawCommand {
481public:
482 SkBeginDrawShadowedPictureCommand(const SkPicture* picture,
483 const SkMatrix* matrix,
vjiaoblacke6f5d562016-08-25 06:30:23 -0700484 const SkPaint* paint,
485 const SkShadowParams& params);
vjiaoblack95302da2016-07-21 10:25:54 -0700486
487 void execute(SkCanvas* canvas) const override;
488 bool render(SkCanvas* canvas) const override;
489
490private:
491 SkAutoTUnref<const SkPicture> fPicture;
492 SkTLazy<SkMatrix> fMatrix;
493 SkTLazy<SkPaint> fPaint;
vjiaoblacke6f5d562016-08-25 06:30:23 -0700494#ifdef SK_EXPERIMENTAL_SHADOWING
495 SkShadowParams fShadowParams;
496#endif
vjiaoblack95302da2016-07-21 10:25:54 -0700497
498 typedef SkDrawCommand INHERITED;
499};
500
501class SkEndDrawShadowedPictureCommand : public SkDrawCommand {
502public:
503 SkEndDrawShadowedPictureCommand(bool restore);
504
505 void execute(SkCanvas* canvas) const override;
506
507private:
508 bool fRestore;
509
510 typedef SkDrawCommand INHERITED;
511};
512
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000513class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000514public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000515 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000516 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000517 virtual ~SkDrawPointsCommand() { delete [] fPts; }
mtklein36352bf2015-03-25 18:17:31 -0700518 void execute(SkCanvas* canvas) const override;
519 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800520 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
521 static SkDrawPointsCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800522
chudy@google.com902ebe52012-06-29 14:21:22 +0000523private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000524 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000525 size_t fCount;
526 SkPoint* fPts;
527 SkPaint fPaint;
528
529 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000530};
531
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000532class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000533public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000534 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000535 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000536 virtual ~SkDrawTextCommand() { delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700537 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800538 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
539 static SkDrawTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800540
chudy@google.com902ebe52012-06-29 14:21:22 +0000541private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000542 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000543 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000544 SkScalar fX;
545 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000546 SkPaint fPaint;
547
548 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000549};
550
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000551class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000552public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000553 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
554 const SkPaint& paint);
555 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700556 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800557 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
558 static SkDrawPosTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800559
chudy@google.com902ebe52012-06-29 14:21:22 +0000560private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000561 char* fText;
562 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000563 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000564 SkPaint fPaint;
565
566 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000567};
568
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000569class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000570public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000571 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
572 const SkMatrix* matrix, const SkPaint& paint);
573 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700574 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800575 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
576 static SkDrawTextOnPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800577
chudy@google.com902ebe52012-06-29 14:21:22 +0000578private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000579 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000580 size_t fByteLength;
581 SkPath fPath;
582 SkMatrix fMatrix;
583 SkPaint fPaint;
584
585 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000586};
587
reed45561a02016-07-07 12:47:17 -0700588class SkDrawTextRSXformCommand : public SkDrawCommand {
589public:
590 SkDrawTextRSXformCommand(const void* text, size_t byteLength, const SkRSXform[],
591 const SkRect*, const SkPaint& paint);
592 ~SkDrawTextRSXformCommand() override { delete[] fText; delete[] fXform; }
593 void execute(SkCanvas* canvas) const override;
594 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
595 static SkDrawTextRSXformCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
596
597private:
598 char* fText;
599 size_t fByteLength;
600 SkRSXform* fXform;
601 SkRect* fCull;
602 SkRect fCullStorage;
603 SkPaint fPaint;
604
605 typedef SkDrawCommand INHERITED;
606};
607
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000608class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000609public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000610 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
611 SkScalar constY, const SkPaint& paint);
612 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700613 void execute(SkCanvas* canvas) const override;
bungeman51190df2016-03-09 07:42:54 -0800614 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
615 static SkDrawPosTextHCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800616
chudy@google.com902ebe52012-06-29 14:21:22 +0000617private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000618 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000619 char* fText;
620 size_t fByteLength;
621 SkScalar fConstY;
622 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000623
624 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000625};
626
fmalitab7425172014-08-26 07:56:44 -0700627class SkDrawTextBlobCommand : public SkDrawCommand {
628public:
fmalita37283c22016-09-13 10:00:23 -0700629 SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y, const SkPaint& paint);
fmalitab7425172014-08-26 07:56:44 -0700630
mtklein36352bf2015-03-25 18:17:31 -0700631 void execute(SkCanvas* canvas) const override;
632 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800633 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
634 static SkDrawTextBlobCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
fmalitab7425172014-08-26 07:56:44 -0700635
636private:
fmalita37283c22016-09-13 10:00:23 -0700637 sk_sp<SkTextBlob> fBlob;
638 SkScalar fXPos;
639 SkScalar fYPos;
640 SkPaint fPaint;
fmalitab7425172014-08-26 07:56:44 -0700641
642 typedef SkDrawCommand INHERITED;
643};
644
robertphillips9bafc302015-02-13 11:13:00 -0800645class SkDrawPatchCommand : public SkDrawCommand {
646public:
647 SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
648 const SkPoint texCoords[4], SkXfermode* xmode,
649 const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700650 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800651 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
652 static SkDrawPatchCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips9bafc302015-02-13 11:13:00 -0800653
654private:
655 SkPoint fCubics[12];
ethannicholas1446a9a2016-02-10 14:05:02 -0800656 SkColor* fColorsPtr;
657 SkColor fColors[4];
658 SkPoint* fTexCoordsPtr;
659 SkPoint fTexCoords[4];
robertphillips9bafc302015-02-13 11:13:00 -0800660 SkAutoTUnref<SkXfermode> fXfermode;
661 SkPaint fPaint;
662
663 typedef SkDrawCommand INHERITED;
664};
665
666
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000667class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000668public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000669 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700670 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800671 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
672 static SkDrawRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000673
robertphillips@google.com91217d02013-03-17 18:33:46 +0000674 const SkRect& rect() const { return fRect; }
675 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000676private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000677 SkRect fRect;
678 SkPaint fPaint;
679
680 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000681};
682
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000683class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000684public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000685 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700686 void execute(SkCanvas* canvas) const override;
687 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800688 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
689 static SkDrawRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800690
robertphillips@google.com67baba42013-01-02 20:20:31 +0000691private:
692 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000693 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000694
695 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000696};
697
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000698class SkDrawDRRectCommand : public SkDrawCommand {
699public:
700 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
701 const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700702 void execute(SkCanvas* canvas) const override;
703 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800704 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
705 static SkDrawDRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800706
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000707private:
708 SkRRect fOuter;
709 SkRRect fInner;
710 SkPaint fPaint;
711
712 typedef SkDrawCommand INHERITED;
713};
714
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000715class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000716public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000717 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
718 const SkPoint vertices[], const SkPoint texs[],
719 const SkColor colors[], SkXfermode* xfermode,
720 const uint16_t indices[], int indexCount,
721 const SkPaint& paint);
722 virtual ~SkDrawVerticesCommand();
mtklein36352bf2015-03-25 18:17:31 -0700723 void execute(SkCanvas* canvas) const override;
ethannicholas50a8dd02016-02-10 05:40:46 -0800724
chudy@google.com902ebe52012-06-29 14:21:22 +0000725private:
726 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000727 int fVertexCount;
728 SkPoint* fVertices;
729 SkPoint* fTexs;
730 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000731 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000732 uint16_t* fIndices;
733 int fIndexCount;
734 SkPaint fPaint;
735
736 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000737};
738
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000739class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000740public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400741 SkSaveCommand();
mtklein36352bf2015-03-25 18:17:31 -0700742 void execute(SkCanvas* canvas) const override;
743 Action action() const override { return kPushLayer_Action; }
ethannicholasf62a8b72016-02-11 10:35:21 -0800744 static SkSaveCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800745
chudy@google.com902ebe52012-06-29 14:21:22 +0000746private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000747 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000748};
749
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000750class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000751public:
reed4960eee2015-12-18 07:09:18 -0800752 SkSaveLayerCommand(const SkCanvas::SaveLayerRec&);
ethannicholas50a8dd02016-02-10 05:40:46 -0800753 virtual ~SkSaveLayerCommand();
mtklein36352bf2015-03-25 18:17:31 -0700754 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800755 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
756 static SkSaveLayerCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
mtklein36352bf2015-03-25 18:17:31 -0700757 void vizExecute(SkCanvas* canvas) const override;
758 Action action() const override{ return kPushLayer_Action; }
759 void setActive(bool active) override { fActive = active; }
760 bool active() const override { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000761
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000762 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000763
chudy@google.com902ebe52012-06-29 14:21:22 +0000764private:
ethannicholas50a8dd02016-02-10 05:40:46 -0800765 SkRect fBounds;
766 SkPaint fPaint;
767 SkPaint* fPaintPtr;
768 const SkImageFilter* fBackdrop;
769 uint32_t fSaveLayerFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000770
reed4960eee2015-12-18 07:09:18 -0800771 bool fActive;
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000772
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000773 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000774};
775
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000776class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000777public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000778 SkSetMatrixCommand(const SkMatrix& matrix);
mtklein36352bf2015-03-25 18:17:31 -0700779 void setUserMatrix(const SkMatrix&) override;
780 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800781 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
782 static SkSetMatrixCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800783
chudy@google.com902ebe52012-06-29 14:21:22 +0000784private:
robertphillips70171682014-10-16 14:28:28 -0700785 SkMatrix fUserMatrix;
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000786 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000787
788 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000789};
790
vjiaoblacke5de1302016-07-13 14:05:28 -0700791class SkTranslateZCommand : public SkDrawCommand {
792public:
793 SkTranslateZCommand(SkScalar);
794 void execute(SkCanvas* canvas) const override;
795 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
796 static SkTranslateZCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
797
798private:
799 SkScalar fZTranslate;
800
801 typedef SkDrawCommand INHERITED;
802};
chudy@google.com902ebe52012-06-29 14:21:22 +0000803#endif
vjiaoblacke6f5d562016-08-25 06:30:23 -0700804