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