blob: f3c8cca9de00090a380cb53f68229d804b13742d [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef SKDRAWCOMMAND_H_
10#define SKDRAWCOMMAND_H_
11
chudy@google.com902ebe52012-06-29 14:21:22 +000012#include "SkPictureFlat.h"
13#include "SkCanvas.h"
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000014#include "SkString.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000015
fmalita@google.com86681b32013-06-13 20:59:14 +000016class SK_API SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000017public:
18 /* TODO(chudy): Remove subclasses. */
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000019 SkDrawCommand(DrawType drawType);
chudy@google.com902ebe52012-06-29 14:21:22 +000020 SkDrawCommand();
21
22 virtual ~SkDrawCommand();
23
chudy@google.com97cee972012-08-07 20:41:37 +000024 virtual SkString toString();
chudy@google.com902ebe52012-06-29 14:21:22 +000025
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000026 void setOffset(size_t offset) { fOffset = offset; }
27 virtual size_t offset() { return fOffset; }
28
chudy@google.com902ebe52012-06-29 14:21:22 +000029 virtual const char* toCString() {
30 return GetCommandString(fDrawType);
31 }
32
chudy@google.com0b5bbb02012-07-31 19:55:32 +000033 bool isVisible() const {
34 return fVisible;
35 }
36
37 void setVisible(bool toggle) {
38 fVisible = toggle;
39 }
chudy@google.com902ebe52012-06-29 14:21:22 +000040
chudy@google.com97cee972012-08-07 20:41:37 +000041 SkTDArray<SkString*>* Info() {return &fInfo; };
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000042 virtual void execute(SkCanvas* canvas) = 0;
43 virtual void vizExecute(SkCanvas* canvas) { };
tomhudson@google.com0699e022012-11-27 16:09:42 +000044 /** Does nothing by default, but used by save() and restore()-type
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000045 subclasses to track unresolved save() calls. */
tomhudson@google.com0699e022012-11-27 16:09:42 +000046 virtual void trackSaveState(int* state) { };
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000047
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000048 // The next "active" system is only used by save, saveLayer, restore,
49 // pushCull and popCull. It is used in two ways:
skia.committer@gmail.comade9a342014-03-04 03:02:32 +000050 // To determine which saveLayers are currently active (at a
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000051 // given point in the rendering).
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000052 // saves just return a kPushLayer action but don't track active state
53 // restores just return a kPopLayer action
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000054 // saveLayers return kPushLayer but also track the active state
55 // To determine which culls are currently active (at a given point)
56 // in the rendering).
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000057 // pushCulls return a kPushCull action
58 // popCulls return a kPopCull action
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000059 enum Action {
60 kNone_Action,
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000061 kPopLayer_Action,
62 kPushLayer_Action,
63 kPopCull_Action,
64 kPushCull_Action
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000065 };
66 virtual Action action() const { return kNone_Action; }
67 virtual void setActive(bool active) {}
68 virtual bool active() const { return false; }
69
chudy@google.com902ebe52012-06-29 14:21:22 +000070 DrawType getType() { return fDrawType; };
71
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000072 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000073
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000074 static const char* GetCommandString(DrawType type);
75
chudy@google.com902ebe52012-06-29 14:21:22 +000076protected:
chudy@google.com97cee972012-08-07 20:41:37 +000077 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +000078
79private:
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000080 DrawType fDrawType;
81 size_t fOffset;
82 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +000083};
84
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000085class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000086public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000087 SkRestoreCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +000088 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +000089 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000090 virtual Action action() const SK_OVERRIDE { return kPopLayer_Action; }
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000091
92private:
93 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000094};
95
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000096class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000097public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000098 SkClearCommand(SkColor color);
chudy@google.com902ebe52012-06-29 14:21:22 +000099 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
100private:
101 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000102
103 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000104};
105
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000106class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000107public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000108 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000109 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000110 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000111private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000112 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +0000113 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000114 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000115
116 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000117};
118
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000119class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000120public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000121 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
chudy@google.com902ebe52012-06-29 14:21:22 +0000122 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
123private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000124 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +0000125 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000126
127 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000128};
129
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000130class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000131public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000132 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000133 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000134
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000135 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000136 SkRegion::Op op() const { return fOp; }
137 bool doAA() const { return fDoAA; }
138
chudy@google.com902ebe52012-06-29 14:21:22 +0000139private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000140 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000141 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000142 bool fDoAA;
143
144 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000145};
146
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000147class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000148public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000149 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000150 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000151 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000152
153 const SkRRect& rrect() const { return fRRect; }
154 SkRegion::Op op() const { return fOp; }
155 bool doAA() const { return fDoAA; }
156
robertphillips@google.com67baba42013-01-02 20:20:31 +0000157private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000158 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000159 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000160 bool fDoAA;
161
162 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000163};
164
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000165class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000166public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000167 SkConcatCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000168 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
169private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000170 SkMatrix fMatrix;
171
172 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000173};
174
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000175class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000176public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000177 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000178 const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000179 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000180 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000181private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000182 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000183 SkScalar fLeft;
184 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000185 SkPaint fPaint;
186 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +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 SkDrawBitmapMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000192public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000193 SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, const SkMatrix& matrix,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000194 const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000195 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000196 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000197private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000198 SkBitmap fBitmap;
199 SkMatrix fMatrix;
200 SkPaint fPaint;
201 SkPaint* fPaintPtr;
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 SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000207public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000208 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000209 const SkRect& dst, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000210 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000211 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000212private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000213 SkBitmap fBitmap;
214 SkIRect fCenter;
215 SkRect fDst;
216 SkPaint fPaint;
217 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000218
219 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000220};
221
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000222class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000223public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000224 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000225 const SkRect& dst, const SkPaint* paint,
226 SkCanvas::DrawBitmapRectFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000227 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000228 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000229
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000230 const SkBitmap& bitmap() const { return fBitmap; }
231
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000232 // The non-const 'paint' method allows modification of this object's
233 // SkPaint. For this reason the ctor and setPaint method make a local copy.
234 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
235 // (since only an SkPaint* is passed into the ctor).
236 const SkPaint* paint() const { return fPaintPtr; }
237 SkPaint* paint() { return fPaintPtr; }
238
239 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
240
robertphillips@google.com91217d02013-03-17 18:33:46 +0000241 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000242 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000243
244 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000245 void setDstRect(const SkRect& dst) { fDst = dst; }
246
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000247 SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
248 void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
249
chudy@google.com902ebe52012-06-29 14:21:22 +0000250private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000251 SkBitmap fBitmap;
252 SkRect fSrc;
253 SkRect fDst;
254 SkPaint fPaint;
255 SkPaint* fPaintPtr;
256 SkCanvas::DrawBitmapRectFlags fFlags;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000257
258 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000259};
260
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000261class SkDrawDataCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000262public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000263 SkDrawDataCommand(const void* data, size_t length);
264 virtual ~SkDrawDataCommand() { delete [] fData; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000265 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
266private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000267 char* fData;
chudy@google.com902ebe52012-06-29 14:21:22 +0000268 size_t fLength;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000269
270 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000271};
272
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000273class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000274public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000275 SkBeginCommentGroupCommand(const char* description);
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000276 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
277 canvas->beginCommentGroup(fDescription.c_str());
278 };
279private:
280 SkString fDescription;
281
282 typedef SkDrawCommand INHERITED;
283};
284
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000285class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000286public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000287 SkCommentCommand(const char* kywd, const char* value);
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000288 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
289 canvas->addComment(fKywd.c_str(), fValue.c_str());
290 };
291private:
292 SkString fKywd;
293 SkString fValue;
294
295 typedef SkDrawCommand INHERITED;
296};
297
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000298class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000299public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000300 SkEndCommentGroupCommand();
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000301 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
302 canvas->endCommentGroup();
303 };
304private:
305 typedef SkDrawCommand INHERITED;
306};
307
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000308class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000309public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000310 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000311 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000312 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000313private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000314 SkRect fOval;
315 SkPaint fPaint;
316
317 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000318};
319
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000320class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000321public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000322 SkDrawPaintCommand(const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000323 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000324 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000325private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000326 SkPaint fPaint;
327
328 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000329};
330
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000331class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000332public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000333 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000334 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000335 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000336
chudy@google.com902ebe52012-06-29 14:21:22 +0000337private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000338 SkPath fPath;
339 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000340
341 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000342};
343
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000344class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000345public:
robertphillipsb3f319f2014-08-13 10:46:23 -0700346 SkDrawPictureCommand(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000347 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000348 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
349
chudy@google.com902ebe52012-06-29 14:21:22 +0000350private:
robertphillips9b14f262014-06-04 05:40:44 -0700351 SkAutoTUnref<const SkPicture> fPicture;
robertphillipsb3f319f2014-08-13 10:46:23 -0700352 SkMatrix fMatrix;
353 SkMatrix* fMatrixPtr;
354 SkPaint fPaint;
355 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000356
357 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000358};
359
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000360class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000361public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000362 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000363 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000364 virtual ~SkDrawPointsCommand() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000365 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000366 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000367private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000368 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000369 size_t fCount;
370 SkPoint* fPts;
371 SkPaint fPaint;
372
373 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000374};
375
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000376class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000377public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000378 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000379 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000380 virtual ~SkDrawTextCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000381 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
382private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000383 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000384 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000385 SkScalar fX;
386 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000387 SkPaint fPaint;
388
389 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000390};
391
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000392class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000393public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000394 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
395 const SkPaint& paint);
396 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000397 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
398private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000399 char* fText;
400 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000401 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000402 SkPaint fPaint;
403
404 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000405};
406
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000407class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000408public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000409 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
410 const SkMatrix* matrix, const SkPaint& paint);
411 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000412 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
413private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000414 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000415 size_t fByteLength;
416 SkPath fPath;
417 SkMatrix fMatrix;
418 SkPaint fPaint;
419
420 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000421};
422
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000423class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000424public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000425 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
426 SkScalar constY, const SkPaint& paint);
427 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000428 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
429private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000430 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000431 char* fText;
432 size_t fByteLength;
433 SkScalar fConstY;
434 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000435
436 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000437};
438
fmalitab7425172014-08-26 07:56:44 -0700439class SkDrawTextBlobCommand : public SkDrawCommand {
440public:
441 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
442
443 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
444
445private:
446 SkAutoTUnref<const SkTextBlob> fBlob;
447 SkScalar fXPos;
448 SkScalar fYPos;
449 SkPaint fPaint;
450
451 typedef SkDrawCommand INHERITED;
452};
453
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000454class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000455public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000456 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000457 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000458
robertphillips@google.com91217d02013-03-17 18:33:46 +0000459 const SkRect& rect() const { return fRect; }
460 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000461private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000462 SkRect fRect;
463 SkPaint fPaint;
464
465 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000466};
467
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000468class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000469public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000470 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000471 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000472 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000473private:
474 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000475 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000476
477 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000478};
479
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000480class SkDrawDRRectCommand : public SkDrawCommand {
481public:
482 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
483 const SkPaint& paint);
484 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
485 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
486private:
487 SkRRect fOuter;
488 SkRRect fInner;
489 SkPaint fPaint;
490
491 typedef SkDrawCommand INHERITED;
492};
493
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000494class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000495public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000496 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000497 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000498 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000499private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000500 SkBitmap fBitmap;
501 int fLeft;
502 int fTop;
503 SkPaint fPaint;
504 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000505
506 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000507};
508
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000509class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000510public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000511 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
512 const SkPoint vertices[], const SkPoint texs[],
513 const SkColor colors[], SkXfermode* xfermode,
514 const uint16_t indices[], int indexCount,
515 const SkPaint& paint);
516 virtual ~SkDrawVerticesCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +0000517 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
518private:
519 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000520 int fVertexCount;
521 SkPoint* fVertices;
522 SkPoint* fTexs;
523 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000524 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000525 uint16_t* fIndices;
526 int fIndexCount;
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 SkRotateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000533public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000534 SkRotateCommand(SkScalar degrees);
chudy@google.com902ebe52012-06-29 14:21:22 +0000535 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
536private:
537 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000538
539 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000540};
541
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000542class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000543public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400544 SkSaveCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +0000545 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000546 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000547 virtual Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000548private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000549 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000550};
551
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000552class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000553public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000554 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
555 SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000556 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000557 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000558 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000559 virtual Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000560 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; }
561 virtual bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000562
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000563 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000564
chudy@google.com902ebe52012-06-29 14:21:22 +0000565private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000566 SkRect fBounds;
567 SkPaint fPaint;
568 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000569 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000570
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000571 bool fActive;
572
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000573 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000574};
575
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000576class SkScaleCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000577public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000578 SkScaleCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000579 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000580
581 SkScalar x() const { return fSx; }
582 SkScalar y() const { return fSy; }
583
chudy@google.com902ebe52012-06-29 14:21:22 +0000584private:
585 SkScalar fSx;
586 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000587
588 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000589};
590
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000591class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000592public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000593 SkSetMatrixCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000594 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
595private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000596 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000597
598 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000599};
600
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000601class SkSkewCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000602public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000603 SkSkewCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000604 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
605private:
606 SkScalar fSx;
607 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000608
609 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000610};
611
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000612class SkTranslateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000613public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000614 SkTranslateCommand(SkScalar dx, SkScalar dy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000615 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000616
617 SkScalar x() const { return fDx; }
618 SkScalar y() const { return fDy; }
619
chudy@google.com902ebe52012-06-29 14:21:22 +0000620private:
621 SkScalar fDx;
622 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000623
624 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000625};
626
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000627class SkPushCullCommand : public SkDrawCommand {
628public:
629 SkPushCullCommand(const SkRect&);
630 virtual void execute(SkCanvas*) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000631 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE;
632 virtual Action action() const { return kPushCull_Action; }
633 virtual void setActive(bool active) { fActive = active; }
634 virtual bool active() const { return fActive; }
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000635private:
636 SkRect fCullRect;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000637 bool fActive;
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000638
639 typedef SkDrawCommand INHERITED;
640};
641
642class SkPopCullCommand : public SkDrawCommand {
643public:
644 SkPopCullCommand();
645 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000646 virtual Action action() const { return kPopCull_Action; }
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000647private:
648 typedef SkDrawCommand INHERITED;
649};
650
chudy@google.com902ebe52012-06-29 14:21:22 +0000651#endif