blob: a4f50c9737e1c2c7436ce72be6427deb1fc1c030 [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
26 virtual const char* toCString() {
27 return GetCommandString(fDrawType);
28 }
29
chudy@google.com0b5bbb02012-07-31 19:55:32 +000030 bool isVisible() const {
31 return fVisible;
32 }
33
34 void setVisible(bool toggle) {
35 fVisible = toggle;
36 }
chudy@google.com902ebe52012-06-29 14:21:22 +000037
chudy@google.com97cee972012-08-07 20:41:37 +000038 SkTDArray<SkString*>* Info() {return &fInfo; };
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000039 virtual void execute(SkCanvas* canvas) = 0;
40 virtual void vizExecute(SkCanvas* canvas) { };
tomhudson@google.com0699e022012-11-27 16:09:42 +000041 /** Does nothing by default, but used by save() and restore()-type
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000042 subclasses to track unresolved save() calls. */
tomhudson@google.com0699e022012-11-27 16:09:42 +000043 virtual void trackSaveState(int* state) { };
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000044
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000045 // The next "active" system is only used by save, saveLayer, restore,
46 // pushCull and popCull. It is used in two ways:
47 // To determine which saveLayers are currently active (at a
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000048 // given point in the rendering).
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000049 // save just return a kPushLayer action but don't track active state
50 // restore just return a kPopLayer action
51 // saveLayers return kPushLayer but also track the active state
52 // To determine which culls are currently active (at a given point)
53 // in the rendering).
54 // pushCull returns a kPushCull action
55 // popCull returns a kPopCull action
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000056 enum Action {
57 kNone_Action,
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000058 kPopLayer_Action,
59 kPushLayer_Action,
60 kPopCull_Action,
61 kPushCull_Action
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000062 };
63 virtual Action action() const { return kNone_Action; }
64 virtual void setActive(bool active) {}
65 virtual bool active() const { return false; }
66
chudy@google.com902ebe52012-06-29 14:21:22 +000067 DrawType getType() { return fDrawType; };
68
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000069 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000070
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000071 static const char* GetCommandString(DrawType type);
72
chudy@google.com902ebe52012-06-29 14:21:22 +000073protected:
74 DrawType fDrawType;
chudy@google.com97cee972012-08-07 20:41:37 +000075 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +000076
77private:
78 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +000079};
80
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000081class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000082public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000083 SkRestoreCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +000084 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +000085 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000086 virtual Action action() const SK_OVERRIDE { return kPopLayer_Action; }
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000087
88private:
89 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000090};
91
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000092class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000093public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000094 SkClearCommand(SkColor color);
chudy@google.com902ebe52012-06-29 14:21:22 +000095 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
96private:
97 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000098
99 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000100};
101
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000102class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000103public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000104 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000105 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000106 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000107private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000108 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +0000109 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000110 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000111
112 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000113};
114
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000115class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000116public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000117 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
chudy@google.com902ebe52012-06-29 14:21:22 +0000118 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
119private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000120 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +0000121 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000122
123 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000124};
125
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000126class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000127public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000128 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000129 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000130
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000131 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000132 SkRegion::Op op() const { return fOp; }
133 bool doAA() const { return fDoAA; }
134
chudy@google.com902ebe52012-06-29 14:21:22 +0000135private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000136 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000137 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000138 bool fDoAA;
139
140 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000141};
142
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000143class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000144public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000145 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000146 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000147 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000148
149 const SkRRect& rrect() const { return fRRect; }
150 SkRegion::Op op() const { return fOp; }
151 bool doAA() const { return fDoAA; }
152
robertphillips@google.com67baba42013-01-02 20:20:31 +0000153private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000154 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000155 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000156 bool fDoAA;
157
158 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000159};
160
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000161class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000162public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000163 SkConcatCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000164 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
165private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000166 SkMatrix fMatrix;
167
168 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000169};
170
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000171class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000172public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000173 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000174 const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000175 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000176 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000177private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000178 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000179 SkScalar fLeft;
180 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000181 SkPaint fPaint;
182 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000183
184 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000185};
186
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000187class SkDrawBitmapMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000188public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000189 SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, const SkMatrix& matrix,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000190 const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000191 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000192 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000193private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000194 SkBitmap fBitmap;
195 SkMatrix fMatrix;
196 SkPaint fPaint;
197 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000198
199 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000200};
201
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000202class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000203public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000204 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000205 const SkRect& dst, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000206 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000207 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000208private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000209 SkBitmap fBitmap;
210 SkIRect fCenter;
211 SkRect fDst;
212 SkPaint fPaint;
213 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000214
215 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000216};
217
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000218class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000219public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000220 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000221 const SkRect& dst, const SkPaint* paint,
222 SkCanvas::DrawBitmapRectFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000223 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000224 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000225
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000226 const SkBitmap& bitmap() const { return fBitmap; }
227
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000228 // The non-const 'paint' method allows modification of this object's
229 // SkPaint. For this reason the ctor and setPaint method make a local copy.
230 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
231 // (since only an SkPaint* is passed into the ctor).
232 const SkPaint* paint() const { return fPaintPtr; }
233 SkPaint* paint() { return fPaintPtr; }
234
235 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
236
robertphillips@google.com91217d02013-03-17 18:33:46 +0000237 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000238 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000239
240 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000241 void setDstRect(const SkRect& dst) { fDst = dst; }
242
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000243 SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
244 void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
245
chudy@google.com902ebe52012-06-29 14:21:22 +0000246private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000247 SkBitmap fBitmap;
248 SkRect fSrc;
249 SkRect fDst;
250 SkPaint fPaint;
251 SkPaint* fPaintPtr;
252 SkCanvas::DrawBitmapRectFlags fFlags;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000253
254 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000255};
256
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000257class SkDrawDataCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000258public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000259 SkDrawDataCommand(const void* data, size_t length);
260 virtual ~SkDrawDataCommand() { delete [] fData; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000261 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
262private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000263 char* fData;
chudy@google.com902ebe52012-06-29 14:21:22 +0000264 size_t fLength;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000265
266 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000267};
268
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000269class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000270public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000271 SkBeginCommentGroupCommand(const char* description);
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000272 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
273 canvas->beginCommentGroup(fDescription.c_str());
274 };
275private:
276 SkString fDescription;
277
278 typedef SkDrawCommand INHERITED;
279};
280
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000281class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000282public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000283 SkCommentCommand(const char* kywd, const char* value);
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000284 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
285 canvas->addComment(fKywd.c_str(), fValue.c_str());
286 };
287private:
288 SkString fKywd;
289 SkString fValue;
290
291 typedef SkDrawCommand INHERITED;
292};
293
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000294class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000295public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000296 SkEndCommentGroupCommand();
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000297 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
298 canvas->endCommentGroup();
299 };
300private:
301 typedef SkDrawCommand INHERITED;
302};
303
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000304class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000305public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000306 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000307 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000308 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000309private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000310 SkRect fOval;
311 SkPaint fPaint;
312
313 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000314};
315
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000316class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000317public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000318 SkDrawPaintCommand(const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000319 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000320 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000321private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000322 SkPaint fPaint;
323
324 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000325};
326
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000327class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000328public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000329 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000330 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000331 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000332
chudy@google.com902ebe52012-06-29 14:21:22 +0000333private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000334 SkPath fPath;
335 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000336
337 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000338};
339
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000340class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000341public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000342 SkDrawPictureCommand(SkPicture& picture);
chudy@google.com902ebe52012-06-29 14:21:22 +0000343 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000344 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
345
chudy@google.com902ebe52012-06-29 14:21:22 +0000346private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000347 SkPicture fPicture;
348
349 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000350};
351
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000352class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000353public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000354 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000355 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000356 virtual ~SkDrawPointsCommand() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000357 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000358 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000359private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000360 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000361 size_t fCount;
362 SkPoint* fPts;
363 SkPaint fPaint;
364
365 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000366};
367
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000368class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000369public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000370 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000371 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000372 virtual ~SkDrawTextCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000373 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
374private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000375 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000376 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000377 SkScalar fX;
378 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000379 SkPaint fPaint;
380
381 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000382};
383
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000384class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000385public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000386 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
387 const SkPaint& paint);
388 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000389 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
390private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000391 char* fText;
392 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000393 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000394 SkPaint fPaint;
395
396 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000397};
398
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000399class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000400public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000401 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
402 const SkMatrix* matrix, const SkPaint& paint);
403 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000404 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
405private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000406 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000407 size_t fByteLength;
408 SkPath fPath;
409 SkMatrix fMatrix;
410 SkPaint fPaint;
411
412 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000413};
414
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000415class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000416public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000417 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
418 SkScalar constY, const SkPaint& paint);
419 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000420 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
421private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000422 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000423 char* fText;
424 size_t fByteLength;
425 SkScalar fConstY;
426 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000427
428 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000429};
430
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000431class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000432public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000433 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000434 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000435
robertphillips@google.com91217d02013-03-17 18:33:46 +0000436 const SkRect& rect() const { return fRect; }
437 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000438private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000439 SkRect fRect;
440 SkPaint fPaint;
441
442 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000443};
444
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000445class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000446public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000447 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000448 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000449 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000450private:
451 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000452 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000453
454 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000455};
456
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000457class SkDrawDRRectCommand : public SkDrawCommand {
458public:
459 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
460 const SkPaint& paint);
461 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
462 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
463private:
464 SkRRect fOuter;
465 SkRRect fInner;
466 SkPaint fPaint;
467
468 typedef SkDrawCommand INHERITED;
469};
470
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000471class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000472public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000473 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000474 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000475 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000476private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000477 SkBitmap fBitmap;
478 int fLeft;
479 int fTop;
480 SkPaint fPaint;
481 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000482
483 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000484};
485
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000486class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000487public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000488 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
489 const SkPoint vertices[], const SkPoint texs[],
490 const SkColor colors[], SkXfermode* xfermode,
491 const uint16_t indices[], int indexCount,
492 const SkPaint& paint);
493 virtual ~SkDrawVerticesCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +0000494 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
495private:
496 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000497 int fVertexCount;
498 SkPoint* fVertices;
499 SkPoint* fTexs;
500 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000501 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000502 uint16_t* fIndices;
503 int fIndexCount;
504 SkPaint fPaint;
505
506 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000507};
508
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000509class SkRotateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000510public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000511 SkRotateCommand(SkScalar degrees);
chudy@google.com902ebe52012-06-29 14:21:22 +0000512 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
513private:
514 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000515
516 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000517};
518
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000519class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000520public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000521 SkSaveCommand(SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000522 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000523 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000524 virtual Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000525private:
526 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000527
528 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000529};
530
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000531class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000532public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000533 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
534 SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000535 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000536 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000537 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000538 virtual Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000539 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; }
540 virtual bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000541
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000542 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000543
chudy@google.com902ebe52012-06-29 14:21:22 +0000544private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000545 SkRect fBounds;
546 SkPaint fPaint;
547 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000548 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000549
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000550 bool fActive;
551
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000552 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000553};
554
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000555class SkScaleCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000556public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000557 SkScaleCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000558 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000559
560 SkScalar x() const { return fSx; }
561 SkScalar y() const { return fSy; }
562
chudy@google.com902ebe52012-06-29 14:21:22 +0000563private:
564 SkScalar fSx;
565 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000566
567 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000568};
569
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000570class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000571public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000572 SkSetMatrixCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000573 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
574private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000575 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000576
577 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000578};
579
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000580class SkSkewCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000581public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000582 SkSkewCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000583 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
584private:
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 SkTranslateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000592public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000593 SkTranslateCommand(SkScalar dx, SkScalar dy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000594 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000595
596 SkScalar x() const { return fDx; }
597 SkScalar y() const { return fDy; }
598
chudy@google.com902ebe52012-06-29 14:21:22 +0000599private:
600 SkScalar fDx;
601 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000602
603 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000604};
605
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000606class SkPushCullCommand : public SkDrawCommand {
607public:
608 SkPushCullCommand(const SkRect&);
609 virtual void execute(SkCanvas*) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000610 virtual void vizExecute(SkCanvas* canvas) SK_OVERRIDE;
611 virtual Action action() const { return kPushCull_Action; }
612 virtual void setActive(bool active) { fActive = active; }
613 virtual bool active() const { return fActive; }
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000614private:
615 SkRect fCullRect;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000616 bool fActive;
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000617
618 typedef SkDrawCommand INHERITED;
619};
620
621class SkPopCullCommand : public SkDrawCommand {
622public:
623 SkPopCullCommand();
624 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000625 virtual Action action() const { return kPopCull_Action; }
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000626private:
627 typedef SkDrawCommand INHERITED;
628};
629
chudy@google.com902ebe52012-06-29 14:21:22 +0000630#endif