blob: f2e151ae4f40ef3a30eb99d326fea387dce87e3c [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:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000346 SkDrawPictureCommand(SkPicture& picture);
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:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000351 SkPicture fPicture;
352
353 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000354};
355
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000356class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000357public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000358 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000359 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000360 virtual ~SkDrawPointsCommand() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000361 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000362 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000363private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000364 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000365 size_t fCount;
366 SkPoint* fPts;
367 SkPaint fPaint;
368
369 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000370};
371
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000372class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000373public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000374 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000375 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000376 virtual ~SkDrawTextCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000377 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
378private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000379 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000380 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000381 SkScalar fX;
382 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000383 SkPaint fPaint;
384
385 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000386};
387
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000388class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000389public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000390 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
391 const SkPaint& paint);
392 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000393 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
394private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000395 char* fText;
396 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000397 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000398 SkPaint fPaint;
399
400 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000401};
402
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000403class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000404public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000405 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
406 const SkMatrix* matrix, const SkPaint& paint);
407 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000408 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
409private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000410 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000411 size_t fByteLength;
412 SkPath fPath;
413 SkMatrix fMatrix;
414 SkPaint fPaint;
415
416 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000417};
418
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000419class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000420public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000421 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
422 SkScalar constY, const SkPaint& paint);
423 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000424 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
425private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000426 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000427 char* fText;
428 size_t fByteLength;
429 SkScalar fConstY;
430 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000431
432 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000433};
434
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000435class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000436public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000437 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000438 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000439
robertphillips@google.com91217d02013-03-17 18:33:46 +0000440 const SkRect& rect() const { return fRect; }
441 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000442private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000443 SkRect fRect;
444 SkPaint fPaint;
445
446 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000447};
448
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000449class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000450public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000451 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000452 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000453 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000454private:
455 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000456 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000457
458 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000459};
460
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000461class SkDrawDRRectCommand : public SkDrawCommand {
462public:
463 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
464 const SkPaint& paint);
465 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
466 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
467private:
468 SkRRect fOuter;
469 SkRRect fInner;
470 SkPaint fPaint;
471
472 typedef SkDrawCommand INHERITED;
473};
474
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000475class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000476public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000477 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000478 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000479 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000480private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000481 SkBitmap fBitmap;
482 int fLeft;
483 int fTop;
484 SkPaint fPaint;
485 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000486
487 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000488};
489
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000490class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000491public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000492 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
493 const SkPoint vertices[], const SkPoint texs[],
494 const SkColor colors[], SkXfermode* xfermode,
495 const uint16_t indices[], int indexCount,
496 const SkPaint& paint);
497 virtual ~SkDrawVerticesCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +0000498 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
499private:
500 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000501 int fVertexCount;
502 SkPoint* fVertices;
503 SkPoint* fTexs;
504 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000505 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000506 uint16_t* fIndices;
507 int fIndexCount;
508 SkPaint fPaint;
509
510 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000511};
512
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000513class SkRotateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000514public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000515 SkRotateCommand(SkScalar degrees);
chudy@google.com902ebe52012-06-29 14:21:22 +0000516 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
517private:
518 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000519
520 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000521};
522
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000523class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000524public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000525 SkSaveCommand(SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000526 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000527 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000528 virtual Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000529private:
530 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000531
532 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000533};
534
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000535class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000536public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000537 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
538 SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000539 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000540 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000541 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000542 virtual Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000543 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; }
544 virtual bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000545
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000546 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000547
chudy@google.com902ebe52012-06-29 14:21:22 +0000548private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000549 SkRect fBounds;
550 SkPaint fPaint;
551 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000552 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000553
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000554 bool fActive;
555
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000556 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000557};
558
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000559class SkScaleCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000560public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000561 SkScaleCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000562 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000563
564 SkScalar x() const { return fSx; }
565 SkScalar y() const { return fSy; }
566
chudy@google.com902ebe52012-06-29 14:21:22 +0000567private:
568 SkScalar fSx;
569 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000570
571 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000572};
573
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000574class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000575public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000576 SkSetMatrixCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000577 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
578private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000579 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000580
581 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000582};
583
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000584class SkSkewCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000585public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000586 SkSkewCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000587 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
588private:
589 SkScalar fSx;
590 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000591
592 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000593};
594
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000595class SkTranslateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000596public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000597 SkTranslateCommand(SkScalar dx, SkScalar dy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000598 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000599
600 SkScalar x() const { return fDx; }
601 SkScalar y() const { return fDy; }
602
chudy@google.com902ebe52012-06-29 14:21:22 +0000603private:
604 SkScalar fDx;
605 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000606
607 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000608};
609
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000610class SkPushCullCommand : public SkDrawCommand {
611public:
612 SkPushCullCommand(const SkRect&);
613 virtual void execute(SkCanvas*) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000614 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE;
615 virtual Action action() const { return kPushCull_Action; }
616 virtual void setActive(bool active) { fActive = active; }
617 virtual bool active() const { return fActive; }
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000618private:
619 SkRect fCullRect;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000620 bool fActive;
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000621
622 typedef SkDrawCommand INHERITED;
623};
624
625class SkPopCullCommand : public SkDrawCommand {
626public:
627 SkPopCullCommand();
628 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000629 virtual Action action() const { return kPopCull_Action; }
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000630private:
631 typedef SkDrawCommand INHERITED;
632};
633
chudy@google.com902ebe52012-06-29 14:21:22 +0000634#endif