blob: 22ee700dd7ebd820640a7f48b78ba76aa7875cce [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:
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000018 SkDrawCommand(DrawType drawType);
chudy@google.com902ebe52012-06-29 14:21:22 +000019
20 virtual ~SkDrawCommand();
21
fmalita8c89c522014-11-08 16:18:56 -080022 virtual SkString toString() const;
chudy@google.com902ebe52012-06-29 14:21:22 +000023
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000024 void setOffset(size_t offset) { fOffset = offset; }
fmalita8c89c522014-11-08 16:18:56 -080025 size_t offset() const { return fOffset; }
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000026
fmalita8c89c522014-11-08 16:18:56 -080027 virtual const char* toCString() const {
chudy@google.com902ebe52012-06-29 14:21:22 +000028 return GetCommandString(fDrawType);
29 }
30
chudy@google.com0b5bbb02012-07-31 19:55:32 +000031 bool isVisible() const {
32 return fVisible;
33 }
34
35 void setVisible(bool toggle) {
36 fVisible = toggle;
37 }
chudy@google.com902ebe52012-06-29 14:21:22 +000038
fmalita8c89c522014-11-08 16:18:56 -080039 const SkTDArray<SkString*>* Info() const { return &fInfo; }
40 virtual void execute(SkCanvas*) const = 0;
41 virtual void vizExecute(SkCanvas*) const {}
robertphillips70171682014-10-16 14:28:28 -070042
fmalita8c89c522014-11-08 16:18:56 -080043 virtual void setUserMatrix(const SkMatrix&) {}
robertphillips70171682014-10-16 14:28:28 -070044
tomhudson@google.com0699e022012-11-27 16:09:42 +000045 /** Does nothing by default, but used by save() and restore()-type
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000046 subclasses to track unresolved save() calls. */
fmalita8c89c522014-11-08 16:18:56 -080047 virtual void trackSaveState(int* state) {}
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000048
mtkleinf0f14112014-12-12 08:46:25 -080049 // The next "active" system is only used by save, saveLayer, and restore.
50 // It is used to determine which saveLayers are currently active (at a
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000051 // given point in the rendering).
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000052 // saves just return a kPushLayer action but don't track active state
53 // restores just return a kPopLayer action
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000054 // saveLayers return kPushLayer but also track the active state
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000055 enum Action {
56 kNone_Action,
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000057 kPopLayer_Action,
58 kPushLayer_Action,
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000059 };
60 virtual Action action() const { return kNone_Action; }
61 virtual void setActive(bool active) {}
62 virtual bool active() const { return false; }
63
fmalita8c89c522014-11-08 16:18:56 -080064 DrawType getType() const { return fDrawType; }
chudy@google.com902ebe52012-06-29 14:21:22 +000065
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000066 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000067
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000068 static const char* GetCommandString(DrawType type);
69
chudy@google.com902ebe52012-06-29 14:21:22 +000070protected:
chudy@google.com97cee972012-08-07 20:41:37 +000071 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +000072
73private:
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000074 DrawType fDrawType;
75 size_t fOffset;
76 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +000077};
78
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000079class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000080public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000081 SkRestoreCommand();
mtklein72c9faa2015-01-09 10:06:39 -080082 void execute(SkCanvas* canvas) const SK_OVERRIDE;
83 void trackSaveState(int* state) SK_OVERRIDE;
84 Action action() const SK_OVERRIDE { return kPopLayer_Action; }
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000085
86private:
87 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000088};
89
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000090class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000091public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000092 SkClearCommand(SkColor color);
mtklein72c9faa2015-01-09 10:06:39 -080093 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +000094private:
95 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000096
97 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000098};
99
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000100class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000101public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000102 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800103 void execute(SkCanvas* canvas) const SK_OVERRIDE;
104 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000105private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000106 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +0000107 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000108 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000109
110 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000111};
112
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000113class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000114public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000115 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
mtklein72c9faa2015-01-09 10:06:39 -0800116 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000117private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000118 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +0000119 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000120
121 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000122};
123
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000124class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000125public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000126 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800127 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000128
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000129 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000130 SkRegion::Op op() const { return fOp; }
131 bool doAA() const { return fDoAA; }
132
chudy@google.com902ebe52012-06-29 14:21:22 +0000133private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000134 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000135 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000136 bool fDoAA;
137
138 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000139};
140
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000141class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000142public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000143 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800144 void execute(SkCanvas* canvas) const SK_OVERRIDE;
145 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000146
147 const SkRRect& rrect() const { return fRRect; }
148 SkRegion::Op op() const { return fOp; }
149 bool doAA() const { return fDoAA; }
150
robertphillips@google.com67baba42013-01-02 20:20:31 +0000151private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000152 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000153 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000154 bool fDoAA;
155
156 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000157};
158
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000159class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000160public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000161 SkConcatCommand(const SkMatrix& matrix);
mtklein72c9faa2015-01-09 10:06:39 -0800162 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000163private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000164 SkMatrix fMatrix;
165
166 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000167};
168
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000169class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000170public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000171 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000172 const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800173 void execute(SkCanvas* canvas) const SK_OVERRIDE;
174 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000175private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000176 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000177 SkScalar fLeft;
178 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000179 SkPaint fPaint;
180 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000181
182 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000183};
184
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000185class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000186public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000187 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000188 const SkRect& dst, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800189 void execute(SkCanvas* canvas) const SK_OVERRIDE;
190 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000191private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000192 SkBitmap fBitmap;
193 SkIRect fCenter;
194 SkRect fDst;
195 SkPaint fPaint;
196 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000197
198 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000199};
200
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000201class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000202public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000203 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000204 const SkRect& dst, const SkPaint* paint,
205 SkCanvas::DrawBitmapRectFlags flags);
mtklein72c9faa2015-01-09 10:06:39 -0800206 void execute(SkCanvas* canvas) const SK_OVERRIDE;
207 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000208
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000209 const SkBitmap& bitmap() const { return fBitmap; }
210
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000211 // The non-const 'paint' method allows modification of this object's
212 // SkPaint. For this reason the ctor and setPaint method make a local copy.
213 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
214 // (since only an SkPaint* is passed into the ctor).
215 const SkPaint* paint() const { return fPaintPtr; }
216 SkPaint* paint() { return fPaintPtr; }
217
218 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
219
robertphillips@google.com91217d02013-03-17 18:33:46 +0000220 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000221 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000222
223 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000224 void setDstRect(const SkRect& dst) { fDst = dst; }
225
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000226 SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
227 void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
228
chudy@google.com902ebe52012-06-29 14:21:22 +0000229private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000230 SkBitmap fBitmap;
231 SkRect fSrc;
232 SkRect fDst;
233 SkPaint fPaint;
234 SkPaint* fPaintPtr;
235 SkCanvas::DrawBitmapRectFlags fFlags;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000236
237 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000238};
239
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000240class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000241public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000242 SkBeginCommentGroupCommand(const char* description);
mtklein72c9faa2015-01-09 10:06:39 -0800243 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000244 canvas->beginCommentGroup(fDescription.c_str());
245 };
246private:
247 SkString fDescription;
248
249 typedef SkDrawCommand INHERITED;
250};
251
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000252class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000253public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000254 SkCommentCommand(const char* kywd, const char* value);
mtklein72c9faa2015-01-09 10:06:39 -0800255 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000256 canvas->addComment(fKywd.c_str(), fValue.c_str());
257 };
258private:
259 SkString fKywd;
260 SkString fValue;
261
262 typedef SkDrawCommand INHERITED;
263};
264
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000265class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000266public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000267 SkEndCommentGroupCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800268 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000269 canvas->endCommentGroup();
270 };
271private:
272 typedef SkDrawCommand INHERITED;
273};
274
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000275class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000276public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000277 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800278 void execute(SkCanvas* canvas) const SK_OVERRIDE;
279 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000280private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000281 SkRect fOval;
282 SkPaint fPaint;
283
284 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000285};
286
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000287class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000288public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000289 SkDrawPaintCommand(const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800290 void execute(SkCanvas* canvas) const SK_OVERRIDE;
291 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000292private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000293 SkPaint fPaint;
294
295 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000296};
297
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000298class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000299public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000300 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800301 void execute(SkCanvas* canvas) const SK_OVERRIDE;
302 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000303
chudy@google.com902ebe52012-06-29 14:21:22 +0000304private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000305 SkPath fPath;
306 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000307
308 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000309};
310
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000311class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000312public:
robertphillipsb3f319f2014-08-13 10:46:23 -0700313 SkDrawPictureCommand(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800314 void execute(SkCanvas* canvas) const SK_OVERRIDE;
315 bool render(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000316
chudy@google.com902ebe52012-06-29 14:21:22 +0000317private:
robertphillips9b14f262014-06-04 05:40:44 -0700318 SkAutoTUnref<const SkPicture> fPicture;
robertphillipsb3f319f2014-08-13 10:46:23 -0700319 SkMatrix fMatrix;
320 SkMatrix* fMatrixPtr;
321 SkPaint fPaint;
322 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000323
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[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000330 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000331 virtual ~SkDrawPointsCommand() { delete [] fPts; }
mtklein72c9faa2015-01-09 10:06:39 -0800332 void execute(SkCanvas* canvas) const SK_OVERRIDE;
333 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,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000346 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000347 virtual ~SkDrawTextCommand() { delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800348 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000349private:
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; }
mtklein72c9faa2015-01-09 10:06:39 -0800364 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000365private:
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; }
mtklein72c9faa2015-01-09 10:06:39 -0800379 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000380private:
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; }
mtklein72c9faa2015-01-09 10:06:39 -0800395 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000396private:
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
fmalitab7425172014-08-26 07:56:44 -0700406class SkDrawTextBlobCommand : public SkDrawCommand {
407public:
408 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
409
mtklein72c9faa2015-01-09 10:06:39 -0800410 void execute(SkCanvas* canvas) const SK_OVERRIDE;
411 bool render(SkCanvas* canvas) const SK_OVERRIDE;
fmalitab7425172014-08-26 07:56:44 -0700412
413private:
414 SkAutoTUnref<const SkTextBlob> fBlob;
415 SkScalar fXPos;
416 SkScalar fYPos;
417 SkPaint fPaint;
418
419 typedef SkDrawCommand INHERITED;
420};
421
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000422class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000423public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000424 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800425 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000426
robertphillips@google.com91217d02013-03-17 18:33:46 +0000427 const SkRect& rect() const { return fRect; }
428 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000429private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000430 SkRect fRect;
431 SkPaint fPaint;
432
433 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000434};
435
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000436class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000437public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000438 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800439 void execute(SkCanvas* canvas) const SK_OVERRIDE;
440 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000441private:
442 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000443 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000444
445 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000446};
447
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000448class SkDrawDRRectCommand : public SkDrawCommand {
449public:
450 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
451 const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800452 void execute(SkCanvas* canvas) const SK_OVERRIDE;
453 bool render(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000454private:
455 SkRRect fOuter;
456 SkRRect fInner;
457 SkPaint fPaint;
458
459 typedef SkDrawCommand INHERITED;
460};
461
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000462class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000463public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000464 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800465 void execute(SkCanvas* canvas) const SK_OVERRIDE;
466 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000467private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000468 SkBitmap fBitmap;
469 int fLeft;
470 int fTop;
471 SkPaint fPaint;
472 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000473
474 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000475};
476
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000477class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000478public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000479 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
480 const SkPoint vertices[], const SkPoint texs[],
481 const SkColor colors[], SkXfermode* xfermode,
482 const uint16_t indices[], int indexCount,
483 const SkPaint& paint);
484 virtual ~SkDrawVerticesCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800485 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000486private:
487 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000488 int fVertexCount;
489 SkPoint* fVertices;
490 SkPoint* fTexs;
491 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000492 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000493 uint16_t* fIndices;
494 int fIndexCount;
495 SkPaint fPaint;
496
497 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000498};
499
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000500class SkRotateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000501public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000502 SkRotateCommand(SkScalar degrees);
mtklein72c9faa2015-01-09 10:06:39 -0800503 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000504private:
505 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000506
507 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000508};
509
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000510class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000511public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400512 SkSaveCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800513 void execute(SkCanvas* canvas) const SK_OVERRIDE;
514 void trackSaveState(int* state) SK_OVERRIDE;
515 Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000516private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000517 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000518};
519
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000520class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000521public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000522 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
523 SkCanvas::SaveFlags flags);
mtklein72c9faa2015-01-09 10:06:39 -0800524 void execute(SkCanvas* canvas) const SK_OVERRIDE;
525 void vizExecute(SkCanvas* canvas) const SK_OVERRIDE;
526 void trackSaveState(int* state) SK_OVERRIDE;
527 Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
528 void setActive(bool active) SK_OVERRIDE { fActive = active; }
529 bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000530
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000531 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000532
chudy@google.com902ebe52012-06-29 14:21:22 +0000533private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000534 SkRect fBounds;
535 SkPaint fPaint;
536 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000537 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000538
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000539 bool fActive;
540
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000541 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000542};
543
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000544class SkScaleCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000545public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000546 SkScaleCommand(SkScalar sx, SkScalar sy);
mtklein72c9faa2015-01-09 10:06:39 -0800547 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000548
549 SkScalar x() const { return fSx; }
550 SkScalar y() const { return fSy; }
551
chudy@google.com902ebe52012-06-29 14:21:22 +0000552private:
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 SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000560public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000561 SkSetMatrixCommand(const SkMatrix& matrix);
mtklein72c9faa2015-01-09 10:06:39 -0800562 void setUserMatrix(const SkMatrix&) SK_OVERRIDE;
563 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000564private:
robertphillips70171682014-10-16 14:28:28 -0700565 SkMatrix fUserMatrix;
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000566 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000567
568 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000569};
570
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000571class SkSkewCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000572public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000573 SkSkewCommand(SkScalar sx, SkScalar sy);
mtklein72c9faa2015-01-09 10:06:39 -0800574 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000575private:
576 SkScalar fSx;
577 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000578
579 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000580};
581
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000582class SkTranslateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000583public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000584 SkTranslateCommand(SkScalar dx, SkScalar dy);
mtklein72c9faa2015-01-09 10:06:39 -0800585 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000586
587 SkScalar x() const { return fDx; }
588 SkScalar y() const { return fDy; }
589
chudy@google.com902ebe52012-06-29 14:21:22 +0000590private:
591 SkScalar fDx;
592 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000593
594 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000595};
596
chudy@google.com902ebe52012-06-29 14:21:22 +0000597#endif