chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 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.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 12 | #include "SkPictureFlat.h" |
| 13 | #include "SkCanvas.h" |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 14 | #include "SkString.h" |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 15 | |
| 16 | class SkDrawCommand { |
| 17 | public: |
| 18 | /* TODO(chudy): Remove subclasses. */ |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 19 | SkDrawCommand(DrawType drawType); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 20 | SkDrawCommand(); |
| 21 | |
| 22 | virtual ~SkDrawCommand(); |
| 23 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 24 | virtual SkString toString(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 25 | |
| 26 | virtual const char* toCString() { |
| 27 | return GetCommandString(fDrawType); |
| 28 | } |
| 29 | |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 30 | bool isVisible() const { |
| 31 | return fVisible; |
| 32 | } |
| 33 | |
| 34 | void setVisible(bool toggle) { |
| 35 | fVisible = toggle; |
| 36 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 37 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 38 | SkTDArray<SkString*>* Info() {return &fInfo; }; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 39 | virtual void execute(SkCanvas* canvas)=0; |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 40 | /** Does nothing by default, but used by save() and restore()-type |
| 41 | subclassse to track unresolved save() calls. */ |
| 42 | virtual void trackSaveState(int* state) { }; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 43 | DrawType getType() { return fDrawType; }; |
| 44 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 45 | virtual bool render(SkCanvas* canvas) const { return false; } |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 46 | |
robertphillips@google.com | 8a1cdae | 2012-11-19 20:44:29 +0000 | [diff] [blame] | 47 | static const char* GetCommandString(DrawType type); |
| 48 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 49 | protected: |
| 50 | DrawType fDrawType; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 51 | SkTDArray<SkString*> fInfo; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 52 | |
| 53 | private: |
| 54 | bool fVisible; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | class Restore : public SkDrawCommand { |
| 58 | public: |
| 59 | Restore(); |
| 60 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 61 | virtual void trackSaveState(int* state) SK_OVERRIDE; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 62 | |
| 63 | private: |
| 64 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | class Clear : public SkDrawCommand { |
| 68 | public: |
| 69 | Clear(SkColor color); |
| 70 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 71 | private: |
| 72 | SkColor fColor; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 73 | |
| 74 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | class ClipPath : public SkDrawCommand { |
| 78 | public: |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 79 | ClipPath(const SkPath& path, SkRegion::Op op, bool doAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 80 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 81 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 82 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 83 | SkPath fPath; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 84 | SkRegion::Op fOp; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 85 | bool fDoAA; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 86 | |
| 87 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | class ClipRegion : public SkDrawCommand { |
| 91 | public: |
| 92 | ClipRegion(const SkRegion& region, SkRegion::Op op); |
| 93 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 94 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 95 | SkRegion fRegion; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 96 | SkRegion::Op fOp; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 97 | |
| 98 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | class ClipRect : public SkDrawCommand { |
| 102 | public: |
| 103 | ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA); |
| 104 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 105 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 106 | const SkRect& rect() const { return fRect; } |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 107 | SkRegion::Op op() const { return fOp; } |
| 108 | bool doAA() const { return fDoAA; } |
| 109 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 110 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 111 | SkRect fRect; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 112 | SkRegion::Op fOp; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 113 | bool fDoAA; |
| 114 | |
| 115 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 116 | }; |
| 117 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 118 | class ClipRRect : public SkDrawCommand { |
| 119 | public: |
| 120 | ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA); |
| 121 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 122 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 123 | |
| 124 | const SkRRect& rrect() const { return fRRect; } |
| 125 | SkRegion::Op op() const { return fOp; } |
| 126 | bool doAA() const { return fDoAA; } |
| 127 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 128 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 129 | SkRRect fRRect; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 130 | SkRegion::Op fOp; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 131 | bool fDoAA; |
| 132 | |
| 133 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 134 | }; |
| 135 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 136 | class Concat : public SkDrawCommand { |
| 137 | public: |
| 138 | Concat(const SkMatrix& matrix); |
| 139 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 140 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 141 | SkMatrix fMatrix; |
| 142 | |
| 143 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | class DrawBitmap : public SkDrawCommand { |
| 147 | public: |
| 148 | DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 149 | const SkPaint* paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 150 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 151 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 152 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 153 | SkBitmap fBitmap; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 154 | SkScalar fLeft; |
| 155 | SkScalar fTop; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 156 | SkPaint fPaint; |
| 157 | SkPaint* fPaintPtr; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 158 | |
| 159 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | class DrawBitmapMatrix : public SkDrawCommand { |
| 163 | public: |
| 164 | DrawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& matrix, |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 165 | const SkPaint* paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 166 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 167 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 168 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 169 | SkBitmap fBitmap; |
| 170 | SkMatrix fMatrix; |
| 171 | SkPaint fPaint; |
| 172 | SkPaint* fPaintPtr; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 173 | |
| 174 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | class DrawBitmapNine : public SkDrawCommand { |
| 178 | public: |
| 179 | DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 180 | const SkRect& dst, const SkPaint* paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 181 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 182 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 183 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 184 | SkBitmap fBitmap; |
| 185 | SkIRect fCenter; |
| 186 | SkRect fDst; |
| 187 | SkPaint fPaint; |
| 188 | SkPaint* fPaintPtr; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 189 | |
| 190 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | class DrawBitmapRect : public SkDrawCommand { |
| 194 | public: |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 195 | DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 196 | const SkRect& dst, const SkPaint* paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 197 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 198 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 199 | |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame] | 200 | const SkBitmap& bitmap() const { return fBitmap; } |
| 201 | |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 202 | // The non-const 'paint' method allows modification of this object's |
| 203 | // SkPaint. For this reason the ctor and setPaint method make a local copy. |
| 204 | // The 'fPaintPtr' member acts a signal that the local SkPaint is valid |
| 205 | // (since only an SkPaint* is passed into the ctor). |
| 206 | const SkPaint* paint() const { return fPaintPtr; } |
| 207 | SkPaint* paint() { return fPaintPtr; } |
| 208 | |
| 209 | void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; } |
| 210 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 211 | const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; } |
| 212 | const SkRect& dstRect() const { return fDst; } |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 213 | |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame] | 214 | void setSrcRect(const SkRect& src) { fSrc = src; } |
| 215 | void setDstRect(const SkRect& dst) { fDst = dst; } |
| 216 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 217 | private: |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 218 | SkBitmap fBitmap; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 219 | SkRect fSrc; |
| 220 | SkRect fDst; |
| 221 | SkPaint fPaint; |
| 222 | SkPaint* fPaintPtr; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 223 | |
| 224 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | class DrawData : public SkDrawCommand { |
| 228 | public: |
| 229 | DrawData(const void* data, size_t length); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 230 | virtual ~DrawData() { delete [] fData; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 231 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 232 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 233 | char* fData; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 234 | size_t fLength; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 235 | |
| 236 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 237 | }; |
| 238 | |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 239 | class BeginCommentGroup : public SkDrawCommand { |
| 240 | public: |
| 241 | BeginCommentGroup(const char* description); |
| 242 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE { |
| 243 | canvas->beginCommentGroup(fDescription.c_str()); |
| 244 | }; |
| 245 | private: |
| 246 | SkString fDescription; |
| 247 | |
| 248 | typedef SkDrawCommand INHERITED; |
| 249 | }; |
| 250 | |
| 251 | class Comment : public SkDrawCommand { |
| 252 | public: |
| 253 | Comment(const char* kywd, const char* value); |
| 254 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE { |
| 255 | canvas->addComment(fKywd.c_str(), fValue.c_str()); |
| 256 | }; |
| 257 | private: |
| 258 | SkString fKywd; |
| 259 | SkString fValue; |
| 260 | |
| 261 | typedef SkDrawCommand INHERITED; |
| 262 | }; |
| 263 | |
| 264 | class EndCommentGroup : public SkDrawCommand { |
| 265 | public: |
| 266 | EndCommentGroup(); |
| 267 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE { |
| 268 | canvas->endCommentGroup(); |
| 269 | }; |
| 270 | private: |
| 271 | typedef SkDrawCommand INHERITED; |
| 272 | }; |
| 273 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 274 | class DrawOval : public SkDrawCommand { |
| 275 | public: |
| 276 | DrawOval(const SkRect& oval, const SkPaint& paint); |
| 277 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 278 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 279 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 280 | SkRect fOval; |
| 281 | SkPaint fPaint; |
| 282 | |
| 283 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 284 | }; |
| 285 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 286 | class DrawPaint : public SkDrawCommand { |
| 287 | public: |
| 288 | DrawPaint(const SkPaint& paint); |
| 289 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 290 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 291 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 292 | SkPaint fPaint; |
| 293 | |
| 294 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | class DrawPath : public SkDrawCommand { |
| 298 | public: |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 299 | DrawPath(const SkPath& path, const SkPaint& paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 300 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 301 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 302 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 303 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 304 | SkPath fPath; |
| 305 | SkPaint fPaint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 306 | |
| 307 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | class DrawPicture : public SkDrawCommand { |
| 311 | public: |
| 312 | DrawPicture(SkPicture& picture); |
| 313 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 314 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 315 | SkPicture fPicture; |
| 316 | |
| 317 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 318 | }; |
| 319 | |
| 320 | class DrawPoints : public SkDrawCommand { |
| 321 | public: |
| 322 | DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 323 | const SkPaint& paint); |
| 324 | virtual ~DrawPoints() { delete [] fPts; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 325 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 326 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 327 | private: |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 328 | SkCanvas::PointMode fMode; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 329 | size_t fCount; |
| 330 | SkPoint* fPts; |
| 331 | SkPaint fPaint; |
| 332 | |
| 333 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 334 | }; |
| 335 | |
| 336 | /* TODO(chudy): DrawText is a predefined macro and was breaking something |
| 337 | * in the windows build of the debugger. |
| 338 | */ |
| 339 | class DrawTextC : public SkDrawCommand { |
| 340 | public: |
| 341 | DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 342 | const SkPaint& paint); |
| 343 | virtual ~DrawTextC() { delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 344 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 345 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 346 | char* fText; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 347 | size_t fByteLength; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 348 | SkScalar fX; |
| 349 | SkScalar fY; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 350 | SkPaint fPaint; |
| 351 | |
| 352 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 353 | }; |
| 354 | |
| 355 | class DrawPosText : public SkDrawCommand { |
| 356 | public: |
| 357 | DrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 358 | const SkPaint& paint); |
| 359 | virtual ~DrawPosText() { delete [] fPos; delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 360 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 361 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 362 | char* fText; |
| 363 | size_t fByteLength; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 364 | SkPoint* fPos; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 365 | SkPaint fPaint; |
| 366 | |
| 367 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 368 | }; |
| 369 | |
| 370 | class DrawTextOnPath : public SkDrawCommand { |
| 371 | public: |
| 372 | DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 373 | const SkMatrix* matrix, const SkPaint& paint); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 374 | virtual ~DrawTextOnPath() { delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 375 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 376 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 377 | char* fText; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 378 | size_t fByteLength; |
| 379 | SkPath fPath; |
| 380 | SkMatrix fMatrix; |
| 381 | SkPaint fPaint; |
| 382 | |
| 383 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 384 | }; |
| 385 | |
| 386 | class DrawPosTextH : public SkDrawCommand { |
| 387 | public: |
| 388 | DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 389 | SkScalar constY, const SkPaint& paint); |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 390 | virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 391 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 392 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 393 | SkScalar* fXpos; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 394 | char* fText; |
| 395 | size_t fByteLength; |
| 396 | SkScalar fConstY; |
| 397 | SkPaint fPaint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 398 | |
| 399 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 400 | }; |
| 401 | |
| 402 | class DrawRectC : public SkDrawCommand { |
| 403 | public: |
| 404 | DrawRectC(const SkRect& rect, const SkPaint& paint); |
| 405 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 406 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 407 | const SkRect& rect() const { return fRect; } |
| 408 | const SkPaint& paint() const { return fPaint; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 409 | private: |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 410 | SkRect fRect; |
| 411 | SkPaint fPaint; |
| 412 | |
| 413 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 414 | }; |
| 415 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 416 | class DrawRRect : public SkDrawCommand { |
| 417 | public: |
| 418 | DrawRRect(const SkRRect& rrect, const SkPaint& paint); |
| 419 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 420 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 421 | private: |
| 422 | SkRRect fRRect; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 423 | SkPaint fPaint; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 424 | |
| 425 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 426 | }; |
| 427 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 428 | class DrawSprite : public SkDrawCommand { |
| 429 | public: |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 430 | DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 431 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame^] | 432 | virtual bool render(SkCanvas* canvas) const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 433 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 434 | SkBitmap fBitmap; |
| 435 | int fLeft; |
| 436 | int fTop; |
| 437 | SkPaint fPaint; |
| 438 | SkPaint* fPaintPtr; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 439 | |
| 440 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 441 | }; |
| 442 | |
| 443 | class DrawVertices : public SkDrawCommand { |
| 444 | public: |
| 445 | DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, |
skia.committer@gmail.com | e60ed08 | 2013-03-26 07:01:04 +0000 | [diff] [blame] | 446 | const SkPoint vertices[], const SkPoint texs[], |
| 447 | const SkColor colors[], SkXfermode* xfermode, |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 448 | const uint16_t indices[], int indexCount, |
| 449 | const SkPaint& paint); |
| 450 | virtual ~DrawVertices(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 451 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 452 | private: |
| 453 | SkCanvas::VertexMode fVmode; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 454 | int fVertexCount; |
| 455 | SkPoint* fVertices; |
| 456 | SkPoint* fTexs; |
| 457 | SkColor* fColors; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 458 | SkXfermode* fXfermode; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 459 | uint16_t* fIndices; |
| 460 | int fIndexCount; |
| 461 | SkPaint fPaint; |
| 462 | |
| 463 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 464 | }; |
| 465 | |
| 466 | class Rotate : public SkDrawCommand { |
| 467 | public: |
| 468 | Rotate(SkScalar degrees); |
| 469 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 470 | private: |
| 471 | SkScalar fDegrees; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 472 | |
| 473 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 474 | }; |
| 475 | |
| 476 | class Save : public SkDrawCommand { |
| 477 | public: |
| 478 | Save(SkCanvas::SaveFlags flags); |
| 479 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 480 | virtual void trackSaveState(int* state) SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 481 | private: |
| 482 | SkCanvas::SaveFlags fFlags; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 483 | |
| 484 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 485 | }; |
| 486 | |
| 487 | class SaveLayer : public SkDrawCommand { |
| 488 | public: |
| 489 | SaveLayer(const SkRect* bounds, const SkPaint* paint, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 490 | SkCanvas::SaveFlags flags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 491 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 492 | virtual void trackSaveState(int* state) SK_OVERRIDE; |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 493 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 494 | const SkPaint* paint() const { return fPaintPtr; } |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 495 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 496 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 497 | SkRect fBounds; |
| 498 | SkPaint fPaint; |
| 499 | SkPaint* fPaintPtr; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 500 | SkCanvas::SaveFlags fFlags; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 501 | |
| 502 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 503 | }; |
| 504 | |
| 505 | class Scale : public SkDrawCommand { |
| 506 | public: |
| 507 | Scale(SkScalar sx, SkScalar sy); |
| 508 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 9105ad0 | 2013-03-17 18:46:16 +0000 | [diff] [blame] | 509 | |
| 510 | SkScalar x() const { return fSx; } |
| 511 | SkScalar y() const { return fSy; } |
| 512 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 513 | private: |
| 514 | SkScalar fSx; |
| 515 | SkScalar fSy; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 516 | |
| 517 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 518 | }; |
| 519 | |
| 520 | class SetMatrix : public SkDrawCommand { |
| 521 | public: |
| 522 | SetMatrix(const SkMatrix& matrix); |
| 523 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 524 | private: |
robertphillips@google.com | b94b1e7 | 2013-02-19 21:00:26 +0000 | [diff] [blame] | 525 | SkMatrix fMatrix; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 526 | |
| 527 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 528 | }; |
| 529 | |
| 530 | class Skew : public SkDrawCommand { |
| 531 | public: |
| 532 | Skew(SkScalar sx, SkScalar sy); |
| 533 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 534 | private: |
| 535 | SkScalar fSx; |
| 536 | SkScalar fSy; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 537 | |
| 538 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 539 | }; |
| 540 | |
| 541 | class Translate : public SkDrawCommand { |
| 542 | public: |
| 543 | Translate(SkScalar dx, SkScalar dy); |
| 544 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 9105ad0 | 2013-03-17 18:46:16 +0000 | [diff] [blame] | 545 | |
| 546 | SkScalar x() const { return fDx; } |
| 547 | SkScalar y() const { return fDy; } |
| 548 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 549 | private: |
| 550 | SkScalar fDx; |
| 551 | SkScalar fDy; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 552 | |
| 553 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | #endif |