blob: 951d15e19519d09c8329b67bc20249fe3b2e4bfb [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();
fmalita8c89c522014-11-08 16:18:56 -080082 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +000083 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +000084 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -080093 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800103 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000104 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800116 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800127 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800144 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000145 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800162 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800173 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000174 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800189 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000190 virtual 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);
fmalita8c89c522014-11-08 16:18:56 -0800206 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000207 virtual 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 SkDrawDataCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000241public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000242 SkDrawDataCommand(const void* data, size_t length);
243 virtual ~SkDrawDataCommand() { delete [] fData; }
fmalita8c89c522014-11-08 16:18:56 -0800244 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000245private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000246 char* fData;
chudy@google.com902ebe52012-06-29 14:21:22 +0000247 size_t fLength;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000248
249 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000250};
251
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000252class SkBeginCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000253public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000254 SkBeginCommentGroupCommand(const char* description);
fmalita8c89c522014-11-08 16:18:56 -0800255 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000256 canvas->beginCommentGroup(fDescription.c_str());
257 };
258private:
259 SkString fDescription;
260
261 typedef SkDrawCommand INHERITED;
262};
263
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000264class SkCommentCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000265public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000266 SkCommentCommand(const char* kywd, const char* value);
fmalita8c89c522014-11-08 16:18:56 -0800267 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000268 canvas->addComment(fKywd.c_str(), fValue.c_str());
269 };
270private:
271 SkString fKywd;
272 SkString fValue;
273
274 typedef SkDrawCommand INHERITED;
275};
276
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000277class SkEndCommentGroupCommand : public SkDrawCommand {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000278public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000279 SkEndCommentGroupCommand();
fmalita8c89c522014-11-08 16:18:56 -0800280 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE {
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000281 canvas->endCommentGroup();
282 };
283private:
284 typedef SkDrawCommand INHERITED;
285};
286
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000287class SkDrawOvalCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000288public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000289 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
fmalita8c89c522014-11-08 16:18:56 -0800290 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000291 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000292private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000293 SkRect fOval;
294 SkPaint fPaint;
295
296 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000297};
298
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000299class SkDrawPaintCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000300public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000301 SkDrawPaintCommand(const SkPaint& paint);
fmalita8c89c522014-11-08 16:18:56 -0800302 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000303 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000304private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000305 SkPaint fPaint;
306
307 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000308};
309
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000310class SkDrawPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000311public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000312 SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
fmalita8c89c522014-11-08 16:18:56 -0800313 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000314 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000315
chudy@google.com902ebe52012-06-29 14:21:22 +0000316private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000317 SkPath fPath;
318 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000319
320 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000321};
322
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000323class SkDrawPictureCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000324public:
robertphillipsb3f319f2014-08-13 10:46:23 -0700325 SkDrawPictureCommand(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
fmalita8c89c522014-11-08 16:18:56 -0800326 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.orge898e9c2013-11-21 17:08:12 +0000327 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
328
chudy@google.com902ebe52012-06-29 14:21:22 +0000329private:
robertphillips9b14f262014-06-04 05:40:44 -0700330 SkAutoTUnref<const SkPicture> fPicture;
robertphillipsb3f319f2014-08-13 10:46:23 -0700331 SkMatrix fMatrix;
332 SkMatrix* fMatrixPtr;
333 SkPaint fPaint;
334 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000335
336 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000337};
338
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000339class SkDrawPointsCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000340public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000341 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000342 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000343 virtual ~SkDrawPointsCommand() { delete [] fPts; }
fmalita8c89c522014-11-08 16:18:56 -0800344 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000345 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000346private:
chudy@google.com902ebe52012-06-29 14:21:22 +0000347 SkCanvas::PointMode fMode;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000348 size_t fCount;
349 SkPoint* fPts;
350 SkPaint fPaint;
351
352 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000353};
354
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000355class SkDrawTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000356public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000357 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
commit-bot@chromium.org57f74e02014-03-25 23:31:33 +0000358 const SkPaint& paint);
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000359 virtual ~SkDrawTextCommand() { delete [] fText; }
fmalita8c89c522014-11-08 16:18:56 -0800360 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000361private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000362 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000363 size_t fByteLength;
chudy@google.com902ebe52012-06-29 14:21:22 +0000364 SkScalar fX;
365 SkScalar fY;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000366 SkPaint fPaint;
367
368 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000369};
370
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000371class SkDrawPosTextCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000372public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000373 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[],
374 const SkPaint& paint);
375 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; }
fmalita8c89c522014-11-08 16:18:56 -0800376 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000377private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000378 char* fText;
379 size_t fByteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000380 SkPoint* fPos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000381 SkPaint fPaint;
382
383 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000384};
385
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000386class SkDrawTextOnPathCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000387public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000388 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& path,
389 const SkMatrix* matrix, const SkPaint& paint);
390 virtual ~SkDrawTextOnPathCommand() { delete [] fText; }
fmalita8c89c522014-11-08 16:18:56 -0800391 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000392private:
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000393 char* fText;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000394 size_t fByteLength;
395 SkPath fPath;
396 SkMatrix fMatrix;
397 SkPaint fPaint;
398
399 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000400};
401
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000402class SkDrawPosTextHCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000403public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000404 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xpos[],
405 SkScalar constY, const SkPaint& paint);
406 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; }
fmalita8c89c522014-11-08 16:18:56 -0800407 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000408private:
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000409 SkScalar* fXpos;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000410 char* fText;
411 size_t fByteLength;
412 SkScalar fConstY;
413 SkPaint fPaint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000414
415 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000416};
417
fmalitab7425172014-08-26 07:56:44 -0700418class SkDrawTextBlobCommand : public SkDrawCommand {
419public:
420 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
421
fmalita8c89c522014-11-08 16:18:56 -0800422 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
fmalita55773872014-08-29 15:08:20 -0700423 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
fmalitab7425172014-08-26 07:56:44 -0700424
425private:
426 SkAutoTUnref<const SkTextBlob> fBlob;
427 SkScalar fXPos;
428 SkScalar fYPos;
429 SkPaint fPaint;
430
431 typedef SkDrawCommand INHERITED;
432};
433
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000434class SkDrawRectCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000435public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000436 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
fmalita8c89c522014-11-08 16:18:56 -0800437 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000438
robertphillips@google.com91217d02013-03-17 18:33:46 +0000439 const SkRect& rect() const { return fRect; }
440 const SkPaint& paint() const { return fPaint; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000441private:
robertphillips@google.com91217d02013-03-17 18:33:46 +0000442 SkRect fRect;
443 SkPaint fPaint;
444
445 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000446};
447
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000448class SkDrawRRectCommand : public SkDrawCommand {
robertphillips@google.com67baba42013-01-02 20:20:31 +0000449public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000450 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
fmalita8c89c522014-11-08 16:18:56 -0800451 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000452 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000453private:
454 SkRRect fRRect;
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000455 SkPaint fPaint;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000456
457 typedef SkDrawCommand INHERITED;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000458};
459
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000460class SkDrawDRRectCommand : public SkDrawCommand {
461public:
462 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
463 const SkPaint& paint);
fmalita8c89c522014-11-08 16:18:56 -0800464 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
commit-bot@chromium.org3d305202014-02-24 17:28:55 +0000465 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
466private:
467 SkRRect fOuter;
468 SkRRect fInner;
469 SkPaint fPaint;
470
471 typedef SkDrawCommand INHERITED;
472};
473
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000474class SkDrawSpriteCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000475public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000476 SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, const SkPaint* paint);
fmalita8c89c522014-11-08 16:18:56 -0800477 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000478 virtual bool render(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000479private:
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000480 SkBitmap fBitmap;
481 int fLeft;
482 int fTop;
483 SkPaint fPaint;
484 SkPaint* fPaintPtr;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000485
486 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000487};
488
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000489class SkDrawVerticesCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000490public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000491 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
492 const SkPoint vertices[], const SkPoint texs[],
493 const SkColor colors[], SkXfermode* xfermode,
494 const uint16_t indices[], int indexCount,
495 const SkPaint& paint);
496 virtual ~SkDrawVerticesCommand();
fmalita8c89c522014-11-08 16:18:56 -0800497 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000498private:
499 SkCanvas::VertexMode fVmode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000500 int fVertexCount;
501 SkPoint* fVertices;
502 SkPoint* fTexs;
503 SkColor* fColors;
chudy@google.com902ebe52012-06-29 14:21:22 +0000504 SkXfermode* fXfermode;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000505 uint16_t* fIndices;
506 int fIndexCount;
507 SkPaint fPaint;
508
509 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000510};
511
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000512class SkRotateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000513public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000514 SkRotateCommand(SkScalar degrees);
fmalita8c89c522014-11-08 16:18:56 -0800515 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000516private:
517 SkScalar fDegrees;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000518
519 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000520};
521
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000522class SkSaveCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000523public:
Florin Malita5f6102d2014-06-30 10:13:28 -0400524 SkSaveCommand();
fmalita8c89c522014-11-08 16:18:56 -0800525 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000526 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000527 virtual Action action() const SK_OVERRIDE { return kPushLayer_Action; }
chudy@google.com902ebe52012-06-29 14:21:22 +0000528private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000529 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000530};
531
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000532class SkSaveLayerCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000533public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000534 SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
535 SkCanvas::SaveFlags flags);
fmalita8c89c522014-11-08 16:18:56 -0800536 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
537 virtual void vizExecute(SkCanvas* canvas) const SK_OVERRIDE;
tomhudson@google.com0699e022012-11-27 16:09:42 +0000538 virtual void trackSaveState(int* state) SK_OVERRIDE;
commit-bot@chromium.org1643b2c2014-03-03 23:25:41 +0000539 virtual Action action() const SK_OVERRIDE{ return kPushLayer_Action; }
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000540 virtual void setActive(bool active) SK_OVERRIDE { fActive = active; }
541 virtual bool active() const SK_OVERRIDE { return fActive; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000542
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000543 const SkPaint* paint() const { return fPaintPtr; }
robertphillips@google.com3b0a9fe2013-01-31 15:56:22 +0000544
chudy@google.com902ebe52012-06-29 14:21:22 +0000545private:
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000546 SkRect fBounds;
547 SkPaint fPaint;
548 SkPaint* fPaintPtr;
chudy@google.com902ebe52012-06-29 14:21:22 +0000549 SkCanvas::SaveFlags fFlags;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000550
commit-bot@chromium.org768ac852014-03-03 16:32:17 +0000551 bool fActive;
552
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000553 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000554};
555
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000556class SkScaleCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000557public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000558 SkScaleCommand(SkScalar sx, SkScalar sy);
fmalita8c89c522014-11-08 16:18:56 -0800559 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000560
561 SkScalar x() const { return fSx; }
562 SkScalar y() const { return fSy; }
563
chudy@google.com902ebe52012-06-29 14:21:22 +0000564private:
565 SkScalar fSx;
566 SkScalar fSy;
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 SkSetMatrixCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000572public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000573 SkSetMatrixCommand(const SkMatrix& matrix);
robertphillips70171682014-10-16 14:28:28 -0700574 virtual void setUserMatrix(const SkMatrix&) SK_OVERRIDE;
fmalita8c89c522014-11-08 16:18:56 -0800575 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000576private:
robertphillips70171682014-10-16 14:28:28 -0700577 SkMatrix fUserMatrix;
robertphillips@google.comb94b1e72013-02-19 21:00:26 +0000578 SkMatrix fMatrix;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000579
580 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000581};
582
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000583class SkSkewCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000584public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000585 SkSkewCommand(SkScalar sx, SkScalar sy);
fmalita8c89c522014-11-08 16:18:56 -0800586 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000587private:
588 SkScalar fSx;
589 SkScalar fSy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000590
591 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000592};
593
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000594class SkTranslateCommand : public SkDrawCommand {
chudy@google.com902ebe52012-06-29 14:21:22 +0000595public:
commit-bot@chromium.org7a115912013-06-18 20:20:55 +0000596 SkTranslateCommand(SkScalar dx, SkScalar dy);
fmalita8c89c522014-11-08 16:18:56 -0800597 virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
robertphillips@google.com9105ad02013-03-17 18:46:16 +0000598
599 SkScalar x() const { return fDx; }
600 SkScalar y() const { return fDy; }
601
chudy@google.com902ebe52012-06-29 14:21:22 +0000602private:
603 SkScalar fDx;
604 SkScalar fDy;
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000605
606 typedef SkDrawCommand INHERITED;
chudy@google.com902ebe52012-06-29 14:21:22 +0000607};
608
chudy@google.com902ebe52012-06-29 14:21:22 +0000609#endif