blob: 086627a2f78d3fa22cb9105b30aa23271213ef13 [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"
chudy@google.com902ebe52012-06-29 14:21:22 +000014
15class SkDrawCommand {
16public:
17 /* TODO(chudy): Remove subclasses. */
18 SkDrawCommand();
19
20 virtual ~SkDrawCommand();
21
chudy@google.com97cee972012-08-07 20:41:37 +000022 virtual SkString toString();
chudy@google.com902ebe52012-06-29 14:21:22 +000023
24 virtual const char* toCString() {
25 return GetCommandString(fDrawType);
26 }
27
chudy@google.com0b5bbb02012-07-31 19:55:32 +000028 bool isVisible() const {
29 return fVisible;
30 }
31
32 void setVisible(bool toggle) {
33 fVisible = toggle;
34 }
chudy@google.com902ebe52012-06-29 14:21:22 +000035
chudy@google.com97cee972012-08-07 20:41:37 +000036 SkTDArray<SkString*>* Info() {return &fInfo; };
chudy@google.com902ebe52012-06-29 14:21:22 +000037 virtual void execute(SkCanvas* canvas)=0;
tomhudson@google.com0699e022012-11-27 16:09:42 +000038 /** Does nothing by default, but used by save() and restore()-type
39 subclassse to track unresolved save() calls. */
40 virtual void trackSaveState(int* state) { };
chudy@google.com902ebe52012-06-29 14:21:22 +000041 DrawType getType() { return fDrawType; };
42
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000043 virtual const SkBitmap* getBitmap() const { return NULL; }
44
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000045 static const char* GetCommandString(DrawType type);
46
chudy@google.com902ebe52012-06-29 14:21:22 +000047protected:
48 DrawType fDrawType;
chudy@google.com97cee972012-08-07 20:41:37 +000049 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +000050
51private:
52 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +000053};
54
55class Restore : public SkDrawCommand {
56public:
57 Restore();
58 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +000059 virtual void trackSaveState(int* state) SK_OVERRIDE;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000060
61private:
62 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000063};
64
65class Clear : public SkDrawCommand {
66public:
67 Clear(SkColor color);
68 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
69private:
70 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000071
72 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000073};
74
75class ClipPath : public SkDrawCommand {
76public:
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000077 ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +000078 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000079 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +000080private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000081 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +000082 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000083 bool fDoAA;
84 SkBitmap fBitmap;
robertphillips@google.com91217d02013-03-17 18:33:46 +000085
86 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000087};
88
89class ClipRegion : public SkDrawCommand {
90public:
91 ClipRegion(const SkRegion& region, SkRegion::Op op);
92 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
93private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000094 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +000095 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000096
97 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000098};
99
100class ClipRect : public SkDrawCommand {
101public:
102 ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA);
103 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000104
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000105 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000106 SkRegion::Op op() const { return fOp; }
107 bool doAA() const { return fDoAA; }
108
chudy@google.com902ebe52012-06-29 14:21:22 +0000109private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000110 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000111 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000112 bool fDoAA;
113
114 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000115};
116
robertphillips@google.com67baba42013-01-02 20:20:31 +0000117class ClipRRect : public SkDrawCommand {
118public:
119 ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA);
120 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000121
122 const SkRRect& rrect() const { return fRRect; }
123 SkRegion::Op op() const { return fOp; }
124 bool doAA() const { return fDoAA; }
125
robertphillips@google.com67baba42013-01-02 20:20:31 +0000126private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000127 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000128 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000129 bool fDoAA;
130
131 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000132};
133
chudy@google.com902ebe52012-06-29 14:21:22 +0000134class Concat : public SkDrawCommand {
135public:
136 Concat(const SkMatrix& matrix);
137 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
138private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000139 SkMatrix fMatrix;
140
141 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000142};
143
144class DrawBitmap : public SkDrawCommand {
145public:
146 DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000147 const SkPaint* paint, SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000148 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000149 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000150private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000151 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000152 SkScalar fLeft;
153 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000154 SkPaint fPaint;
155 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000156 SkBitmap fResizedBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000157
158 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000159};
160
161class DrawBitmapMatrix : public SkDrawCommand {
162public:
163 DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000164 const SkPaint* paint, SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000165 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000166 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000167private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000168 SkBitmap fBitmap;
169 SkMatrix fMatrix;
170 SkPaint fPaint;
171 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000172 SkBitmap fResizedBitmap;
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.com24bfdac2013-03-22 16:33:31 +0000180 const SkRect& dst, const SkPaint* paint,
181 SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000182 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000183 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000184private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000185 SkBitmap fBitmap;
186 SkIRect fCenter;
187 SkRect fDst;
188 SkPaint fPaint;
189 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000190 SkBitmap fResizedBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000191
192 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000193};
194
195class DrawBitmapRect : public SkDrawCommand {
196public:
reed@google.com71121732012-09-18 15:14:33 +0000197 DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
skia.committer@gmail.comc76bb232013-03-18 07:01:03 +0000198 const SkRect& dst, const SkPaint* paint,
robertphillips@google.com91217d02013-03-17 18:33:46 +0000199 SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000200 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000201 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000202
203 // 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; }
213 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000214
chudy@google.com902ebe52012-06-29 14:21:22 +0000215private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000216 SkBitmap fBitmap;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000217 SkRect fSrc;
218 SkRect fDst;
219 SkPaint fPaint;
220 SkPaint* fPaintPtr;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000221 SkBitmap fResizedBitmap;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000222
223 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000224};
225
226class DrawData : public SkDrawCommand {
227public:
228 DrawData(const void* data, size_t length);
229 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
230private:
231 const void* fData;
232 size_t fLength;
233};
234
robertphillips@google.com67baba42013-01-02 20:20:31 +0000235class DrawOval : public SkDrawCommand {
236public:
237 DrawOval(const SkRect& oval, const SkPaint& paint);
238 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
239private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000240 SkRect fOval;
241 SkPaint fPaint;
242
243 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000244};
245
chudy@google.com902ebe52012-06-29 14:21:22 +0000246class DrawPaint : public SkDrawCommand {
247public:
248 DrawPaint(const SkPaint& paint);
249 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
250private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000251 SkPaint fPaint;
252
253 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000254};
255
256class DrawPath : public SkDrawCommand {
257public:
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000258 DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000259 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
rmistry@google.com44737652012-11-21 18:37:58 +0000260 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000261
chudy@google.com902ebe52012-06-29 14:21:22 +0000262private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000263 SkPath fPath;
264 SkPaint fPaint;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000265 SkBitmap fBitmap;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000266
267 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000268};
269
270class DrawPicture : public SkDrawCommand {
271public:
272 DrawPicture(SkPicture& picture);
273 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
274private:
275 SkPicture* fPicture;
276};
277
278class DrawPoints : public SkDrawCommand {
279public:
280 DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000281 const SkPaint& paint);
282 virtual ~DrawPoints() { delete [] fPts; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000283 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000284
chudy@google.com902ebe52012-06-29 14:21:22 +0000285private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000286 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000287 size_t fCount;
288 SkPoint* fPts;
289 SkPaint fPaint;
290
291 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000292};
293
294/* TODO(chudy): DrawText is a predefined macro and was breaking something
295 * in the windows build of the debugger.
296 */
297class DrawTextC : public SkDrawCommand {
298public:
299 DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
300 const SkPaint& paint);
301 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
302private:
303 const void* fText;
304 size_t fByteLength;
305 SkScalar fX;
306 SkScalar fY;
307 const SkPaint* fPaint;
308};
309
310class DrawPosText : public SkDrawCommand {
311public:
312 DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000313 const SkPaint& paint);
314 virtual ~DrawPosText() { delete [] fPos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000315 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
316private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000317 SkPoint* fPos;
318 char* fText;
chudy@google.com902ebe52012-06-29 14:21:22 +0000319 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000320 SkPaint fPaint;
chudy@google.com902ebe52012-06-29 14:21:22 +0000321};
322
323class DrawTextOnPath : public SkDrawCommand {
324public:
325 DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000326 const SkMatrix* matrix, const SkPaint& paint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000327 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
328private:
329 const SkMatrix* fMatrix;
330 const void* fText;
331 size_t fByteLength;
332 const SkPath* fPath;
333 const SkPaint* fPaint;
334};
335
336class DrawPosTextH : public SkDrawCommand {
337public:
338 DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
robertphillips@google.com91217d02013-03-17 18:33:46 +0000339 SkScalar constY, const SkPaint& paint);
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000340 virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000341 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
342private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000343 SkScalar* fXpos;
344 char* fText;
chudy@google.com902ebe52012-06-29 14:21:22 +0000345 size_t fByteLength;
346 SkScalar fConstY;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000347 SkPaint fPaint;
348
349 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000350};
351
352class DrawRectC : public SkDrawCommand {
353public:
354 DrawRectC(const SkRect& rect, const SkPaint& paint);
355 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000356
robertphillips@google.com91217d02013-03-17 18:33:46 +0000357 const SkRect& rect() const { return fRect; }
358 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000359private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000360 SkRect fRect;
361 SkPaint fPaint;
362
363 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000364};
365
robertphillips@google.com67baba42013-01-02 20:20:31 +0000366class DrawRRect : public SkDrawCommand {
367public:
368 DrawRRect(const SkRRect& rrect, const SkPaint& paint);
369 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
370private:
371 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000372 SkPaint fPaint;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000373};
374
chudy@google.com902ebe52012-06-29 14:21:22 +0000375class DrawSprite : public SkDrawCommand {
376public:
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000377 DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint,
378 SkBitmap& resizedBitmap);
chudy@google.com902ebe52012-06-29 14:21:22 +0000379 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000380 virtual const SkBitmap* getBitmap() const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000381private:
382 const SkPaint* fPaint;
383 int fLeft;
384 int fTop;
385 const SkBitmap* fBitmap;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000386 SkBitmap fResizedBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000387};
388
389class DrawVertices : public SkDrawCommand {
390public:
391 DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
392 const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
393 SkXfermode* xfermode, const uint16_t indices[], int indexCount,
394 const SkPaint& paint);
395 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
396private:
397 SkCanvas::VertexMode fVmode;
398 int fVertexCount;
399 int fIndexCount;
400 const SkPoint* fVertices;
401 const SkPoint* fTexs;
402 const SkColor* fColors;
403 const uint16_t* fIndices;
404 SkXfermode* fXfermode;
405 const SkPaint* fPaint;
406};
407
408class Rotate : public SkDrawCommand {
409public:
410 Rotate(SkScalar degrees);
411 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
412private:
413 SkScalar fDegrees;
414};
415
416class Save : public SkDrawCommand {
417public:
418 Save(SkCanvas::SaveFlags flags);
419 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000420 virtual void trackSaveState(int* state) SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000421private:
422 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000423
424 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000425};
426
427class SaveLayer : public SkDrawCommand {
428public:
429 SaveLayer(const SkRect* bounds, const SkPaint* paint,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000430 SkCanvas::SaveFlags flags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000431 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000432 virtual void trackSaveState(int* state) SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000433
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000434 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000435
chudy@google.com902ebe52012-06-29 14:21:22 +0000436private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000437 SkRect fBounds;
438 SkPaint fPaint;
439 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000440 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000441
442 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000443};
444
445class Scale : public SkDrawCommand {
446public:
447 Scale(SkScalar sx, SkScalar sy);
448 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000449
450 SkScalar x() const { return fSx; }
451 SkScalar y() const { return fSy; }
452
chudy@google.com902ebe52012-06-29 14:21:22 +0000453private:
454 SkScalar fSx;
455 SkScalar fSy;
456};
457
458class SetMatrix : public SkDrawCommand {
459public:
460 SetMatrix(const SkMatrix& matrix);
461 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
462private:
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000463 SkMatrix fMatrix;
chudy@google.com902ebe52012-06-29 14:21:22 +0000464};
465
466class Skew : public SkDrawCommand {
467public:
468 Skew(SkScalar sx, SkScalar sy);
469 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
470private:
471 SkScalar fSx;
472 SkScalar fSy;
473};
474
475class Translate : public SkDrawCommand {
476public:
477 Translate(SkScalar dx, SkScalar dy);
478 virtual void execute(SkCanvas* canvas) SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000479
480 SkScalar x() const { return fDx; }
481 SkScalar y() const { return fDy; }
482
chudy@google.com902ebe52012-06-29 14:21:22 +0000483private:
484 SkScalar fDx;
485 SkScalar fDy;
486};
487
488#endif