blob: 4b5ab0ac00166a574a9e41468d77f8d22424b3c6 [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
16class SkDrawCommand {
17public:
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
57class Restore : public SkDrawCommand {
58public:
59 Restore();
60 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
67class Clear : public SkDrawCommand {
68public:
69 Clear(SkColor color);
70 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
77class ClipPath : public SkDrawCommand {
78public:
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000079 ClipPath(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
90class ClipRegion : public SkDrawCommand {
91public:
92 ClipRegion(const SkRegion& region, SkRegion::Op op);
93 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
101class ClipRect : public SkDrawCommand {
102public:
103 ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
104 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
robertphillips@google.com67baba42013-01-02 20:20:31 +0000118class ClipRRect : public SkDrawCommand {
119public:
120 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
121 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
chudy@google.com902ebe52012-06-29 14:21:22 +0000136class Concat : public SkDrawCommand {
137public:
138 Concat(const SkMatrix& matrix);
139 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
146class DrawBitmap : public SkDrawCommand {
147public:
148 DrawBitmap(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
162class DrawBitmapMatrix : public SkDrawCommand {
163public:
164 DrawBitmapMatrix(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
177class DrawBitmapNine : public SkDrawCommand {
178public:
179 DrawBitmapNine(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
193class DrawBitmapRect : public SkDrawCommand {
194public:
reed@google.com71121732012-09-18 15:14:33 +0000195 DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000196 const SkRect& dst, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000197 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000198 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000199
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000200 const SkBitmap& bitmap() const { return fBitmap; }
201
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000202 // The non-const 'paint' method allows modification of this object's
203 // SkPaint. For this reason the ctor and setPaint method make a local copy.
204 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
205 // (since only an SkPaint* is passed into the ctor).
206 const SkPaint* paint() const { return fPaintPtr; }
207 SkPaint* paint() { return fPaintPtr; }
208
209 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
210
robertphillips@google.com91217d02013-03-17 18:33:46 +0000211 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
212 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000213
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000214 void setSrcRect(const SkRect& src) { fSrc = src; }
215 void setDstRect(const SkRect& dst) { fDst = dst; }
216
chudy@google.com902ebe52012-06-29 14:21:22 +0000217private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000218 SkBitmap fBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000219 SkRect fSrc;
220 SkRect fDst;
221 SkPaint fPaint;
222 SkPaint* fPaintPtr;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000223
224 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000225};
226
227class DrawData : public SkDrawCommand {
228public:
229 DrawData(const void* data, size_t length);
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000230 virtual ~DrawData() { delete [] fData; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000231 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
232private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000233 char* fData;
chudy@google.com902ebe52012-06-29 14:21:22 +0000234 size_t fLength;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000235
236 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000237};
238
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000239class BeginCommentGroup : public SkDrawCommand {
240public:
241 BeginCommentGroup(const char* description);
242 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
243 canvas->beginCommentGroup(fDescription.c_str());
244 };
245private:
246 SkString fDescription;
247
248 typedef SkDrawCommand INHERITED;
249};
250
251class Comment : public SkDrawCommand {
252public:
253 Comment(const char* kywd, const char* value);
254 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
255 canvas->addComment(fKywd.c_str(), fValue.c_str());
256 };
257private:
258 SkString fKywd;
259 SkString fValue;
260
261 typedef SkDrawCommand INHERITED;
262};
263
264class EndCommentGroup : public SkDrawCommand {
265public:
266 EndCommentGroup();
267 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
268 canvas->endCommentGroup();
269 };
270private:
271 typedef SkDrawCommand INHERITED;
272};
273
robertphillips@google.com67baba42013-01-02 20:20:31 +0000274class DrawOval : public SkDrawCommand {
275public:
276 DrawOval(const SkRect& oval, const SkPaint& paint);
277 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000278 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000279private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000280 SkRect fOval;
281 SkPaint fPaint;
282
283 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000284};
285
chudy@google.com902ebe52012-06-29 14:21:22 +0000286class DrawPaint : public SkDrawCommand {
287public:
288 DrawPaint(const SkPaint& paint);
289 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000290 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000291private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000292 SkPaint fPaint;
293
294 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000295};
296
297class DrawPath : public SkDrawCommand {
298public:
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000299 DrawPath(const SkPath& path, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000300 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000301 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000302
chudy@google.com902ebe52012-06-29 14:21:22 +0000303private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000304 SkPath fPath;
305 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000306
307 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000308};
309
310class DrawPicture : public SkDrawCommand {
311public:
312 DrawPicture(SkPicture& picture);
313 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
314private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000315 SkPicture fPicture;
316
317 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000318};
319
320class DrawPoints : public SkDrawCommand {
321public:
322 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000323 const SkPaint& paint);
324 virtual ~DrawPoints() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000325 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000326 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000327private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000328 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000329 size_t fCount;
330 SkPoint* fPts;
331 SkPaint fPaint;
332
333 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000334};
335
336/* TODO(chudy): DrawText is a predefined macro and was breaking something
337 * in the windows build of the debugger.
338 */
339class DrawTextC : public SkDrawCommand {
340public:
341 DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000342 const SkPaint& paint);
343 virtual ~DrawTextC() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000344 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
345private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000346 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000347 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000348 SkScalar fX;
349 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000350 SkPaint fPaint;
351
352 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000353};
354
355class DrawPosText : public SkDrawCommand {
356public:
357 DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000358 const SkPaint& paint);
359 virtual ~DrawPosText() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000360 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
361private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000362 char* fText;
363 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000364 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000365 SkPaint fPaint;
366
367 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000368};
369
370class DrawTextOnPath : public SkDrawCommand {
371public:
372 DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000373 const SkMatrix* matrix, const SkPaint& paint);
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000374 virtual ~DrawTextOnPath() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000375 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
376private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000377 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000378 size_t fByteLength;
379 SkPath fPath;
380 SkMatrix fMatrix;
381 SkPaint fPaint;
382
383 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000384};
385
386class DrawPosTextH : public SkDrawCommand {
387public:
388 DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
robertphillips@google.com91217d02013-03-17 18:33:46 +0000389 SkScalar constY, const SkPaint& paint);
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000390 virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000391 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
392private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000393 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000394 char* fText;
395 size_t fByteLength;
396 SkScalar fConstY;
397 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000398
399 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000400};
401
402class DrawRectC : public SkDrawCommand {
403public:
404 DrawRectC(const SkRect& rect, const SkPaint& paint);
405 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000406
robertphillips@google.com91217d02013-03-17 18:33:46 +0000407 const SkRect& rect() const { return fRect; }
408 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000409private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000410 SkRect fRect;
411 SkPaint fPaint;
412
413 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000414};
415
robertphillips@google.com67baba42013-01-02 20:20:31 +0000416class DrawRRect : public SkDrawCommand {
417public:
418 DrawRRect(const SkRRect& rrect, const SkPaint& paint);
419 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000420 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000421private:
422 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000423 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000424
425 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000426};
427
chudy@google.com902ebe52012-06-29 14:21:22 +0000428class DrawSprite : public SkDrawCommand {
429public:
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000430 DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000431 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000432 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000433private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000434 SkBitmap fBitmap;
435 int fLeft;
436 int fTop;
437 SkPaint fPaint;
438 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000439
440 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000441};
442
443class DrawVertices : public SkDrawCommand {
444public:
445 DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
skia.committer@gmail.come60ed082013-03-26 07:01:04 +0000446 const SkPoint vertices[], const SkPoint texs[],
447 const SkColor colors[], SkXfermode* xfermode,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000448 const uint16_t indices[], int indexCount,
449 const SkPaint& paint);
450 virtual ~DrawVertices();
chudy@google.com902ebe52012-06-29 14:21:22 +0000451 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
452private:
453 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000454 int fVertexCount;
455 SkPoint* fVertices;
456 SkPoint* fTexs;
457 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000458 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000459 uint16_t* fIndices;
460 int fIndexCount;
461 SkPaint fPaint;
462
463 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000464};
465
466class Rotate : public SkDrawCommand {
467public:
468 Rotate(SkScalar degrees);
469 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
470private:
471 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000472
473 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000474};
475
476class Save : public SkDrawCommand {
477public:
478 Save(SkCanvas::SaveFlags flags);
479 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000480 virtual void trackSaveState(int* state) SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000481private:
482 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000483
484 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000485};
486
487class SaveLayer : public SkDrawCommand {
488public:
489 SaveLayer(const SkRect* bounds, const SkPaint* paint,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000490 SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000491 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000492 virtual void trackSaveState(int* state) SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000493
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000494 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000495
chudy@google.com902ebe52012-06-29 14:21:22 +0000496private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000497 SkRect fBounds;
498 SkPaint fPaint;
499 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000500 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
505class Scale : public SkDrawCommand {
506public:
507 Scale(SkScalar sx, SkScalar sy);
508 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000509
510 SkScalar x() const { return fSx; }
511 SkScalar y() const { return fSy; }
512
chudy@google.com902ebe52012-06-29 14:21:22 +0000513private:
514 SkScalar fSx;
515 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000516
517 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000518};
519
520class SetMatrix : public SkDrawCommand {
521public:
522 SetMatrix(const SkMatrix& matrix);
523 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
524private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000525 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000526
527 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000528};
529
530class Skew : public SkDrawCommand {
531public:
532 Skew(SkScalar sx, SkScalar sy);
533 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
534private:
535 SkScalar fSx;
536 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000537
538 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000539};
540
541class Translate : public SkDrawCommand {
542public:
543 Translate(SkScalar dx, SkScalar dy);
544 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000545
546 SkScalar x() const { return fDx; }
547 SkScalar y() const { return fDy; }
548
chudy@google.com902ebe52012-06-29 14:21:22 +0000549private:
550 SkScalar fDx;
551 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000552
553 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000554};
555
556#endif