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, |
skia.committer@gmail.com | 7e32851 | 2013-03-23 07:01:28 +0000 | [diff] [blame] | 180 | const SkRect& dst, const SkPaint* paint, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 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 | |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame^] | 203 | const SkBitmap& bitmap() const { return fBitmap; } |
| 204 | |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 205 | // The non-const 'paint' method allows modification of this object's |
| 206 | // SkPaint. For this reason the ctor and setPaint method make a local copy. |
| 207 | // The 'fPaintPtr' member acts a signal that the local SkPaint is valid |
| 208 | // (since only an SkPaint* is passed into the ctor). |
| 209 | const SkPaint* paint() const { return fPaintPtr; } |
| 210 | SkPaint* paint() { return fPaintPtr; } |
| 211 | |
| 212 | void setPaint(const SkPaint& paint) { fPaint = paint; fPaintPtr = &fPaint; } |
| 213 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 214 | const SkRect* srcRect() const { return fSrc.isEmpty() ? NULL : &fSrc; } |
| 215 | const SkRect& dstRect() const { return fDst; } |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 216 | |
robertphillips@google.com | c3410b8 | 2013-03-28 12:25:25 +0000 | [diff] [blame^] | 217 | void setSrcRect(const SkRect& src) { fSrc = src; } |
| 218 | void setDstRect(const SkRect& dst) { fDst = dst; } |
| 219 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 220 | private: |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 221 | SkBitmap fBitmap; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 222 | SkRect fSrc; |
| 223 | SkRect fDst; |
| 224 | SkPaint fPaint; |
| 225 | SkPaint* fPaintPtr; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 226 | SkBitmap fResizedBitmap; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 227 | |
| 228 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | class DrawData : public SkDrawCommand { |
| 232 | public: |
| 233 | DrawData(const void* data, size_t length); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 234 | virtual ~DrawData() { delete [] fData; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 235 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 236 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 237 | char* fData; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 238 | size_t fLength; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 239 | |
| 240 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 241 | }; |
| 242 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 243 | class DrawOval : public SkDrawCommand { |
| 244 | public: |
| 245 | DrawOval(const SkRect& oval, const SkPaint& paint); |
| 246 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 247 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 248 | SkRect fOval; |
| 249 | SkPaint fPaint; |
| 250 | |
| 251 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 252 | }; |
| 253 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 254 | class DrawPaint : public SkDrawCommand { |
| 255 | public: |
| 256 | DrawPaint(const SkPaint& paint); |
| 257 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 258 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 259 | SkPaint fPaint; |
| 260 | |
| 261 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 262 | }; |
| 263 | |
| 264 | class DrawPath : public SkDrawCommand { |
| 265 | public: |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 266 | DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 267 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
rmistry@google.com | 4473765 | 2012-11-21 18:37:58 +0000 | [diff] [blame] | 268 | virtual const SkBitmap* getBitmap() const SK_OVERRIDE; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 269 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 270 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 271 | SkPath fPath; |
| 272 | SkPaint fPaint; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 273 | SkBitmap fBitmap; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 274 | |
| 275 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 276 | }; |
| 277 | |
| 278 | class DrawPicture : public SkDrawCommand { |
| 279 | public: |
| 280 | DrawPicture(SkPicture& picture); |
| 281 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 282 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 283 | SkPicture fPicture; |
| 284 | |
| 285 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 286 | }; |
| 287 | |
| 288 | class DrawPoints : public SkDrawCommand { |
| 289 | public: |
| 290 | DrawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 291 | const SkPaint& paint); |
| 292 | virtual ~DrawPoints() { delete [] fPts; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 293 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 294 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 295 | private: |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 296 | SkCanvas::PointMode fMode; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 297 | size_t fCount; |
| 298 | SkPoint* fPts; |
| 299 | SkPaint fPaint; |
| 300 | |
| 301 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 302 | }; |
| 303 | |
| 304 | /* TODO(chudy): DrawText is a predefined macro and was breaking something |
| 305 | * in the windows build of the debugger. |
| 306 | */ |
| 307 | class DrawTextC : public SkDrawCommand { |
| 308 | public: |
| 309 | DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 310 | const SkPaint& paint); |
| 311 | virtual ~DrawTextC() { delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 312 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 313 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 314 | char* fText; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 315 | size_t fByteLength; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 316 | SkScalar fX; |
| 317 | SkScalar fY; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 318 | SkPaint fPaint; |
| 319 | |
| 320 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 321 | }; |
| 322 | |
| 323 | class DrawPosText : public SkDrawCommand { |
| 324 | public: |
| 325 | DrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 326 | const SkPaint& paint); |
| 327 | virtual ~DrawPosText() { delete [] fPos; delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 328 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 329 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 330 | char* fText; |
| 331 | size_t fByteLength; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 332 | SkPoint* fPos; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 333 | SkPaint fPaint; |
| 334 | |
| 335 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 336 | }; |
| 337 | |
| 338 | class DrawTextOnPath : public SkDrawCommand { |
| 339 | public: |
| 340 | DrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 341 | const SkMatrix* matrix, const SkPaint& paint); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 342 | virtual ~DrawTextOnPath() { delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 343 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 344 | private: |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 345 | char* fText; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 346 | size_t fByteLength; |
| 347 | SkPath fPath; |
| 348 | SkMatrix fMatrix; |
| 349 | SkPaint fPaint; |
| 350 | |
| 351 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 352 | }; |
| 353 | |
| 354 | class DrawPosTextH : public SkDrawCommand { |
| 355 | public: |
| 356 | DrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 357 | SkScalar constY, const SkPaint& paint); |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 358 | virtual ~DrawPosTextH() { delete [] fXpos; delete [] fText; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 359 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 360 | private: |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 361 | SkScalar* fXpos; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 362 | char* fText; |
| 363 | size_t fByteLength; |
| 364 | SkScalar fConstY; |
| 365 | SkPaint fPaint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 366 | |
| 367 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 368 | }; |
| 369 | |
| 370 | class DrawRectC : public SkDrawCommand { |
| 371 | public: |
| 372 | DrawRectC(const SkRect& rect, const SkPaint& paint); |
| 373 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 374 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 375 | const SkRect& rect() const { return fRect; } |
| 376 | const SkPaint& paint() const { return fPaint; } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 377 | private: |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 378 | SkRect fRect; |
| 379 | SkPaint fPaint; |
| 380 | |
| 381 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 382 | }; |
| 383 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 384 | class DrawRRect : public SkDrawCommand { |
| 385 | public: |
| 386 | DrawRRect(const SkRRect& rrect, const SkPaint& paint); |
| 387 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 388 | private: |
| 389 | SkRRect fRRect; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 390 | SkPaint fPaint; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 391 | |
| 392 | typedef SkDrawCommand INHERITED; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 393 | }; |
| 394 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 395 | class DrawSprite : public SkDrawCommand { |
| 396 | public: |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 397 | DrawSprite(const SkBitmap& bitmap, int left, int top, const SkPaint* paint, |
| 398 | SkBitmap& resizedBitmap); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 399 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 400 | virtual const SkBitmap* getBitmap() const SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 401 | private: |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 402 | SkBitmap fBitmap; |
| 403 | int fLeft; |
| 404 | int fTop; |
| 405 | SkPaint fPaint; |
| 406 | SkPaint* fPaintPtr; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 407 | SkBitmap fResizedBitmap; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 408 | |
| 409 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 410 | }; |
| 411 | |
| 412 | class DrawVertices : public SkDrawCommand { |
| 413 | public: |
| 414 | DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, |
skia.committer@gmail.com | e60ed08 | 2013-03-26 07:01:04 +0000 | [diff] [blame] | 415 | const SkPoint vertices[], const SkPoint texs[], |
| 416 | const SkColor colors[], SkXfermode* xfermode, |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 417 | const uint16_t indices[], int indexCount, |
| 418 | const SkPaint& paint); |
| 419 | virtual ~DrawVertices(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 420 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 421 | private: |
| 422 | SkCanvas::VertexMode fVmode; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 423 | int fVertexCount; |
| 424 | SkPoint* fVertices; |
| 425 | SkPoint* fTexs; |
| 426 | SkColor* fColors; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 427 | SkXfermode* fXfermode; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 428 | uint16_t* fIndices; |
| 429 | int fIndexCount; |
| 430 | SkPaint fPaint; |
| 431 | |
| 432 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 433 | }; |
| 434 | |
| 435 | class Rotate : public SkDrawCommand { |
| 436 | public: |
| 437 | Rotate(SkScalar degrees); |
| 438 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 439 | private: |
| 440 | SkScalar fDegrees; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +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 Save : public SkDrawCommand { |
| 446 | public: |
| 447 | Save(SkCanvas::SaveFlags flags); |
| 448 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 449 | virtual void trackSaveState(int* state) SK_OVERRIDE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 450 | private: |
| 451 | SkCanvas::SaveFlags fFlags; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 452 | |
| 453 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 454 | }; |
| 455 | |
| 456 | class SaveLayer : public SkDrawCommand { |
| 457 | public: |
| 458 | SaveLayer(const SkRect* bounds, const SkPaint* paint, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 459 | SkCanvas::SaveFlags flags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 460 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 461 | virtual void trackSaveState(int* state) SK_OVERRIDE; |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 462 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 463 | const SkPaint* paint() const { return fPaintPtr; } |
robertphillips@google.com | 3b0a9fe | 2013-01-31 15:56:22 +0000 | [diff] [blame] | 464 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 465 | private: |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 466 | SkRect fBounds; |
| 467 | SkPaint fPaint; |
| 468 | SkPaint* fPaintPtr; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 469 | SkCanvas::SaveFlags fFlags; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 470 | |
| 471 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 472 | }; |
| 473 | |
| 474 | class Scale : public SkDrawCommand { |
| 475 | public: |
| 476 | Scale(SkScalar sx, SkScalar sy); |
| 477 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 9105ad0 | 2013-03-17 18:46:16 +0000 | [diff] [blame] | 478 | |
| 479 | SkScalar x() const { return fSx; } |
| 480 | SkScalar y() const { return fSy; } |
| 481 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 482 | private: |
| 483 | SkScalar fSx; |
| 484 | SkScalar fSy; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 485 | |
| 486 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 487 | }; |
| 488 | |
| 489 | class SetMatrix : public SkDrawCommand { |
| 490 | public: |
| 491 | SetMatrix(const SkMatrix& matrix); |
| 492 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 493 | private: |
robertphillips@google.com | b94b1e7 | 2013-02-19 21:00:26 +0000 | [diff] [blame] | 494 | SkMatrix fMatrix; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 495 | |
| 496 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 497 | }; |
| 498 | |
| 499 | class Skew : public SkDrawCommand { |
| 500 | public: |
| 501 | Skew(SkScalar sx, SkScalar sy); |
| 502 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
| 503 | private: |
| 504 | SkScalar fSx; |
| 505 | SkScalar fSy; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 506 | |
| 507 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 508 | }; |
| 509 | |
| 510 | class Translate : public SkDrawCommand { |
| 511 | public: |
| 512 | Translate(SkScalar dx, SkScalar dy); |
| 513 | virtual void execute(SkCanvas* canvas) SK_OVERRIDE; |
robertphillips@google.com | 9105ad0 | 2013-03-17 18:46:16 +0000 | [diff] [blame] | 514 | |
| 515 | SkScalar x() const { return fDx; } |
| 516 | SkScalar y() const { return fDy; } |
| 517 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 518 | private: |
| 519 | SkScalar fDx; |
| 520 | SkScalar fDy; |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 521 | |
| 522 | typedef SkDrawCommand INHERITED; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 523 | }; |
| 524 | |
| 525 | #endif |