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