blob: ab72a88d718630210c654dd1dc7a0b540d593aa6 [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
robertphillips2e602422015-02-11 13:07:12 -080012#include "SkPictureFlat.h"
chudy@google.com902ebe52012-06-29 14:21:22 +000013#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:
robertphillips72942b8e2015-02-12 06:37:12 -080018 // Staging for Chromium
19 typedef DrawType OpType;
20
21 static const int kOpTypeCount = LAST_DRAWTYPE_ENUM+1;
22
23 static const char* kDrawRectString;
24 static const char* kClipRectString;
25
26 static const OpType kSave_OpType;
27 static const OpType kClipRect_OpType;
28 static const OpType kDrawRect_OpType;
29 static const OpType kRestore_OpType;
30 static const OpType kSetMatrix_OpType;
31 // End Staging
32
33
robertphillips2e602422015-02-11 13:07:12 -080034 SkDrawCommand(DrawType drawType);
chudy@google.com902ebe52012-06-29 14:21:22 +000035
36 virtual ~SkDrawCommand();
37
fmalita8c89c522014-11-08 16:18:56 -080038 virtual SkString toString() const;
chudy@google.com902ebe52012-06-29 14:21:22 +000039
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000040 void setOffset(size_t offset) { fOffset = offset; }
fmalita8c89c522014-11-08 16:18:56 -080041 size_t offset() const { return fOffset; }
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000042
fmalita8c89c522014-11-08 16:18:56 -080043 virtual const char* toCString() const {
robertphillips2e602422015-02-11 13:07:12 -080044 return GetCommandString(fDrawType);
chudy@google.com902ebe52012-06-29 14:21:22 +000045 }
46
chudy@google.com0b5bbb02012-07-31 19:55:32 +000047 bool isVisible() const {
48 return fVisible;
49 }
50
51 void setVisible(bool toggle) {
52 fVisible = toggle;
53 }
chudy@google.com902ebe52012-06-29 14:21:22 +000054
fmalita8c89c522014-11-08 16:18:56 -080055 const SkTDArray<SkString*>* Info() const { return &fInfo; }
56 virtual void execute(SkCanvas*) const = 0;
57 virtual void vizExecute(SkCanvas*) const {}
robertphillips70171682014-10-16 14:28:28 -070058
fmalita8c89c522014-11-08 16:18:56 -080059 virtual void setUserMatrix(const SkMatrix&) {}
robertphillips70171682014-10-16 14:28:28 -070060
mtkleinf0f14112014-12-12 08:46:25 -080061 // The next "active" system is only used by save, saveLayer, and restore.
62 // It is used to determine which saveLayers are currently active (at a
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000063 // given point in the rendering).
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000064 // saves just return a kPushLayer action but don't track active state
65 // restores just return a kPopLayer action
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000066 // saveLayers return kPushLayer but also track the active state
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000067 enum Action {
68 kNone_Action,
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000069 kPopLayer_Action,
70 kPushLayer_Action,
commit-bot@chromium.org768ac852014-03-03 16:32:17 +000071 };
72 virtual Action action() const { return kNone_Action; }
73 virtual void setActive(bool active) {}
74 virtual bool active() const { return false; }
75
robertphillips2e602422015-02-11 13:07:12 -080076 DrawType getType() const { return fDrawType; }
chudy@google.com902ebe52012-06-29 14:21:22 +000077
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000078 virtual bool render(SkCanvas* canvas) const { return false; }
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000079
robertphillips2e602422015-02-11 13:07:12 -080080 static const char* GetCommandString(DrawType type);
robertphillips@google.com8a1cdae2012-11-19 20:44:29 +000081
chudy@google.com902ebe52012-06-29 14:21:22 +000082protected:
chudy@google.com97cee972012-08-07 20:41:37 +000083 SkTDArray<SkString*> fInfo;
chudy@google.com902ebe52012-06-29 14:21:22 +000084
85private:
robertphillips2e602422015-02-11 13:07:12 -080086 DrawType fDrawType;
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +000087 size_t fOffset;
88 bool fVisible;
chudy@google.com902ebe52012-06-29 14:21:22 +000089};
90
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000091class SkRestoreCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +000092public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +000093 SkRestoreCommand();
mtklein72c9faa2015-01-09 10:06:39 -080094 void execute(SkCanvas* canvas) const SK_OVERRIDE;
mtklein72c9faa2015-01-09 10:06:39 -080095 Action action() const SK_OVERRIDE { return kPopLayer_Action; }
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000096
97private:
98 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +000099};
100
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000101class SkClearCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000102public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000103 SkClearCommand(SkColor color);
mtklein72c9faa2015-01-09 10:06:39 -0800104 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000105private:
106 SkColor fColor;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000107
108 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000109};
110
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000111class SkClipPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000112public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000113 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800114 void execute(SkCanvas* canvas) const SK_OVERRIDE;
115 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000116private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000117 SkPath fPath;
chudy@google.com902ebe52012-06-29 14:21:22 +0000118 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000119 bool fDoAA;
robertphillips@google.com91217d02013-03-17 18:33:46 +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 SkClipRegionCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000125public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000126 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op);
mtklein72c9faa2015-01-09 10:06:39 -0800127 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000128private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000129 SkRegion fRegion;
chudy@google.com902ebe52012-06-29 14:21:22 +0000130 SkRegion::Op fOp;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000131
132 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000133};
134
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000135class SkClipRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000136public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000137 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800138 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000139
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000140 const SkRect& rect() const { return fRect; }
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000141 SkRegion::Op op() const { return fOp; }
142 bool doAA() const { return fDoAA; }
143
chudy@google.com902ebe52012-06-29 14:21:22 +0000144private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000145 SkRect fRect;
chudy@google.com902ebe52012-06-29 14:21:22 +0000146 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000147 bool fDoAA;
148
149 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000150};
151
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000152class SkClipRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000153public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000154 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA);
mtklein72c9faa2015-01-09 10:06:39 -0800155 void execute(SkCanvas* canvas) const SK_OVERRIDE;
156 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000157
158 const SkRRect& rrect() const { return fRRect; }
159 SkRegion::Op op() const { return fOp; }
160 bool doAA() const { return fDoAA; }
161
robertphillips@google.com67baba42013-01-02 20:20:31 +0000162private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000163 SkRRect fRRect;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000164 SkRegion::Op fOp;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000165 bool fDoAA;
166
167 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000168};
169
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000170class SkConcatCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000171public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000172 SkConcatCommand(const SkMatrix& matrix);
mtklein72c9faa2015-01-09 10:06:39 -0800173 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000174private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000175 SkMatrix fMatrix;
176
177 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000178};
179
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000180class SkDrawBitmapCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000181public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000182 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000183 const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800184 void execute(SkCanvas* canvas) const SK_OVERRIDE;
185 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000186private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000187 SkBitmap fBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000188 SkScalar fLeft;
189 SkScalar fTop;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000190 SkPaint fPaint;
191 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000192
193 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000194};
195
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000196class SkDrawBitmapNineCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000197public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000198 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000199 const SkRect& dst, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800200 void execute(SkCanvas* canvas) const SK_OVERRIDE;
201 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000202private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000203 SkBitmap fBitmap;
204 SkIRect fCenter;
205 SkRect fDst;
206 SkPaint fPaint;
207 SkPaint* fPaintPtr;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000208
209 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000210};
211
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000212class SkDrawBitmapRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000213public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000214 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000215 const SkRect& dst, const SkPaint* paint,
216 SkCanvas::DrawBitmapRectFlags flags);
mtklein72c9faa2015-01-09 10:06:39 -0800217 void execute(SkCanvas* canvas) const SK_OVERRIDE;
218 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000219
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000220 const SkBitmap& bitmap() const { return fBitmap; }
221
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000222 // The non-const 'paint' method allows modification of this object's
223 // SkPaint. For this reason the ctor and setPaint method make a local copy.
224 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid
225 // (since only an SkPaint* is passed into the ctor).
226 const SkPaint* paint() const { return fPaintPtr; }
227 SkPaint* paint() { return fPaintPtr; }
228
229 void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; }
230
robertphillips@google.com91217d02013-03-17 18:33:46 +0000231 const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000232 void setSrcRect(const SkRect& src) { fSrc = src; }
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000233
234 const SkRect& dstRect() const { return fDst; }
robertphillips@google.comc3410b82013-03-28 12:25:25 +0000235 void setDstRect(const SkRect& dst) { fDst = dst; }
236
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000237 SkCanvas::DrawBitmapRectFlags flags() const { return fFlags; }
238 void setFlags(SkCanvas::DrawBitmapRectFlags flags) { fFlags = flags; }
239
chudy@google.com902ebe52012-06-29 14:21:22 +0000240private:
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000241 SkBitmap fBitmap;
242 SkRect fSrc;
243 SkRect fDst;
244 SkPaint fPaint;
245 SkPaint* fPaintPtr;
246 SkCanvas::DrawBitmapRectFlags fFlags;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000247
248 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000249};
250
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000251class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000252public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000253 SkBeginCommentGroupCommand(const char* description);
mtklein72c9faa2015-01-09 10:06:39 -0800254 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000255 canvas->beginCommentGroup(fDescription.c_str());
256 };
257private:
258 SkString fDescription;
259
260 typedef SkDrawCommand INHERITED;
261};
262
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000263class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000264public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000265 SkCommentCommand(const char* kywd, const char* value);
mtklein72c9faa2015-01-09 10:06:39 -0800266 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000267 canvas->addComment(fKywd.c_str(), fValue.c_str());
268 };
269private:
270 SkString fKywd;
271 SkString fValue;
272
273 typedef SkDrawCommand INHERITED;
274};
275
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000276class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000277public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000278 SkEndCommentGroupCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800279 void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000280 canvas->endCommentGroup();
281 };
282private:
283 typedef SkDrawCommand INHERITED;
284};
285
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000286class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000287public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000288 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800289 void execute(SkCanvas* canvas) const SK_OVERRIDE;
290 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000291private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000292 SkRect fOval;
293 SkPaint fPaint;
294
295 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000296};
297
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000298class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000299public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000300 SkDrawPaintCommand(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;
chudy@google.com902ebe52012-06-29 14:21:22 +0000303private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000304 SkPaint fPaint;
305
306 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000307};
308
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000309class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000310public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000311 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800312 void execute(SkCanvas* canvas) const SK_OVERRIDE;
313 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000314
chudy@google.com902ebe52012-06-29 14:21:22 +0000315private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000316 SkPath fPath;
317 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000318
319 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000320};
321
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000322class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000323public:
robertphillipsb3f319f2014-08-13 10:46:23 -0700324 SkDrawPictureCommand(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800325 void execute(SkCanvas* canvas) const SK_OVERRIDE;
326 bool render(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000327
chudy@google.com902ebe52012-06-29 14:21:22 +0000328private:
robertphillips9b14f262014-06-04 05:40:44 -0700329 SkAutoTUnref<const SkPicture> fPicture;
robertphillipsb3f319f2014-08-13 10:46:23 -0700330 SkMatrix fMatrix;
331 SkMatrix* fMatrixPtr;
332 SkPaint fPaint;
333 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000334
335 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000336};
337
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000338class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000339public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000340 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000341 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000342 virtual ~SkDrawPointsCommand() { delete [] fPts; }
mtklein72c9faa2015-01-09 10:06:39 -0800343 void execute(SkCanvas* canvas) const SK_OVERRIDE;
344 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000345private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000346 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000347 size_t fCount;
348 SkPoint* fPts;
349 SkPaint fPaint;
350
351 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000352};
353
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000354class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000355public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000356 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000357 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000358 virtual ~SkDrawTextCommand() { delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800359 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000360private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000361 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000362 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000363 SkScalar fX;
364 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000365 SkPaint fPaint;
366
367 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000368};
369
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000370class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000371public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000372 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
373 const SkPaint& paint);
374 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800375 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000376private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000377 char* fText;
378 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000379 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000380 SkPaint fPaint;
381
382 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000383};
384
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000385class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000386public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000387 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
388 const SkMatrix* matrix, const SkPaint& paint);
389 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800390 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000391private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000392 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000393 size_t fByteLength;
394 SkPath fPath;
395 SkMatrix fMatrix;
396 SkPaint fPaint;
397
398 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000399};
400
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000401class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000402public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000403 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
404 SkScalar constY, const SkPaint& paint);
405 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
mtklein72c9faa2015-01-09 10:06:39 -0800406 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000407private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000408 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000409 char* fText;
410 size_t fByteLength;
411 SkScalar fConstY;
412 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000413
414 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000415};
416
fmalitab7425172014-08-26 07:56:44 -0700417class SkDrawTextBlobCommand : public SkDrawCommand {
418public:
419 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
420
mtklein72c9faa2015-01-09 10:06:39 -0800421 void execute(SkCanvas* canvas) const SK_OVERRIDE;
422 bool render(SkCanvas* canvas) const SK_OVERRIDE;
fmalitab7425172014-08-26 07:56:44 -0700423
424private:
425 SkAutoTUnref<const SkTextBlob> fBlob;
426 SkScalar fXPos;
427 SkScalar fYPos;
428 SkPaint fPaint;
429
430 typedef SkDrawCommand INHERITED;
431};
432
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000433class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000434public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000435 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800436 void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000437
robertphillips@google.com91217d02013-03-17 18:33:46 +0000438 const SkRect& rect() const { return fRect; }
439 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000440private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000441 SkRect fRect;
442 SkPaint fPaint;
443
444 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000445};
446
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000447class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000448public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000449 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800450 void execute(SkCanvas* canvas) const SK_OVERRIDE;
451 bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000452private:
453 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000454 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000455
456 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000457};
458
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000459class SkDrawDRRectCommand : public SkDrawCommand {
460public:
461 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
462 const SkPaint& paint);
mtklein72c9faa2015-01-09 10:06:39 -0800463 void execute(SkCanvas* canvas) const SK_OVERRIDE;
464 bool render(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000465private:
466 SkRRect fOuter;
467 SkRRect fInner;
468 SkPaint fPaint;
469
470 typedef SkDrawCommand INHERITED;
471};
472
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000473class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000474public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000475 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
mtklein72c9faa2015-01-09 10:06:39 -0800476 void execute(SkCanvas* canvas) const SK_OVERRIDE;
477 bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000478private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000479 SkBitmap fBitmap;
480 int fLeft;
481 int fTop;
482 SkPaint fPaint;
483 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000484
485 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000486};
487
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000488class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000489public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000490 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
491 const SkPoint vertices[], const SkPoint texs[],
492 const SkColor colors[], SkXfermode* xfermode,
493 const uint16_t indices[], int indexCount,
494 const SkPaint& paint);
495 virtual ~SkDrawVerticesCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800496 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000497private:
498 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000499 int fVertexCount;
500 SkPoint* fVertices;
501 SkPoint* fTexs;
502 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000503 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000504 uint16_t* fIndices;
505 int fIndexCount;
506 SkPaint fPaint;
507
508 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000509};
510
robertphillips2e602422015-02-11 13:07:12 -0800511class SkRotateCommand : public SkDrawCommand {
512public:
513 SkRotateCommand(SkScalar degrees);
514 void execute(SkCanvas* canvas) const SK_OVERRIDE;
515private:
516 SkScalar fDegrees;
517
518 typedef SkDrawCommand INHERITED;
519};
520
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000521class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000522public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400523 SkSaveCommand();
mtklein72c9faa2015-01-09 10:06:39 -0800524 void execute(SkCanvas* canvas) const SK_OVERRIDE;
mtklein72c9faa2015-01-09 10:06:39 -0800525 Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000526private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000527 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000528};
529
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000530class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000531public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000532 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
533 SkCanvas::SaveFlags flags);
mtklein72c9faa2015-01-09 10:06:39 -0800534 void execute(SkCanvas* canvas) const SK_OVERRIDE;
535 void vizExecute(SkCanvas* canvas) const SK_OVERRIDE;
mtklein72c9faa2015-01-09 10:06:39 -0800536 Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
537 void setActive(bool active) SK_OVERRIDE { fActive = active; }
538 bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000539
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000540 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000541
chudy@google.com902ebe52012-06-29 14:21:22 +0000542private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000543 SkRect fBounds;
544 SkPaint fPaint;
545 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000546 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000547
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000548 bool fActive;
549
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000550 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000551};
552
robertphillips2e602422015-02-11 13:07:12 -0800553class SkScaleCommand : public SkDrawCommand {
554public:
555 SkScaleCommand(SkScalar sx, SkScalar sy);
556 void execute(SkCanvas* canvas) const SK_OVERRIDE;
557
558 SkScalar x() const { return fSx; }
559 SkScalar y() const { return fSy; }
560
561private:
562 SkScalar fSx;
563 SkScalar fSy;
564
565 typedef SkDrawCommand INHERITED;
566};
567
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000568class SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000569public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000570 SkSetMatrixCommand(const SkMatrix& matrix);
mtklein72c9faa2015-01-09 10:06:39 -0800571 void setUserMatrix(const SkMatrix&) SK_OVERRIDE;
572 void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000573private:
robertphillips70171682014-10-16 14:28:28 -0700574 SkMatrix fUserMatrix;
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000575 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000576
577 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000578};
579
robertphillips2e602422015-02-11 13:07:12 -0800580class SkSkewCommand : public SkDrawCommand {
581public:
582 SkSkewCommand(SkScalar sx, SkScalar sy);
583 void execute(SkCanvas* canvas) const SK_OVERRIDE;
584private:
585 SkScalar fSx;
586 SkScalar fSy;
587
588 typedef SkDrawCommand INHERITED;
589};
590
591class SkTranslateCommand : public SkDrawCommand {
592public:
593 SkTranslateCommand(SkScalar dx, SkScalar dy);
594 void execute(SkCanvas* canvas) const SK_OVERRIDE;
595
596 SkScalar x() const { return fDx; }
597 SkScalar y() const { return fDy; }
598
599private:
600 SkScalar fDx;
601 SkScalar fDy;
602
603 typedef SkDrawCommand INHERITED;
604};
605
chudy@google.com902ebe52012-06-29 14:21:22 +0000606#endif