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