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