blob: 07dd477f6a93620b6cbc4efe9b88f2ccf28eb481 [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);
126 static Json::Value MakeJsonPoint(const SkPoint& point);
127 static Json::Value MakeJsonPoint(SkScalar x, SkScalar y);
128 static Json::Value MakeJsonRect(const SkRect& rect);
joshualittbd724132016-03-03 11:39:38 -0800129 static Json::Value MakeJsonIRect(const SkIRect&);
130 static Json::Value MakeJsonMatrix(const SkMatrix&);
vjiaoblacke5de1302016-07-13 14:05:28 -0700131 static Json::Value MakeJsonScalar(SkScalar);
brianosmanfad98562016-05-04 11:06:28 -0700132 static Json::Value MakeJsonPath(const SkPath& path);
133 static Json::Value MakeJsonRegion(const SkRegion& region);
134 static Json::Value MakeJsonPaint(const SkPaint& paint, UrlDataManager& urlDataManager);
135
136 static void flatten(const SkFlattenable* flattenable, Json::Value* target,
137 UrlDataManager& urlDataManager);
138 static bool flatten(const SkImage& image, Json::Value* target,
139 UrlDataManager& urlDataManager);
140 static bool flatten(const SkBitmap& bitmap, Json::Value* target,
141 UrlDataManager& urlDataManager);
joshualittbd724132016-03-03 11:39:38 -0800142
chudy@google.com902ebe52012-06-29 14:21:22 +0000143protected:
chudy@google.com97cee972012-08-07 20:41:37 +0000144 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +0000145
146private:
robertphillips9bafc302015-02-13 11:13:00 -0800147 OpType fOpType;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000148 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +0000149};
150
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000151class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000152public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000153 SkRestoreCommand();
mtklein36352bf2015-03-25 18:17:31 -0700154 void execute(SkCanvas* canvas) const override;
155 Action action() const override { return kPopLayer_Action; }
ethannicholasf62a8b72016-02-11 10:35:21 -0800156 static SkRestoreCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000157
158private:
159 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000160};
161
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000162class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000163public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000164 SkClearCommand(SkColor color);
mtklein36352bf2015-03-25 18:17:31 -0700165 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800166 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
167 static SkClearCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800168
chudy@google.com902ebe52012-06-29 14:21:22 +0000169private:
170 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000171
172 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000173};
174
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000175class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000176public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000177 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700178 void execute(SkCanvas* canvas) const override;
179 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800180 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
181 static SkClipPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800182
chudy@google.com902ebe52012-06-29 14:21:22 +0000183private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000184 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +0000185 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000186 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000187
188 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000189};
190
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000191class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000192public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000193 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
mtklein36352bf2015-03-25 18:17:31 -0700194 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800195 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
196 static SkClipRegionCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800197
chudy@google.com902ebe52012-06-29 14:21:22 +0000198private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000199 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +0000200 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000201
202 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000203};
204
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000205class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000206public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000207 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700208 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800209 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
210 static SkClipRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000211
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000212 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000213 SkRegion::Op op() const { return fOp; }
214 bool doAA() const { return fDoAA; }
215
chudy@google.com902ebe52012-06-29 14:21:22 +0000216private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000217 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000218 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000219 bool fDoAA;
220
221 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000222};
223
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000224class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000225public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000226 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
mtklein36352bf2015-03-25 18:17:31 -0700227 void execute(SkCanvas* canvas) const override;
228 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800229 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
230 static SkClipRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000231
232 const SkRRect& rrect() const { return fRRect; }
233 SkRegion::Op op() const { return fOp; }
234 bool doAA() const { return fDoAA; }
235
robertphillips@google.com67baba42013-01-02 20:20:31 +0000236private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000237 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000238 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000239 bool fDoAA;
240
241 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000242};
243
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000244class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000245public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000246 SkConcatCommand(const SkMatrix& matrix);
mtklein36352bf2015-03-25 18:17:31 -0700247 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800248 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
249 static SkConcatCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800250
chudy@google.com902ebe52012-06-29 14:21:22 +0000251private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000252 SkMatrix fMatrix;
253
254 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000255};
256
reed97660cc2016-06-28 18:54:19 -0700257class SkDrawAnnotationCommand : public SkDrawCommand {
258public:
259 SkDrawAnnotationCommand(const SkRect&, const char key[], sk_sp<SkData> value);
260 void execute(SkCanvas* canvas) const override;
261 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
262 static SkDrawAnnotationCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
263
264private:
265 SkRect fRect;
266 SkString fKey;
267 sk_sp<SkData> fValue;
268
269 typedef SkDrawCommand INHERITED;
270};
271
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000272class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000273public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000274 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000275 const SkPaint* paint);
mtklein36352bf2015-03-25 18:17:31 -0700276 void execute(SkCanvas* canvas) const override;
277 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800278 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
279 static SkDrawBitmapCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800280
chudy@google.com902ebe52012-06-29 14:21:22 +0000281private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000282 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000283 SkScalar fLeft;
284 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000285 SkPaint fPaint;
286 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000287
288 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000289};
290
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000291class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000292public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000293 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000294 const SkRect& dst, const SkPaint* paint);
mtklein36352bf2015-03-25 18:17:31 -0700295 void execute(SkCanvas* canvas) const override;
296 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800297 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
298 static SkDrawBitmapNineCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800299
chudy@google.com902ebe52012-06-29 14:21:22 +0000300private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000301 SkBitmap fBitmap;
302 SkIRect fCenter;
303 SkRect fDst;
304 SkPaint fPaint;
305 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000306
307 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000308};
309
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000310class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000311public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000312 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000313 const SkRect& dst, const SkPaint* paint,
reeda5517e22015-07-14 10:54:12 -0700314 SkCanvas::SrcRectConstraint);
mtklein36352bf2015-03-25 18:17:31 -0700315 void execute(SkCanvas* canvas) const override;
316 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800317 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
318 static SkDrawBitmapRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000319
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000320 const SkBitmap& bitmap() const { return fBitmap; }
321
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000322 // The non-const 'paint' method allows modification of this object's
323 // SkPaint. For this reason the ctor and setPaint method make a local copy.
324 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
325 // (since only an SkPaint* is passed into the ctor).
326 const SkPaint* paint() const { return fPaintPtr; }
327 SkPaint* paint() { return fPaintPtr; }
328
329 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
330
halcanary96fcdcc2015-08-27 07:41:13 -0700331 const SkRect* srcRect() const { return fSrc.isEmpty() ? nullptr : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000332 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000333
334 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000335 void setDstRect(const SkRect& dst) { fDst = dst; }
336
reeda5517e22015-07-14 10:54:12 -0700337 SkCanvas::SrcRectConstraint constraint() const { return fConstraint; }
338 void setConstraint(SkCanvas::SrcRectConstraint constraint) { fConstraint = constraint; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000339
chudy@google.com902ebe52012-06-29 14:21:22 +0000340private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000341 SkBitmap fBitmap;
342 SkRect fSrc;
343 SkRect fDst;
344 SkPaint fPaint;
345 SkPaint* fPaintPtr;
reeda5517e22015-07-14 10:54:12 -0700346 SkCanvas::SrcRectConstraint fConstraint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000347
348 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000349};
350
fmalita651c9202015-07-22 10:23:01 -0700351class SkDrawImageCommand : public SkDrawCommand {
352public:
353 SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);
354 void execute(SkCanvas* canvas) const override;
355 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800356 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
357 static SkDrawImageCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800358
fmalita651c9202015-07-22 10:23:01 -0700359private:
360 SkAutoTUnref<const SkImage> fImage;
361 SkScalar fLeft;
362 SkScalar fTop;
363 SkTLazy<SkPaint> fPaint;
364
365 typedef SkDrawCommand INHERITED;
366};
367
368class SkDrawImageRectCommand : public SkDrawCommand {
369public:
370 SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect& dst,
371 const SkPaint* paint, SkCanvas::SrcRectConstraint constraint);
372 void execute(SkCanvas* canvas) const override;
373 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800374 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
375 static SkDrawImageRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800376
fmalita651c9202015-07-22 10:23:01 -0700377private:
378 SkAutoTUnref<const SkImage> fImage;
379 SkTLazy<SkRect> fSrc;
380 SkRect fDst;
381 SkTLazy<SkPaint> fPaint;
382 SkCanvas::SrcRectConstraint fConstraint;
383
384 typedef SkDrawCommand INHERITED;
385};
386
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000387class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000388public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000389 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700390 void execute(SkCanvas* canvas) const override;
391 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800392 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
393 static SkDrawOvalCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800394
robertphillips@google.com67baba42013-01-02 20:20:31 +0000395private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000396 SkRect fOval;
397 SkPaint fPaint;
398
399 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000400};
401
bsalomonac3aa242016-08-19 11:25:19 -0700402class SkDrawArcCommand : public SkDrawCommand {
403public:
404 SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
405 const SkPaint& paint);
406 void execute(SkCanvas* canvas) const override;
407 bool render(SkCanvas* canvas) const override;
408 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
409 static SkDrawArcCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
410
411private:
412 SkRect fOval;
413 SkScalar fStartAngle;
414 SkScalar fSweepAngle;
415 bool fUseCenter;
416 SkPaint fPaint;
417
418 typedef SkDrawCommand INHERITED;
419};
420
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000421class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000422public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000423 SkDrawPaintCommand(const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700424 void execute(SkCanvas* canvas) const override;
425 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800426 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
427 static SkDrawPaintCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800428
chudy@google.com902ebe52012-06-29 14:21:22 +0000429private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000430 SkPaint fPaint;
431
432 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000433};
434
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000435class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000436public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000437 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700438 void execute(SkCanvas* canvas) const override;
439 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800440 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
441 static SkDrawPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000442
chudy@google.com902ebe52012-06-29 14:21:22 +0000443private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000444 SkPath fPath;
445 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000446
447 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000448};
449
fmalita160ebb22015-04-01 20:58:37 -0700450class SkBeginDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000451public:
fmalita160ebb22015-04-01 20:58:37 -0700452 SkBeginDrawPictureCommand(const SkPicture* picture,
453 const SkMatrix* matrix,
454 const SkPaint* paint);
455
mtklein36352bf2015-03-25 18:17:31 -0700456 void execute(SkCanvas* canvas) const override;
457 bool render(SkCanvas* canvas) const override;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000458
chudy@google.com902ebe52012-06-29 14:21:22 +0000459private:
robertphillips9b14f262014-06-04 05:40:44 -0700460 SkAutoTUnref<const SkPicture> fPicture;
fmalita160ebb22015-04-01 20:58:37 -0700461 SkTLazy<SkMatrix> fMatrix;
462 SkTLazy<SkPaint> fPaint;
463
464 typedef SkDrawCommand INHERITED;
465};
466
467class SkEndDrawPictureCommand : public SkDrawCommand {
468public:
469 SkEndDrawPictureCommand(bool restore);
470
471 void execute(SkCanvas* canvas) const override;
472
473private:
474 bool fRestore;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000475
476 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000477};
478
vjiaoblack95302da2016-07-21 10:25:54 -0700479class SkBeginDrawShadowedPictureCommand : public SkDrawCommand {
480public:
481 SkBeginDrawShadowedPictureCommand(const SkPicture* picture,
482 const SkMatrix* matrix,
vjiaoblacke6f5d562016-08-25 06:30:23 -0700483 const SkPaint* paint,
484 const SkShadowParams& params);
vjiaoblack95302da2016-07-21 10:25:54 -0700485
486 void execute(SkCanvas* canvas) const override;
487 bool render(SkCanvas* canvas) const override;
488
489private:
490 SkAutoTUnref<const SkPicture> fPicture;
491 SkTLazy<SkMatrix> fMatrix;
492 SkTLazy<SkPaint> fPaint;
vjiaoblacke6f5d562016-08-25 06:30:23 -0700493#ifdef SK_EXPERIMENTAL_SHADOWING
494 SkShadowParams fShadowParams;
495#endif
vjiaoblack95302da2016-07-21 10:25:54 -0700496
497 typedef SkDrawCommand INHERITED;
498};
499
500class SkEndDrawShadowedPictureCommand : public SkDrawCommand {
501public:
502 SkEndDrawShadowedPictureCommand(bool restore);
503
504 void execute(SkCanvas* canvas) const override;
505
506private:
507 bool fRestore;
508
509 typedef SkDrawCommand INHERITED;
510};
511
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000512class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000513public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000514 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000515 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000516 virtual ~SkDrawPointsCommand() { delete [] fPts; }
mtklein36352bf2015-03-25 18:17:31 -0700517 void execute(SkCanvas* canvas) const override;
518 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800519 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
520 static SkDrawPointsCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800521
chudy@google.com902ebe52012-06-29 14:21:22 +0000522private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000523 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000524 size_t fCount;
525 SkPoint* fPts;
526 SkPaint fPaint;
527
528 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000529};
530
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000531class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000532public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000533 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000534 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000535 virtual ~SkDrawTextCommand() { delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700536 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800537 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
538 static SkDrawTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800539
chudy@google.com902ebe52012-06-29 14:21:22 +0000540private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000541 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000542 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000543 SkScalar fX;
544 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000545 SkPaint fPaint;
546
547 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000548};
549
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000550class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000551public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000552 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
553 const SkPaint& paint);
554 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700555 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800556 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
557 static SkDrawPosTextCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800558
chudy@google.com902ebe52012-06-29 14:21:22 +0000559private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000560 char* fText;
561 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000562 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000563 SkPaint fPaint;
564
565 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000566};
567
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000568class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000569public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000570 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
571 const SkMatrix* matrix, const SkPaint& paint);
572 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700573 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800574 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
575 static SkDrawTextOnPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800576
chudy@google.com902ebe52012-06-29 14:21:22 +0000577private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000578 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000579 size_t fByteLength;
580 SkPath fPath;
581 SkMatrix fMatrix;
582 SkPaint fPaint;
583
584 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000585};
586
reed45561a02016-07-07 12:47:17 -0700587class SkDrawTextRSXformCommand : public SkDrawCommand {
588public:
589 SkDrawTextRSXformCommand(const void* text, size_t byteLength, const SkRSXform[],
590 const SkRect*, const SkPaint& paint);
591 ~SkDrawTextRSXformCommand() override { delete[] fText; delete[] fXform; }
592 void execute(SkCanvas* canvas) const override;
593 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
594 static SkDrawTextRSXformCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
595
596private:
597 char* fText;
598 size_t fByteLength;
599 SkRSXform* fXform;
600 SkRect* fCull;
601 SkRect fCullStorage;
602 SkPaint fPaint;
603
604 typedef SkDrawCommand INHERITED;
605};
606
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000607class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000608public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000609 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
610 SkScalar constY, const SkPaint& paint);
611 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
mtklein36352bf2015-03-25 18:17:31 -0700612 void execute(SkCanvas* canvas) const override;
bungeman51190df2016-03-09 07:42:54 -0800613 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
614 static SkDrawPosTextHCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800615
chudy@google.com902ebe52012-06-29 14:21:22 +0000616private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000617 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000618 char* fText;
619 size_t fByteLength;
620 SkScalar fConstY;
621 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000622
623 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000624};
625
fmalitab7425172014-08-26 07:56:44 -0700626class SkDrawTextBlobCommand : public SkDrawCommand {
627public:
fmalita37283c22016-09-13 10:00:23 -0700628 SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y, const SkPaint& paint);
fmalitab7425172014-08-26 07:56:44 -0700629
mtklein36352bf2015-03-25 18:17:31 -0700630 void execute(SkCanvas* canvas) const override;
631 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800632 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
633 static SkDrawTextBlobCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
fmalitab7425172014-08-26 07:56:44 -0700634
635private:
fmalita37283c22016-09-13 10:00:23 -0700636 sk_sp<SkTextBlob> fBlob;
637 SkScalar fXPos;
638 SkScalar fYPos;
639 SkPaint fPaint;
fmalitab7425172014-08-26 07:56:44 -0700640
641 typedef SkDrawCommand INHERITED;
642};
643
robertphillips9bafc302015-02-13 11:13:00 -0800644class SkDrawPatchCommand : public SkDrawCommand {
645public:
646 SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
647 const SkPoint texCoords[4], SkXfermode* xmode,
648 const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700649 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800650 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
651 static SkDrawPatchCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips9bafc302015-02-13 11:13:00 -0800652
653private:
654 SkPoint fCubics[12];
ethannicholas1446a9a2016-02-10 14:05:02 -0800655 SkColor* fColorsPtr;
656 SkColor fColors[4];
657 SkPoint* fTexCoordsPtr;
658 SkPoint fTexCoords[4];
robertphillips9bafc302015-02-13 11:13:00 -0800659 SkAutoTUnref<SkXfermode> fXfermode;
660 SkPaint fPaint;
661
662 typedef SkDrawCommand INHERITED;
663};
664
665
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000666class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000667public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000668 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700669 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800670 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
671 static SkDrawRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000672
robertphillips@google.com91217d02013-03-17 18:33:46 +0000673 const SkRect& rect() const { return fRect; }
674 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000675private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000676 SkRect fRect;
677 SkPaint fPaint;
678
679 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000680};
681
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000682class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000683public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000684 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700685 void execute(SkCanvas* canvas) const override;
686 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800687 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
688 static SkDrawRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800689
robertphillips@google.com67baba42013-01-02 20:20:31 +0000690private:
691 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000692 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000693
694 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000695};
696
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000697class SkDrawDRRectCommand : public SkDrawCommand {
698public:
699 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
700 const SkPaint& paint);
mtklein36352bf2015-03-25 18:17:31 -0700701 void execute(SkCanvas* canvas) const override;
702 bool render(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800703 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
704 static SkDrawDRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800705
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000706private:
707 SkRRect fOuter;
708 SkRRect fInner;
709 SkPaint fPaint;
710
711 typedef SkDrawCommand INHERITED;
712};
713
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000714class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000715public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000716 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
717 const SkPoint vertices[], const SkPoint texs[],
718 const SkColor colors[], SkXfermode* xfermode,
719 const uint16_t indices[], int indexCount,
720 const SkPaint& paint);
721 virtual ~SkDrawVerticesCommand();
mtklein36352bf2015-03-25 18:17:31 -0700722 void execute(SkCanvas* canvas) const override;
ethannicholas50a8dd02016-02-10 05:40:46 -0800723
chudy@google.com902ebe52012-06-29 14:21:22 +0000724private:
725 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000726 int fVertexCount;
727 SkPoint* fVertices;
728 SkPoint* fTexs;
729 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000730 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000731 uint16_t* fIndices;
732 int fIndexCount;
733 SkPaint fPaint;
734
735 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000736};
737
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000738class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000739public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400740 SkSaveCommand();
mtklein36352bf2015-03-25 18:17:31 -0700741 void execute(SkCanvas* canvas) const override;
742 Action action() const override { return kPushLayer_Action; }
ethannicholasf62a8b72016-02-11 10:35:21 -0800743 static SkSaveCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800744
chudy@google.com902ebe52012-06-29 14:21:22 +0000745private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000746 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000747};
748
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000749class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000750public:
reed4960eee2015-12-18 07:09:18 -0800751 SkSaveLayerCommand(const SkCanvas::SaveLayerRec&);
ethannicholas50a8dd02016-02-10 05:40:46 -0800752 virtual ~SkSaveLayerCommand();
mtklein36352bf2015-03-25 18:17:31 -0700753 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800754 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
755 static SkSaveLayerCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
mtklein36352bf2015-03-25 18:17:31 -0700756 void vizExecute(SkCanvas* canvas) const override;
757 Action action() const override{ return kPushLayer_Action; }
758 void setActive(bool active) override { fActive = active; }
759 bool active() const override { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000760
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000761 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000762
chudy@google.com902ebe52012-06-29 14:21:22 +0000763private:
ethannicholas50a8dd02016-02-10 05:40:46 -0800764 SkRect fBounds;
765 SkPaint fPaint;
766 SkPaint* fPaintPtr;
767 const SkImageFilter* fBackdrop;
768 uint32_t fSaveLayerFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000769
reed4960eee2015-12-18 07:09:18 -0800770 bool fActive;
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000771
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000772 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000773};
774
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000775class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000776public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000777 SkSetMatrixCommand(const SkMatrix& matrix);
mtklein36352bf2015-03-25 18:17:31 -0700778 void setUserMatrix(const SkMatrix&) override;
779 void execute(SkCanvas* canvas) const override;
ethannicholasf62a8b72016-02-11 10:35:21 -0800780 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
781 static SkSetMatrixCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
ethannicholas50a8dd02016-02-10 05:40:46 -0800782
chudy@google.com902ebe52012-06-29 14:21:22 +0000783private:
robertphillips70171682014-10-16 14:28:28 -0700784 SkMatrix fUserMatrix;
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000785 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000786
787 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000788};
789
vjiaoblacke5de1302016-07-13 14:05:28 -0700790class SkTranslateZCommand : public SkDrawCommand {
791public:
792 SkTranslateZCommand(SkScalar);
793 void execute(SkCanvas* canvas) const override;
794 Json::Value toJSON(UrlDataManager& urlDataManager) const override;
795 static SkTranslateZCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
796
797private:
798 SkScalar fZTranslate;
799
800 typedef SkDrawCommand INHERITED;
801};
chudy@google.com902ebe52012-06-29 14:21:22 +0000802#endif
vjiaoblacke6f5d562016-08-25 06:30:23 -0700803