blob: e03eb072b97912fafb2790383c6ff7671205f4b2 [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; };
chudy@google.com902ebe52012-06-29 14:21:22 +000039 virtual void execute(SkCanvas* canvas)=0;
tomhudson@google.com0699e022012-11-27 16:09:42 +000040 /** Does nothing by default, but used by save() and restore()-type
41 subclassse to track unresolved save() calls. */
42 virtual void trackSaveState(int* state) { };
chudy@google.com902ebe52012-06-29 14:21:22 +000043 DrawType getType() { return fDrawType; };
44
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000045 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000046
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000047 static const char* GetCommandString(DrawType type);
48
chudy@google.com902ebe52012-06-29 14:21:22 +000049protected:
50 DrawType fDrawType;
chudy@google.com97cee972012-08-07 20:41:37 +000051 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +000052
53private:
54 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +000055};
56
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000057class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000058public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000059 SkRestoreCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +000060 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +000061 virtual void trackSaveState(int* state) SK_OVERRIDE;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000062
63private:
64 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000065};
66
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000067class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000068public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000069 SkClearCommand(SkColor color);
chudy@google.com902ebe52012-06-29 14:21:22 +000070 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
71private:
72 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000073
74 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000075};
76
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000077class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000078public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000079 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
chudy@google.com902ebe52012-06-29 14:21:22 +000080 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000081 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +000082private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000083 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +000084 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000085 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +000086
87 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000088};
89
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000090class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000091public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000092 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
chudy@google.com902ebe52012-06-29 14:21:22 +000093 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
94private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000095 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +000096 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000097
98 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000099};
100
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000101class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000102public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000103 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000104 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000105
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000106 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000107 SkRegion::Op op() const { return fOp; }
108 bool doAA() const { return fDoAA; }
109
chudy@google.com902ebe52012-06-29 14:21:22 +0000110private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000111 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000112 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000113 bool fDoAA;
114
115 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000116};
117
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000118class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000119public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000120 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000121 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000122 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000123
124 const SkRRect& rrect() const { return fRRect; }
125 SkRegion::Op op() const { return fOp; }
126 bool doAA() const { return fDoAA; }
127
robertphillips@google.com67baba42013-01-02 20:20:31 +0000128private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000129 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000130 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000131 bool fDoAA;
132
133 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000134};
135
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000136class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000137public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000138 SkConcatCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000139 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
140private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000141 SkMatrix fMatrix;
142
143 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000144};
145
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000146class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000147public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000148 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000149 const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +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;
chudy@google.com902ebe52012-06-29 14:21:22 +0000152private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000153 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000154 SkScalar fLeft;
155 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000156 SkPaint fPaint;
157 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000158
159 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000160};
161
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000162class SkDrawBitmapMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000163public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000164 SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, const SkMatrix& matrix,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000165 const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000166 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000167 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000168private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000169 SkBitmap fBitmap;
170 SkMatrix fMatrix;
171 SkPaint fPaint;
172 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000173
174 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000175};
176
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000177class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000178public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000179 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000180 const SkRect& dst, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000181 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000182 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000183private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000184 SkBitmap fBitmap;
185 SkIRect fCenter;
186 SkRect fDst;
187 SkPaint fPaint;
188 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000189
190 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000191};
192
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000193class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000194public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000195 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000196 const SkRect& dst, const SkPaint* paint,
197 SkCanvas::DrawBitmapRectFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000198 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000199 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000200
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000201 const SkBitmap& bitmap() const { return fBitmap; }
202
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000203 // The non-const 'paint' method allows modification of this object's
204 // SkPaint. For this reason the ctor and setPaint method make a local copy.
205 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
206 // (since only an SkPaint* is passed into the ctor).
207 const SkPaint* paint() const { return fPaintPtr; }
208 SkPaint* paint() { return fPaintPtr; }
209
210 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
211
robertphillips@google.com91217d02013-03-17 18:33:46 +0000212 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000213 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000214
215 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000216 void setDstRect(const SkRect& dst) { fDst = dst; }
217
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000218 SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
219 void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
220
chudy@google.com902ebe52012-06-29 14:21:22 +0000221private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000222 SkBitmap fBitmap;
223 SkRect fSrc;
224 SkRect fDst;
225 SkPaint fPaint;
226 SkPaint* fPaintPtr;
227 SkCanvas::DrawBitmapRectFlags fFlags;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000228
229 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000230};
231
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000232class SkDrawDataCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000233public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000234 SkDrawDataCommand(const void* data, size_t length);
235 virtual ~SkDrawDataCommand() { delete [] fData; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000236 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
237private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000238 char* fData;
chudy@google.com902ebe52012-06-29 14:21:22 +0000239 size_t fLength;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000240
241 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000242};
243
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000244class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000245public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000246 SkBeginCommentGroupCommand(const char* description);
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000247 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
248 canvas->beginCommentGroup(fDescription.c_str());
249 };
250private:
251 SkString fDescription;
252
253 typedef SkDrawCommand INHERITED;
254};
255
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000256class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000257public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000258 SkCommentCommand(const char* kywd, const char* value);
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000259 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
260 canvas->addComment(fKywd.c_str(), fValue.c_str());
261 };
262private:
263 SkString fKywd;
264 SkString fValue;
265
266 typedef SkDrawCommand INHERITED;
267};
268
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000269class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000270public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000271 SkEndCommentGroupCommand();
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000272 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
273 canvas->endCommentGroup();
274 };
275private:
276 typedef SkDrawCommand INHERITED;
277};
278
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000279class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000280public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000281 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000282 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000283 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000284private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000285 SkRect fOval;
286 SkPaint fPaint;
287
288 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000289};
290
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000291class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000292public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000293 SkDrawPaintCommand(const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000294 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000295 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000296private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000297 SkPaint fPaint;
298
299 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000300};
301
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000302class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000303public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000304 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000305 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000306 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000307
chudy@google.com902ebe52012-06-29 14:21:22 +0000308private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000309 SkPath fPath;
310 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000311
312 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000313};
314
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000315class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000316public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000317 SkDrawPictureCommand(SkPicture& picture);
chudy@google.com902ebe52012-06-29 14:21:22 +0000318 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000319 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
320
chudy@google.com902ebe52012-06-29 14:21:22 +0000321private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000322 SkPicture fPicture;
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 SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000328public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000329 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000330 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000331 virtual ~SkDrawPointsCommand() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000332 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000333 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000334private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000335 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000336 size_t fCount;
337 SkPoint* fPts;
338 SkPaint fPaint;
339
340 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000341};
342
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000343class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000344public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000345 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000346 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000347 virtual ~SkDrawTextCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000348 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
349private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000350 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000351 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000352 SkScalar fX;
353 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000354 SkPaint fPaint;
355
356 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000357};
358
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000359class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000360public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000361 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
362 const SkPaint& paint);
363 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000364 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
365private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000366 char* fText;
367 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000368 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000369 SkPaint fPaint;
370
371 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000372};
373
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000374class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000375public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000376 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
377 const SkMatrix* matrix, const SkPaint& paint);
378 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000379 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
380private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000381 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000382 size_t fByteLength;
383 SkPath fPath;
384 SkMatrix fMatrix;
385 SkPaint fPaint;
386
387 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000388};
389
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000390class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000391public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000392 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
393 SkScalar constY, const SkPaint& paint);
394 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000395 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
396private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000397 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000398 char* fText;
399 size_t fByteLength;
400 SkScalar fConstY;
401 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000402
403 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000404};
405
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000406class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000407public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000408 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000409 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000410
robertphillips@google.com91217d02013-03-17 18:33:46 +0000411 const SkRect& rect() const { return fRect; }
412 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000413private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000414 SkRect fRect;
415 SkPaint fPaint;
416
417 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000418};
419
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000420class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000421public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000422 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000423 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000424 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000425private:
426 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000427 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000428
429 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000430};
431
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000432class SkDrawDRRectCommand : public SkDrawCommand {
433public:
434 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
435 const SkPaint& paint);
436 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
437 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
438private:
439 SkRRect fOuter;
440 SkRRect fInner;
441 SkPaint fPaint;
442
443 typedef SkDrawCommand INHERITED;
444};
445
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000446class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000447public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000448 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000449 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000450 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000451private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000452 SkBitmap fBitmap;
453 int fLeft;
454 int fTop;
455 SkPaint fPaint;
456 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000457
458 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000459};
460
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000461class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000462public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000463 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
464 const SkPoint vertices[], const SkPoint texs[],
465 const SkColor colors[], SkXfermode* xfermode,
466 const uint16_t indices[], int indexCount,
467 const SkPaint& paint);
468 virtual ~SkDrawVerticesCommand();
chudy@google.com902ebe52012-06-29 14:21:22 +0000469 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
470private:
471 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000472 int fVertexCount;
473 SkPoint* fVertices;
474 SkPoint* fTexs;
475 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000476 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000477 uint16_t* fIndices;
478 int fIndexCount;
479 SkPaint fPaint;
480
481 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000482};
483
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000484class SkRotateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000485public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000486 SkRotateCommand(SkScalar degrees);
chudy@google.com902ebe52012-06-29 14:21:22 +0000487 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
488private:
489 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000490
491 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000492};
493
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000494class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000495public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000496 SkSaveCommand(SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000497 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000498 virtual void trackSaveState(int* state) SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000499private:
500 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000501
502 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000503};
504
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000505class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000506public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000507 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
508 SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000509 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000510 virtual void trackSaveState(int* state) SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000511
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000512 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000513
chudy@google.com902ebe52012-06-29 14:21:22 +0000514private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000515 SkRect fBounds;
516 SkPaint fPaint;
517 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000518 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +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 SkScaleCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000524public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000525 SkScaleCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000526 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000527
528 SkScalar x() const { return fSx; }
529 SkScalar y() const { return fSy; }
530
chudy@google.com902ebe52012-06-29 14:21:22 +0000531private:
532 SkScalar fSx;
533 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000534
535 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000536};
537
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000538class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000539public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000540 SkSetMatrixCommand(const SkMatrix& matrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000541 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
542private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000543 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000544
545 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000546};
547
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000548class SkSkewCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000549public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000550 SkSkewCommand(SkScalar sx, SkScalar sy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000551 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
552private:
553 SkScalar fSx;
554 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000555
556 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000557};
558
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000559class SkTranslateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000560public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000561 SkTranslateCommand(SkScalar dx, SkScalar dy);
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 fDx; }
565 SkScalar y() const { return fDy; }
566
chudy@google.com902ebe52012-06-29 14:21:22 +0000567private:
568 SkScalar fDx;
569 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000570
571 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000572};
573
574#endif