blob: 9ff1a9f65c8da3a8258895fee3dc6ecdd8d12fae [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 "SkCanvas.h"
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000013#include "SkString.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000014
fmalita@google.com86681b32013-06-13 20:59:14 +000015class SK_API SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000016public:
robertphillips72942b8e2015-02-12 06:37:12 -080017 // Staging for Chromium
robertphillips72942b8e2015-02-12 06:37:12 -080018 static const char* kDrawRectString;
19 static const char* kClipRectString;
robertphillips72942b8e2015-02-12 06:37:12 -080020 // End Staging
21
robertphillips9bafc302015-02-13 11:13:00 -080022 enum OpType {
23 kBeginCommentGroup_OpType,
24 kClipPath_OpType,
25 kClipRegion_OpType,
26 kClipRect_OpType,
27 kClipRRect_OpType,
28 kComment_OpType,
29 kConcat_OpType,
30 kDrawBitmap_OpType,
31 kDrawBitmapNine_OpType,
32 kDrawBitmapRect_OpType,
33 kDrawClear_OpType,
34 kDrawDRRect_OpType,
35 kDrawOval_OpType,
36 kDrawPaint_OpType,
37 kDrawPatch_OpType,
38 kDrawPath_OpType,
39 kDrawPicture_OpType,
40 kDrawPoints_OpType,
41 kDrawPosText_OpType,
42 kDrawPosTextH_OpType,
43 kDrawRect_OpType,
44 kDrawRRect_OpType,
45 kDrawSprite_OpType,
46 kDrawText_OpType,
47 kDrawTextBlob_OpType,
48 kDrawTextOnPath_OpType,
49 kDrawVertices_OpType,
50 kEndCommentGroup_OpType,
51 kRestore_OpType,
52 kSave_OpType,
53 kSaveLayer_OpType,
54 kSetMatrix_OpType,
robertphillips72942b8e2015-02-12 06:37:12 -080055
robertphillips9bafc302015-02-13 11:13:00 -080056 kLast_OpType = kSetMatrix_OpType
57 };
58
59 static const int kOpTypeCount = kLast_OpType + 1;
60
61 SkDrawCommand(OpType opType);
chudy@google.com902ebe52012-06-29 14:21:22 +000062
63 virtual ~SkDrawCommand();
64
fmalita8c89c522014-11-08 16:18:56 -080065 virtual SkString toString() const;
chudy@google.com902ebe52012-06-29 14:21:22 +000066
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000067 void setOffset(size_t offset) { fOffset = offset; }
fmalita8c89c522014-11-08 16:18:56 -080068 size_t offset() const { return fOffset; }
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000069
fmalita8c89c522014-11-08 16:18:56 -080070 virtual const char* toCString() const {
robertphillips9bafc302015-02-13 11:13:00 -080071 return GetCommandString(fOpType);
chudy@google.com902ebe52012-06-29 14:21:22 +000072 }
73
chudy@google.com0b5bbb02012-07-31 19:55:32 +000074 bool isVisible() const {
75 return fVisible;
76 }
77
78 void setVisible(bool toggle) {
79 fVisible = toggle;
80 }
chudy@google.com902ebe52012-06-29 14:21:22 +000081
fmalita8c89c522014-11-08 16:18:56 -080082 const SkTDArray<SkString*>* Info() const { return &fInfo; }
83 virtual void execute(SkCanvas*) const = 0;
84 virtual void vizExecute(SkCanvas*) const {}
robertphillips70171682014-10-16 14:28:28 -070085
fmalita8c89c522014-11-08 16:18:56 -080086 virtual void setUserMatrix(const SkMatrix&) {}
robertphillips70171682014-10-16 14:28:28 -070087
mtkleinf0f14112014-12-12 08:46:25 -080088 // The next "active" system is only used by save, saveLayer, and restore.
89 // It is used to determine which saveLayers are currently active (at a
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000090 // given point in the rendering).
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000091 // saves just return a kPushLayer action but don't track active state
92 // restores just return a kPopLayer action
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000093 // saveLayers return kPushLayer but also track the active state
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000094 enum Action {
95 kNone_Action,
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000096 kPopLayer_Action,
97 kPushLayer_Action,
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000098 };
99 virtual Action action() const { return kNone_Action; }
100 virtual void setActive(bool active) {}
101 virtual bool active() const { return false; }
102
robertphillips9bafc302015-02-13 11:13:00 -0800103 OpType getType() const { return fOpType; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000104
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000105 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000106
robertphillips9bafc302015-02-13 11:13:00 -0800107 static const char* GetCommandString(OpType type);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +0000108
chudy@google.com902ebe52012-06-29 14:21:22 +0000109protected:
chudy@google.com97cee972012-08-07 20:41:37 +0000110 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +0000111
112private:
robertphillips9bafc302015-02-13 11:13:00 -0800113 OpType fOpType;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000114 size_t fOffset;
115 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +0000116};
117
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000118class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000119public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000120 SkRestoreCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800121 void execute(SkCanvas* canvas) const SK_OVERRIDE;
mtklein72c9faa2015-01-09 10:06:39 -0800122 Action action() const SK_OVERRIDE { return kPopLayer_Action; }
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000123
124private:
125 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000126};
127
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000128class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000129public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000130 SkClearCommand(SkColor color);
mtklein72c9faa2015-01-09 10:06:39 -0800131 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000132private:
133 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000134
135 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000136};
137
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000138class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000139public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000140 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800141 void execute(SkCanvas* canvas) const SK_OVERRIDE;
142 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000143private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000144 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +0000145 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000146 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000147
148 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000149};
150
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000151class SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000152public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000153 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
mtklein72c9faa2015-01-09 10:06:39 -0800154 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000155private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000156 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +0000157 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000158
159 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000160};
161
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000162class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000163public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000164 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800165 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000166
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000167 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000168 SkRegion::Op op() const { return fOp; }
169 bool doAA() const { return fDoAA; }
170
chudy@google.com902ebe52012-06-29 14:21:22 +0000171private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000172 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000173 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000174 bool fDoAA;
175
176 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000177};
178
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000179class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000180public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000181 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800182 void execute(SkCanvas* canvas) const SK_OVERRIDE;
183 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000184
185 const SkRRect& rrect() const { return fRRect; }
186 SkRegion::Op op() const { return fOp; }
187 bool doAA() const { return fDoAA; }
188
robertphillips@google.com67baba42013-01-02 20:20:31 +0000189private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000190 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000191 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000192 bool fDoAA;
193
194 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000195};
196
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000197class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000198public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000199 SkConcatCommand(const SkMatrix& matrix);
mtklein72c9faa2015-01-09 10:06:39 -0800200 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000201private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000202 SkMatrix fMatrix;
203
204 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000205};
206
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000207class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000208public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000209 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000210 const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800211 void execute(SkCanvas* canvas) const SK_OVERRIDE;
212 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000213private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000214 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000215 SkScalar fLeft;
216 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000217 SkPaint fPaint;
218 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000219
220 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000221};
222
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000223class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000224public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000225 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000226 const SkRect& dst, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800227 void execute(SkCanvas* canvas) const SK_OVERRIDE;
228 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000229private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000230 SkBitmap fBitmap;
231 SkIRect fCenter;
232 SkRect fDst;
233 SkPaint fPaint;
234 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000235
236 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000237};
238
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000239class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000240public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000241 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000242 const SkRect& dst, const SkPaint* paint,
243 SkCanvas::DrawBitmapRectFlags flags);
mtklein72c9faa2015-01-09 10:06:39 -0800244 void execute(SkCanvas* canvas) const SK_OVERRIDE;
245 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000246
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000247 const SkBitmap& bitmap() const { return fBitmap; }
248
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000249 // The non-const 'paint' method allows modification of this object's
250 // SkPaint. For this reason the ctor and setPaint method make a local copy.
251 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
252 // (since only an SkPaint* is passed into the ctor).
253 const SkPaint* paint() const { return fPaintPtr; }
254 SkPaint* paint() { return fPaintPtr; }
255
256 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
257
robertphillips@google.com91217d02013-03-17 18:33:46 +0000258 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000259 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000260
261 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000262 void setDstRect(const SkRect& dst) { fDst = dst; }
263
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000264 SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
265 void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
266
chudy@google.com902ebe52012-06-29 14:21:22 +0000267private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000268 SkBitmap fBitmap;
269 SkRect fSrc;
270 SkRect fDst;
271 SkPaint fPaint;
272 SkPaint* fPaintPtr;
273 SkCanvas::DrawBitmapRectFlags fFlags;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000274
275 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000276};
277
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000278class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000279public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000280 SkBeginCommentGroupCommand(const char* description);
mtklein72c9faa2015-01-09 10:06:39 -0800281 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000282 canvas->beginCommentGroup(fDescription.c_str());
283 };
284private:
285 SkString fDescription;
286
287 typedef SkDrawCommand INHERITED;
288};
289
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000290class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000291public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000292 SkCommentCommand(const char* kywd, const char* value);
mtklein72c9faa2015-01-09 10:06:39 -0800293 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000294 canvas->addComment(fKywd.c_str(), fValue.c_str());
295 };
296private:
297 SkString fKywd;
298 SkString fValue;
299
300 typedef SkDrawCommand INHERITED;
301};
302
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000303class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000304public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000305 SkEndCommentGroupCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800306 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000307 canvas->endCommentGroup();
308 };
309private:
310 typedef SkDrawCommand INHERITED;
311};
312
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000313class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000314public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000315 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800316 void execute(SkCanvas* canvas) const SK_OVERRIDE;
317 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000318private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000319 SkRect fOval;
320 SkPaint fPaint;
321
322 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000323};
324
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000325class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000326public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000327 SkDrawPaintCommand(const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800328 void execute(SkCanvas* canvas) const SK_OVERRIDE;
329 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000330private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000331 SkPaint fPaint;
332
333 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000334};
335
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000336class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000337public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000338 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800339 void execute(SkCanvas* canvas) const SK_OVERRIDE;
340 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000341
chudy@google.com902ebe52012-06-29 14:21:22 +0000342private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000343 SkPath fPath;
344 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000345
346 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000347};
348
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000349class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000350public:
robertphillipsb3f319f2014-08-13 10:46:23 -0700351 SkDrawPictureCommand(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800352 void execute(SkCanvas* canvas) const SK_OVERRIDE;
353 bool render(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000354
chudy@google.com902ebe52012-06-29 14:21:22 +0000355private:
robertphillips9b14f262014-06-04 05:40:44 -0700356 SkAutoTUnref<const SkPicture> fPicture;
robertphillipsb3f319f2014-08-13 10:46:23 -0700357 SkMatrix fMatrix;
358 SkMatrix* fMatrixPtr;
359 SkPaint fPaint;
360 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000361
362 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000363};
364
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000365class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000366public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000367 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000368 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000369 virtual ~SkDrawPointsCommand() { delete [] fPts; }
mtklein72c9faa2015-01-09 10:06:39 -0800370 void execute(SkCanvas* canvas) const SK_OVERRIDE;
371 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000372private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000373 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000374 size_t fCount;
375 SkPoint* fPts;
376 SkPaint fPaint;
377
378 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000379};
380
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000381class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000382public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000383 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000384 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000385 virtual ~SkDrawTextCommand() { delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800386 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000387private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000388 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000389 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000390 SkScalar fX;
391 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000392 SkPaint fPaint;
393
394 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000395};
396
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000397class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000398public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000399 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
400 const SkPaint& paint);
401 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800402 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000403private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000404 char* fText;
405 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000406 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000407 SkPaint fPaint;
408
409 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000410};
411
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000412class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000413public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000414 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
415 const SkMatrix* matrix, const SkPaint& paint);
416 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800417 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000418private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000419 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000420 size_t fByteLength;
421 SkPath fPath;
422 SkMatrix fMatrix;
423 SkPaint fPaint;
424
425 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000426};
427
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000428class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000429public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000430 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
431 SkScalar constY, const SkPaint& paint);
432 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800433 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000434private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000435 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000436 char* fText;
437 size_t fByteLength;
438 SkScalar fConstY;
439 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000440
441 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000442};
443
fmalitab7425172014-08-26 07:56:44 -0700444class SkDrawTextBlobCommand : public SkDrawCommand {
445public:
446 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
447
mtklein72c9faa2015-01-09 10:06:39 -0800448 void execute(SkCanvas* canvas) const SK_OVERRIDE;
449 bool render(SkCanvas* canvas) const SK_OVERRIDE;
fmalitab7425172014-08-26 07:56:44 -0700450
451private:
452 SkAutoTUnref<const SkTextBlob> fBlob;
453 SkScalar fXPos;
454 SkScalar fYPos;
455 SkPaint fPaint;
456
457 typedef SkDrawCommand INHERITED;
458};
459
robertphillips9bafc302015-02-13 11:13:00 -0800460class SkDrawPatchCommand : public SkDrawCommand {
461public:
462 SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
463 const SkPoint texCoords[4], SkXfermode* xmode,
464 const SkPaint& paint);
465 void execute(SkCanvas* canvas) const SK_OVERRIDE;
466
467private:
468 SkPoint fCubics[12];
469 SkColor fColors[4];
470 SkPoint fTexCoords[4];
471 SkAutoTUnref<SkXfermode> fXfermode;
472 SkPaint fPaint;
473
474 typedef SkDrawCommand INHERITED;
475};
476
477
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000478class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000479public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000480 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800481 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000482
robertphillips@google.com91217d02013-03-17 18:33:46 +0000483 const SkRect& rect() const { return fRect; }
484 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000485private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000486 SkRect fRect;
487 SkPaint fPaint;
488
489 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000490};
491
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000492class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000493public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000494 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800495 void execute(SkCanvas* canvas) const SK_OVERRIDE;
496 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000497private:
498 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000499 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000500
501 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000502};
503
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000504class SkDrawDRRectCommand : public SkDrawCommand {
505public:
506 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
507 const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800508 void execute(SkCanvas* canvas) const SK_OVERRIDE;
509 bool render(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000510private:
511 SkRRect fOuter;
512 SkRRect fInner;
513 SkPaint fPaint;
514
515 typedef SkDrawCommand INHERITED;
516};
517
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000518class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000519public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000520 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800521 void execute(SkCanvas* canvas) const SK_OVERRIDE;
522 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000523private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000524 SkBitmap fBitmap;
525 int fLeft;
526 int fTop;
527 SkPaint fPaint;
528 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000529
530 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000531};
532
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000533class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000534public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000535 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
536 const SkPoint vertices[], const SkPoint texs[],
537 const SkColor colors[], SkXfermode* xfermode,
538 const uint16_t indices[], int indexCount,
539 const SkPaint& paint);
540 virtual ~SkDrawVerticesCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800541 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000542private:
543 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000544 int fVertexCount;
545 SkPoint* fVertices;
546 SkPoint* fTexs;
547 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000548 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000549 uint16_t* fIndices;
550 int fIndexCount;
551 SkPaint fPaint;
552
553 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000554};
555
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000556class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000557public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400558 SkSaveCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800559 void execute(SkCanvas* canvas) const SK_OVERRIDE;
mtklein72c9faa2015-01-09 10:06:39 -0800560 Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000561private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000562 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000563};
564
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000565class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000566public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000567 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
568 SkCanvas::SaveFlags flags);
mtklein72c9faa2015-01-09 10:06:39 -0800569 void execute(SkCanvas* canvas) const SK_OVERRIDE;
570 void vizExecute(SkCanvas* canvas) const SK_OVERRIDE;
mtklein72c9faa2015-01-09 10:06:39 -0800571 Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
572 void setActive(bool active) SK_OVERRIDE { fActive = active; }
573 bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000574
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000575 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000576
chudy@google.com902ebe52012-06-29 14:21:22 +0000577private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000578 SkRect fBounds;
579 SkPaint fPaint;
580 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000581 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000582
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000583 bool fActive;
584
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000585 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000586};
587
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000588class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000589public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000590 SkSetMatrixCommand(const SkMatrix& matrix);
mtklein72c9faa2015-01-09 10:06:39 -0800591 void setUserMatrix(const SkMatrix&) SK_OVERRIDE;
592 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000593private:
robertphillips70171682014-10-16 14:28:28 -0700594 SkMatrix fUserMatrix;
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000595 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000596
597 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000598};
599
chudy@google.com902ebe52012-06-29 14:21:22 +0000600#endif