blob: e73295aa7e145a30bf7a90588a6f6e7cb21a42ab [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.com6dec8fc2012-11-21 17:11:02 +000045 virtual const SkBitmap* getBitmap() const { return NULL; }
46
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.com6dec8fc2012-11-21 17:11:02 +000079 ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +000080 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000081 virtual const SkBitmap* getBitmap() 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;
86 SkBitmap fBitmap;
robertphillips@google.com91217d02013-03-17 18:33:46 +000087
88 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000089};
90
91class ClipRegion : public SkDrawCommand {
92public:
93 ClipRegion(const SkRegion& region, SkRegion::Op op);
94 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
95private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000096 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +000097 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000098
99 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000100};
101
102class ClipRect : public SkDrawCommand {
103public:
104 ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
105 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000106
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000107 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000108 SkRegion::Op op() const { return fOp; }
109 bool doAA() const { return fDoAA; }
110
chudy@google.com902ebe52012-06-29 14:21:22 +0000111private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000112 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000113 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000114 bool fDoAA;
115
116 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000117};
118
robertphillips@google.com67baba42013-01-02 20:20:31 +0000119class ClipRRect : public SkDrawCommand {
120public:
121 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
122 virtual void execute(SkCanvas* canvas) 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.com24bfdac2013-03-22 16:33:31 +0000149 const SkPaint* paint, SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000150 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000151 virtual const SkBitmap* getBitmap() 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.com53ec73d2012-11-26 13:09:17 +0000158 SkBitmap fResizedBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000159
160 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000161};
162
163class DrawBitmapMatrix : public SkDrawCommand {
164public:
165 DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000166 const SkPaint* paint, SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000167 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000168 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000169private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000170 SkBitmap fBitmap;
171 SkMatrix fMatrix;
172 SkPaint fPaint;
173 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000174 SkBitmap fResizedBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000175
176 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000177};
178
179class DrawBitmapNine : public SkDrawCommand {
180public:
181 DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
skia.committer@gmail.com7e328512013-03-23 07:01:28 +0000182 const SkRect& dst, const SkPaint* paint,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000183 SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000184 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000185 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000186private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000187 SkBitmap fBitmap;
188 SkIRect fCenter;
189 SkRect fDst;
190 SkPaint fPaint;
191 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000192 SkBitmap fResizedBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000193
194 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000195};
196
197class DrawBitmapRect : public SkDrawCommand {
198public:
reed@google.com71121732012-09-18 15:14:33 +0000199 DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
skia.committer@gmail.comc76bb232013-03-18 07:01:03 +0000200 const SkRect& dst, const SkPaint* paint,
robertphillips@google.com91217d02013-03-17 18:33:46 +0000201 SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000202 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000203 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000204
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000205 const SkBitmap& bitmap() const { return fBitmap; }
206
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000207 // The non-const 'paint' method allows modification of this object's
208 // SkPaint. For this reason the ctor and setPaint method make a local copy.
209 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
210 // (since only an SkPaint* is passed into the ctor).
211 const SkPaint* paint() const { return fPaintPtr; }
212 SkPaint* paint() { return fPaintPtr; }
213
214 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
215
robertphillips@google.com91217d02013-03-17 18:33:46 +0000216 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
217 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000218
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000219 void setSrcRect(const SkRect& src) { fSrc = src; }
220 void setDstRect(const SkRect& dst) { fDst = dst; }
221
chudy@google.com902ebe52012-06-29 14:21:22 +0000222private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000223 SkBitmap fBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000224 SkRect fSrc;
225 SkRect fDst;
226 SkPaint fPaint;
227 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000228 SkBitmap fResizedBitmap;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000229
230 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000231};
232
233class DrawData : public SkDrawCommand {
234public:
235 DrawData(const void* data, size_t length);
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000236 virtual ~DrawData() { delete [] fData; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000237 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
238private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000239 char* fData;
chudy@google.com902ebe52012-06-29 14:21:22 +0000240 size_t fLength;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000241
242 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000243};
244
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000245class BeginCommentGroup : public SkDrawCommand {
246public:
247 BeginCommentGroup(const char* description);
248 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
249 canvas->beginCommentGroup(fDescription.c_str());
250 };
251private:
252 SkString fDescription;
253
254 typedef SkDrawCommand INHERITED;
255};
256
257class Comment : public SkDrawCommand {
258public:
259 Comment(const char* kywd, const char* value);
260 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
261 canvas->addComment(fKywd.c_str(), fValue.c_str());
262 };
263private:
264 SkString fKywd;
265 SkString fValue;
266
267 typedef SkDrawCommand INHERITED;
268};
269
270class EndCommentGroup : public SkDrawCommand {
271public:
272 EndCommentGroup();
273 virtual void execute(SkCanvas* canvas) SK_OVERRIDE {
274 canvas->endCommentGroup();
275 };
276private:
277 typedef SkDrawCommand INHERITED;
278};
279
robertphillips@google.com67baba42013-01-02 20:20:31 +0000280class DrawOval : public SkDrawCommand {
281public:
282 DrawOval(const SkRect& oval, const SkPaint& paint);
283 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
284private:
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
chudy@google.com902ebe52012-06-29 14:21:22 +0000291class DrawPaint : public SkDrawCommand {
292public:
293 DrawPaint(const SkPaint& paint);
294 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
295private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000296 SkPaint fPaint;
297
298 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000299};
300
301class DrawPath : public SkDrawCommand {
302public:
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000303 DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000304 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
rmistry@google.com44737652012-11-21 18:37:58 +0000305 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000306
chudy@google.com902ebe52012-06-29 14:21:22 +0000307private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000308 SkPath fPath;
309 SkPaint fPaint;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000310 SkBitmap fBitmap;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000311
312 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000313};
314
315class DrawPicture : public SkDrawCommand {
316public:
317 DrawPicture(SkPicture& picture);
318 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
319private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000320 SkPicture fPicture;
321
322 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000323};
324
325class DrawPoints : public SkDrawCommand {
326public:
327 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000328 const SkPaint& paint);
329 virtual ~DrawPoints() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000330 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000331
chudy@google.com902ebe52012-06-29 14:21:22 +0000332private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000333 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000334 size_t fCount;
335 SkPoint* fPts;
336 SkPaint fPaint;
337
338 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000339};
340
341/* TODO(chudy): DrawText is a predefined macro and was breaking something
342 * in the windows build of the debugger.
343 */
344class DrawTextC : public SkDrawCommand {
345public:
346 DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000347 const SkPaint& paint);
348 virtual ~DrawTextC() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000349 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
350private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000351 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000352 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000353 SkScalar fX;
354 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000355 SkPaint fPaint;
356
357 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000358};
359
360class DrawPosText : public SkDrawCommand {
361public:
362 DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000363 const SkPaint& paint);
364 virtual ~DrawPosText() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000365 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
366private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000367 char* fText;
368 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000369 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000370 SkPaint fPaint;
371
372 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000373};
374
375class DrawTextOnPath : public SkDrawCommand {
376public:
377 DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000378 const SkMatrix* matrix, const SkPaint& paint);
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000379 virtual ~DrawTextOnPath() { delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000380 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
381private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000382 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000383 size_t fByteLength;
384 SkPath fPath;
385 SkMatrix fMatrix;
386 SkPaint fPaint;
387
388 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000389};
390
391class DrawPosTextH : public SkDrawCommand {
392public:
393 DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
robertphillips@google.com91217d02013-03-17 18:33:46 +0000394 SkScalar constY, const SkPaint& paint);
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000395 virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000396 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
397private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000398 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000399 char* fText;
400 size_t fByteLength;
401 SkScalar fConstY;
402 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000403
404 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000405};
406
407class DrawRectC : public SkDrawCommand {
408public:
409 DrawRectC(const SkRect& rect, const SkPaint& paint);
410 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000411
robertphillips@google.com91217d02013-03-17 18:33:46 +0000412 const SkRect& rect() const { return fRect; }
413 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000414private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000415 SkRect fRect;
416 SkPaint fPaint;
417
418 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000419};
420
robertphillips@google.com67baba42013-01-02 20:20:31 +0000421class DrawRRect : public SkDrawCommand {
422public:
423 DrawRRect(const SkRRect& rrect, const SkPaint& paint);
424 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
425private:
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
chudy@google.com902ebe52012-06-29 14:21:22 +0000432class DrawSprite : public SkDrawCommand {
433public:
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000434 DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint,
435 SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000436 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000437 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000438private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000439 SkBitmap fBitmap;
440 int fLeft;
441 int fTop;
442 SkPaint fPaint;
443 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000444 SkBitmap fResizedBitmap;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000445
446 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000447};
448
449class DrawVertices : public SkDrawCommand {
450public:
451 DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
skia.committer@gmail.come60ed082013-03-26 07:01:04 +0000452 const SkPoint vertices[], const SkPoint texs[],
453 const SkColor colors[], SkXfermode* xfermode,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000454 const uint16_t indices[], int indexCount,
455 const SkPaint& paint);
456 virtual ~DrawVertices();
chudy@google.com902ebe52012-06-29 14:21:22 +0000457 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
458private:
459 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000460 int fVertexCount;
461 SkPoint* fVertices;
462 SkPoint* fTexs;
463 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000464 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000465 uint16_t* fIndices;
466 int fIndexCount;
467 SkPaint fPaint;
468
469 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000470};
471
472class Rotate : public SkDrawCommand {
473public:
474 Rotate(SkScalar degrees);
475 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
476private:
477 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000478
479 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000480};
481
482class Save : public SkDrawCommand {
483public:
484 Save(SkCanvas::SaveFlags flags);
485 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000486 virtual void trackSaveState(int* state) SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000487private:
488 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000489
490 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000491};
492
493class SaveLayer : public SkDrawCommand {
494public:
495 SaveLayer(const SkRect* bounds, const SkPaint* paint,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000496 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;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000499
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000500 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000501
chudy@google.com902ebe52012-06-29 14:21:22 +0000502private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000503 SkRect fBounds;
504 SkPaint fPaint;
505 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000506 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000507
508 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000509};
510
511class Scale : public SkDrawCommand {
512public:
513 Scale(SkScalar sx, SkScalar sy);
514 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000515
516 SkScalar x() const { return fSx; }
517 SkScalar y() const { return fSy; }
518
chudy@google.com902ebe52012-06-29 14:21:22 +0000519private:
520 SkScalar fSx;
521 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000522
523 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000524};
525
526class SetMatrix : public SkDrawCommand {
527public:
528 SetMatrix(const SkMatrix& matrix);
529 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
530private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000531 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000532
533 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000534};
535
536class Skew : public SkDrawCommand {
537public:
538 Skew(SkScalar sx, SkScalar sy);
539 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
540private:
541 SkScalar fSx;
542 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000543
544 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000545};
546
547class Translate : public SkDrawCommand {
548public:
549 Translate(SkScalar dx, SkScalar dy);
550 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000551
552 SkScalar x() const { return fDx; }
553 SkScalar y() const { return fDy; }
554
chudy@google.com902ebe52012-06-29 14:21:22 +0000555private:
556 SkScalar fDx;
557 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000558
559 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000560};
561
562#endif