| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef SKDRAWCOMMAND_H_ | 9 #ifndef SKDRAWCOMMAND_H_ |
| 10 #define SKDRAWCOMMAND_H_ | 10 #define SKDRAWCOMMAND_H_ |
| 11 | 11 |
| 12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 13 #include "SkTLazy.h" | 13 #include "SkTLazy.h" |
| 14 #include "SkPath.h" | 14 #include "SkPath.h" |
| 15 #include "SkRRect.h" | 15 #include "SkRRect.h" |
| 16 #include "SkString.h" | 16 #include "SkString.h" |
| 17 #include "SkTDArray.h" | 17 #include "SkTDArray.h" |
| 18 #include "SkJSONCPP.h" | |
| 19 | 18 |
| 20 class SK_API SkDrawCommand { | 19 class SK_API SkDrawCommand { |
| 21 public: | 20 public: |
| 22 enum OpType { | 21 enum OpType { |
| 23 kBeginDrawPicture_OpType, | 22 kBeginDrawPicture_OpType, |
| 24 kClipPath_OpType, | 23 kClipPath_OpType, |
| 25 kClipRegion_OpType, | 24 kClipRegion_OpType, |
| 26 kClipRect_OpType, | 25 kClipRect_OpType, |
| 27 kClipRRect_OpType, | 26 kClipRRect_OpType, |
| 28 kConcat_OpType, | 27 kConcat_OpType, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 kPushLayer_Action, | 92 kPushLayer_Action, |
| 94 }; | 93 }; |
| 95 virtual Action action() const { return kNone_Action; } | 94 virtual Action action() const { return kNone_Action; } |
| 96 virtual void setActive(bool active) {} | 95 virtual void setActive(bool active) {} |
| 97 virtual bool active() const { return false; } | 96 virtual bool active() const { return false; } |
| 98 | 97 |
| 99 OpType getType() const { return fOpType; } | 98 OpType getType() const { return fOpType; } |
| 100 | 99 |
| 101 virtual bool render(SkCanvas* canvas) const { return false; } | 100 virtual bool render(SkCanvas* canvas) const { return false; } |
| 102 | 101 |
| 103 virtual Json::Value toJSON() const; | |
| 104 | |
| 105 /* Converts a JSON representation of a command into a newly-allocated SkDraw
Command object. It | |
| 106 * is the caller's responsibility to delete this object. This method may ret
urn null if an error | |
| 107 * occurs. | |
| 108 */ | |
| 109 static SkDrawCommand* fromJSON(Json::Value& command); | |
| 110 | |
| 111 static const char* GetCommandString(OpType type); | 102 static const char* GetCommandString(OpType type); |
| 112 | 103 |
| 113 protected: | 104 protected: |
| 114 SkTDArray<SkString*> fInfo; | 105 SkTDArray<SkString*> fInfo; |
| 115 | 106 |
| 116 private: | 107 private: |
| 117 OpType fOpType; | 108 OpType fOpType; |
| 118 bool fVisible; | 109 bool fVisible; |
| 119 }; | 110 }; |
| 120 | 111 |
| 121 class SkRestoreCommand : public SkDrawCommand { | 112 class SkRestoreCommand : public SkDrawCommand { |
| 122 public: | 113 public: |
| 123 SkRestoreCommand(); | 114 SkRestoreCommand(); |
| 124 void execute(SkCanvas* canvas) const override; | 115 void execute(SkCanvas* canvas) const override; |
| 125 Action action() const override { return kPopLayer_Action; } | 116 Action action() const override { return kPopLayer_Action; } |
| 126 static SkRestoreCommand* fromJSON(Json::Value& command); | |
| 127 | 117 |
| 128 private: | 118 private: |
| 129 typedef SkDrawCommand INHERITED; | 119 typedef SkDrawCommand INHERITED; |
| 130 }; | 120 }; |
| 131 | 121 |
| 132 class SkClearCommand : public SkDrawCommand { | 122 class SkClearCommand : public SkDrawCommand { |
| 133 public: | 123 public: |
| 134 SkClearCommand(SkColor color); | 124 SkClearCommand(SkColor color); |
| 135 void execute(SkCanvas* canvas) const override; | 125 void execute(SkCanvas* canvas) const override; |
| 136 Json::Value toJSON() const override; | |
| 137 static SkClearCommand* fromJSON(Json::Value& command); | |
| 138 | |
| 139 private: | 126 private: |
| 140 SkColor fColor; | 127 SkColor fColor; |
| 141 | 128 |
| 142 typedef SkDrawCommand INHERITED; | 129 typedef SkDrawCommand INHERITED; |
| 143 }; | 130 }; |
| 144 | 131 |
| 145 class SkClipPathCommand : public SkDrawCommand { | 132 class SkClipPathCommand : public SkDrawCommand { |
| 146 public: | 133 public: |
| 147 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA); | 134 SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA); |
| 148 void execute(SkCanvas* canvas) const override; | 135 void execute(SkCanvas* canvas) const override; |
| 149 bool render(SkCanvas* canvas) const override; | 136 bool render(SkCanvas* canvas) const override; |
| 150 Json::Value toJSON() const override; | |
| 151 static SkClipPathCommand* fromJSON(Json::Value& command); | |
| 152 | |
| 153 private: | 137 private: |
| 154 SkPath fPath; | 138 SkPath fPath; |
| 155 SkRegion::Op fOp; | 139 SkRegion::Op fOp; |
| 156 bool fDoAA; | 140 bool fDoAA; |
| 157 | 141 |
| 158 typedef SkDrawCommand INHERITED; | 142 typedef SkDrawCommand INHERITED; |
| 159 }; | 143 }; |
| 160 | 144 |
| 161 class SkClipRegionCommand : public SkDrawCommand { | 145 class SkClipRegionCommand : public SkDrawCommand { |
| 162 public: | 146 public: |
| 163 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op); | 147 SkClipRegionCommand(const SkRegion& region, SkRegion::Op op); |
| 164 void execute(SkCanvas* canvas) const override; | 148 void execute(SkCanvas* canvas) const override; |
| 165 Json::Value toJSON() const override; | |
| 166 static SkClipRegionCommand* fromJSON(Json::Value& command); | |
| 167 | |
| 168 private: | 149 private: |
| 169 SkRegion fRegion; | 150 SkRegion fRegion; |
| 170 SkRegion::Op fOp; | 151 SkRegion::Op fOp; |
| 171 | 152 |
| 172 typedef SkDrawCommand INHERITED; | 153 typedef SkDrawCommand INHERITED; |
| 173 }; | 154 }; |
| 174 | 155 |
| 175 class SkClipRectCommand : public SkDrawCommand { | 156 class SkClipRectCommand : public SkDrawCommand { |
| 176 public: | 157 public: |
| 177 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA); | 158 SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA); |
| 178 void execute(SkCanvas* canvas) const override; | 159 void execute(SkCanvas* canvas) const override; |
| 179 Json::Value toJSON() const override; | |
| 180 static SkClipRectCommand* fromJSON(Json::Value& command); | |
| 181 | 160 |
| 182 const SkRect& rect() const { return fRect; } | 161 const SkRect& rect() const { return fRect; } |
| 183 SkRegion::Op op() const { return fOp; } | 162 SkRegion::Op op() const { return fOp; } |
| 184 bool doAA() const { return fDoAA; } | 163 bool doAA() const { return fDoAA; } |
| 185 | 164 |
| 186 private: | 165 private: |
| 187 SkRect fRect; | 166 SkRect fRect; |
| 188 SkRegion::Op fOp; | 167 SkRegion::Op fOp; |
| 189 bool fDoAA; | 168 bool fDoAA; |
| 190 | 169 |
| 191 typedef SkDrawCommand INHERITED; | 170 typedef SkDrawCommand INHERITED; |
| 192 }; | 171 }; |
| 193 | 172 |
| 194 class SkClipRRectCommand : public SkDrawCommand { | 173 class SkClipRRectCommand : public SkDrawCommand { |
| 195 public: | 174 public: |
| 196 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA); | 175 SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA); |
| 197 void execute(SkCanvas* canvas) const override; | 176 void execute(SkCanvas* canvas) const override; |
| 198 bool render(SkCanvas* canvas) const override; | 177 bool render(SkCanvas* canvas) const override; |
| 199 Json::Value toJSON() const override; | |
| 200 static SkClipRRectCommand* fromJSON(Json::Value& command); | |
| 201 | 178 |
| 202 const SkRRect& rrect() const { return fRRect; } | 179 const SkRRect& rrect() const { return fRRect; } |
| 203 SkRegion::Op op() const { return fOp; } | 180 SkRegion::Op op() const { return fOp; } |
| 204 bool doAA() const { return fDoAA; } | 181 bool doAA() const { return fDoAA; } |
| 205 | 182 |
| 206 private: | 183 private: |
| 207 SkRRect fRRect; | 184 SkRRect fRRect; |
| 208 SkRegion::Op fOp; | 185 SkRegion::Op fOp; |
| 209 bool fDoAA; | 186 bool fDoAA; |
| 210 | 187 |
| 211 typedef SkDrawCommand INHERITED; | 188 typedef SkDrawCommand INHERITED; |
| 212 }; | 189 }; |
| 213 | 190 |
| 214 class SkConcatCommand : public SkDrawCommand { | 191 class SkConcatCommand : public SkDrawCommand { |
| 215 public: | 192 public: |
| 216 SkConcatCommand(const SkMatrix& matrix); | 193 SkConcatCommand(const SkMatrix& matrix); |
| 217 void execute(SkCanvas* canvas) const override; | 194 void execute(SkCanvas* canvas) const override; |
| 218 Json::Value toJSON() const override; | |
| 219 static SkConcatCommand* fromJSON(Json::Value& command); | |
| 220 | |
| 221 private: | 195 private: |
| 222 SkMatrix fMatrix; | 196 SkMatrix fMatrix; |
| 223 | 197 |
| 224 typedef SkDrawCommand INHERITED; | 198 typedef SkDrawCommand INHERITED; |
| 225 }; | 199 }; |
| 226 | 200 |
| 227 class SkDrawBitmapCommand : public SkDrawCommand { | 201 class SkDrawBitmapCommand : public SkDrawCommand { |
| 228 public: | 202 public: |
| 229 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, | 203 SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
| 230 const SkPaint* paint); | 204 const SkPaint* paint); |
| 231 void execute(SkCanvas* canvas) const override; | 205 void execute(SkCanvas* canvas) const override; |
| 232 bool render(SkCanvas* canvas) const override; | 206 bool render(SkCanvas* canvas) const override; |
| 233 Json::Value toJSON() const override; | |
| 234 static SkDrawBitmapCommand* fromJSON(Json::Value& command); | |
| 235 | |
| 236 private: | 207 private: |
| 237 SkBitmap fBitmap; | 208 SkBitmap fBitmap; |
| 238 SkScalar fLeft; | 209 SkScalar fLeft; |
| 239 SkScalar fTop; | 210 SkScalar fTop; |
| 240 SkPaint fPaint; | 211 SkPaint fPaint; |
| 241 SkPaint* fPaintPtr; | 212 SkPaint* fPaintPtr; |
| 242 | 213 |
| 243 typedef SkDrawCommand INHERITED; | 214 typedef SkDrawCommand INHERITED; |
| 244 }; | 215 }; |
| 245 | 216 |
| 246 class SkDrawBitmapNineCommand : public SkDrawCommand { | 217 class SkDrawBitmapNineCommand : public SkDrawCommand { |
| 247 public: | 218 public: |
| 248 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, | 219 SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, |
| 249 const SkRect& dst, const SkPaint* paint); | 220 const SkRect& dst, const SkPaint* paint); |
| 250 void execute(SkCanvas* canvas) const override; | 221 void execute(SkCanvas* canvas) const override; |
| 251 bool render(SkCanvas* canvas) const override; | 222 bool render(SkCanvas* canvas) const override; |
| 252 Json::Value toJSON() const override; | |
| 253 static SkDrawBitmapNineCommand* fromJSON(Json::Value& command); | |
| 254 | |
| 255 private: | 223 private: |
| 256 SkBitmap fBitmap; | 224 SkBitmap fBitmap; |
| 257 SkIRect fCenter; | 225 SkIRect fCenter; |
| 258 SkRect fDst; | 226 SkRect fDst; |
| 259 SkPaint fPaint; | 227 SkPaint fPaint; |
| 260 SkPaint* fPaintPtr; | 228 SkPaint* fPaintPtr; |
| 261 | 229 |
| 262 typedef SkDrawCommand INHERITED; | 230 typedef SkDrawCommand INHERITED; |
| 263 }; | 231 }; |
| 264 | 232 |
| 265 class SkDrawBitmapRectCommand : public SkDrawCommand { | 233 class SkDrawBitmapRectCommand : public SkDrawCommand { |
| 266 public: | 234 public: |
| 267 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src, | 235 SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src, |
| 268 const SkRect& dst, const SkPaint* paint, | 236 const SkRect& dst, const SkPaint* paint, |
| 269 SkCanvas::SrcRectConstraint); | 237 SkCanvas::SrcRectConstraint); |
| 270 void execute(SkCanvas* canvas) const override; | 238 void execute(SkCanvas* canvas) const override; |
| 271 bool render(SkCanvas* canvas) const override; | 239 bool render(SkCanvas* canvas) const override; |
| 272 Json::Value toJSON() const override; | |
| 273 static SkDrawBitmapRectCommand* fromJSON(Json::Value& command); | |
| 274 | 240 |
| 275 const SkBitmap& bitmap() const { return fBitmap; } | 241 const SkBitmap& bitmap() const { return fBitmap; } |
| 276 | 242 |
| 277 // The non-const 'paint' method allows modification of this object's | 243 // The non-const 'paint' method allows modification of this object's |
| 278 // SkPaint. For this reason the ctor and setPaint method make a local copy. | 244 // SkPaint. For this reason the ctor and setPaint method make a local copy. |
| 279 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid | 245 // The 'fPaintPtr' member acts a signal that the local SkPaint is valid |
| 280 // (since only an SkPaint* is passed into the ctor). | 246 // (since only an SkPaint* is passed into the ctor). |
| 281 const SkPaint* paint() const { return fPaintPtr; } | 247 const SkPaint* paint() const { return fPaintPtr; } |
| 282 SkPaint* paint() { return fPaintPtr; } | 248 SkPaint* paint() { return fPaintPtr; } |
| 283 | 249 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 301 SkCanvas::SrcRectConstraint fConstraint; | 267 SkCanvas::SrcRectConstraint fConstraint; |
| 302 | 268 |
| 303 typedef SkDrawCommand INHERITED; | 269 typedef SkDrawCommand INHERITED; |
| 304 }; | 270 }; |
| 305 | 271 |
| 306 class SkDrawImageCommand : public SkDrawCommand { | 272 class SkDrawImageCommand : public SkDrawCommand { |
| 307 public: | 273 public: |
| 308 SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const
SkPaint* paint); | 274 SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const
SkPaint* paint); |
| 309 void execute(SkCanvas* canvas) const override; | 275 void execute(SkCanvas* canvas) const override; |
| 310 bool render(SkCanvas* canvas) const override; | 276 bool render(SkCanvas* canvas) const override; |
| 311 Json::Value toJSON() const override; | |
| 312 static SkDrawImageCommand* fromJSON(Json::Value& command); | |
| 313 | |
| 314 private: | 277 private: |
| 315 SkAutoTUnref<const SkImage> fImage; | 278 SkAutoTUnref<const SkImage> fImage; |
| 316 SkScalar fLeft; | 279 SkScalar fLeft; |
| 317 SkScalar fTop; | 280 SkScalar fTop; |
| 318 SkTLazy<SkPaint> fPaint; | 281 SkTLazy<SkPaint> fPaint; |
| 319 | 282 |
| 320 typedef SkDrawCommand INHERITED; | 283 typedef SkDrawCommand INHERITED; |
| 321 }; | 284 }; |
| 322 | 285 |
| 323 class SkDrawImageRectCommand : public SkDrawCommand { | 286 class SkDrawImageRectCommand : public SkDrawCommand { |
| 324 public: | 287 public: |
| 325 SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect
& dst, | 288 SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect
& dst, |
| 326 const SkPaint* paint, SkCanvas::SrcRectConstraint con
straint); | 289 const SkPaint* paint, SkCanvas::SrcRectConstraint con
straint); |
| 327 void execute(SkCanvas* canvas) const override; | 290 void execute(SkCanvas* canvas) const override; |
| 328 bool render(SkCanvas* canvas) const override; | 291 bool render(SkCanvas* canvas) const override; |
| 329 Json::Value toJSON() const override; | |
| 330 static SkDrawImageRectCommand* fromJSON(Json::Value& command); | |
| 331 | |
| 332 private: | 292 private: |
| 333 SkAutoTUnref<const SkImage> fImage; | 293 SkAutoTUnref<const SkImage> fImage; |
| 334 SkTLazy<SkRect> fSrc; | 294 SkTLazy<SkRect> fSrc; |
| 335 SkRect fDst; | 295 SkRect fDst; |
| 336 SkTLazy<SkPaint> fPaint; | 296 SkTLazy<SkPaint> fPaint; |
| 337 SkCanvas::SrcRectConstraint fConstraint; | 297 SkCanvas::SrcRectConstraint fConstraint; |
| 338 | 298 |
| 339 typedef SkDrawCommand INHERITED; | 299 typedef SkDrawCommand INHERITED; |
| 340 }; | 300 }; |
| 341 | 301 |
| 342 class SkDrawOvalCommand : public SkDrawCommand { | 302 class SkDrawOvalCommand : public SkDrawCommand { |
| 343 public: | 303 public: |
| 344 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint); | 304 SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint); |
| 345 void execute(SkCanvas* canvas) const override; | 305 void execute(SkCanvas* canvas) const override; |
| 346 bool render(SkCanvas* canvas) const override; | 306 bool render(SkCanvas* canvas) const override; |
| 347 Json::Value toJSON() const override; | |
| 348 static SkDrawOvalCommand* fromJSON(Json::Value& command); | |
| 349 | |
| 350 private: | 307 private: |
| 351 SkRect fOval; | 308 SkRect fOval; |
| 352 SkPaint fPaint; | 309 SkPaint fPaint; |
| 353 | 310 |
| 354 typedef SkDrawCommand INHERITED; | 311 typedef SkDrawCommand INHERITED; |
| 355 }; | 312 }; |
| 356 | 313 |
| 357 class SkDrawPaintCommand : public SkDrawCommand { | 314 class SkDrawPaintCommand : public SkDrawCommand { |
| 358 public: | 315 public: |
| 359 SkDrawPaintCommand(const SkPaint& paint); | 316 SkDrawPaintCommand(const SkPaint& paint); |
| 360 void execute(SkCanvas* canvas) const override; | 317 void execute(SkCanvas* canvas) const override; |
| 361 bool render(SkCanvas* canvas) const override; | 318 bool render(SkCanvas* canvas) const override; |
| 362 Json::Value toJSON() const override; | |
| 363 static SkDrawPaintCommand* fromJSON(Json::Value& command); | |
| 364 | |
| 365 private: | 319 private: |
| 366 SkPaint fPaint; | 320 SkPaint fPaint; |
| 367 | 321 |
| 368 typedef SkDrawCommand INHERITED; | 322 typedef SkDrawCommand INHERITED; |
| 369 }; | 323 }; |
| 370 | 324 |
| 371 class SkDrawPathCommand : public SkDrawCommand { | 325 class SkDrawPathCommand : public SkDrawCommand { |
| 372 public: | 326 public: |
| 373 SkDrawPathCommand(const SkPath& path, const SkPaint& paint); | 327 SkDrawPathCommand(const SkPath& path, const SkPaint& paint); |
| 374 void execute(SkCanvas* canvas) const override; | 328 void execute(SkCanvas* canvas) const override; |
| 375 bool render(SkCanvas* canvas) const override; | 329 bool render(SkCanvas* canvas) const override; |
| 376 Json::Value toJSON() const override; | |
| 377 static SkDrawPathCommand* fromJSON(Json::Value& command); | |
| 378 | 330 |
| 379 private: | 331 private: |
| 380 SkPath fPath; | 332 SkPath fPath; |
| 381 SkPaint fPaint; | 333 SkPaint fPaint; |
| 382 | 334 |
| 383 typedef SkDrawCommand INHERITED; | 335 typedef SkDrawCommand INHERITED; |
| 384 }; | 336 }; |
| 385 | 337 |
| 386 class SkBeginDrawPictureCommand : public SkDrawCommand { | 338 class SkBeginDrawPictureCommand : public SkDrawCommand { |
| 387 public: | 339 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 412 typedef SkDrawCommand INHERITED; | 364 typedef SkDrawCommand INHERITED; |
| 413 }; | 365 }; |
| 414 | 366 |
| 415 class SkDrawPointsCommand : public SkDrawCommand { | 367 class SkDrawPointsCommand : public SkDrawCommand { |
| 416 public: | 368 public: |
| 417 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pt
s[], | 369 SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pt
s[], |
| 418 const SkPaint& paint); | 370 const SkPaint& paint); |
| 419 virtual ~SkDrawPointsCommand() { delete [] fPts; } | 371 virtual ~SkDrawPointsCommand() { delete [] fPts; } |
| 420 void execute(SkCanvas* canvas) const override; | 372 void execute(SkCanvas* canvas) const override; |
| 421 bool render(SkCanvas* canvas) const override; | 373 bool render(SkCanvas* canvas) const override; |
| 422 Json::Value toJSON() const override; | |
| 423 static SkDrawPointsCommand* fromJSON(Json::Value& command); | |
| 424 | |
| 425 private: | 374 private: |
| 426 SkCanvas::PointMode fMode; | 375 SkCanvas::PointMode fMode; |
| 427 size_t fCount; | 376 size_t fCount; |
| 428 SkPoint* fPts; | 377 SkPoint* fPts; |
| 429 SkPaint fPaint; | 378 SkPaint fPaint; |
| 430 | 379 |
| 431 typedef SkDrawCommand INHERITED; | 380 typedef SkDrawCommand INHERITED; |
| 432 }; | 381 }; |
| 433 | 382 |
| 434 class SkDrawTextCommand : public SkDrawCommand { | 383 class SkDrawTextCommand : public SkDrawCommand { |
| 435 public: | 384 public: |
| 436 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar
y, | 385 SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar
y, |
| 437 const SkPaint& paint); | 386 const SkPaint& paint); |
| 438 virtual ~SkDrawTextCommand() { delete [] fText; } | 387 virtual ~SkDrawTextCommand() { delete [] fText; } |
| 439 void execute(SkCanvas* canvas) const override; | 388 void execute(SkCanvas* canvas) const override; |
| 440 Json::Value toJSON() const override; | |
| 441 static SkDrawTextCommand* fromJSON(Json::Value& command); | |
| 442 | |
| 443 private: | 389 private: |
| 444 char* fText; | 390 char* fText; |
| 445 size_t fByteLength; | 391 size_t fByteLength; |
| 446 SkScalar fX; | 392 SkScalar fX; |
| 447 SkScalar fY; | 393 SkScalar fY; |
| 448 SkPaint fPaint; | 394 SkPaint fPaint; |
| 449 | 395 |
| 450 typedef SkDrawCommand INHERITED; | 396 typedef SkDrawCommand INHERITED; |
| 451 }; | 397 }; |
| 452 | 398 |
| 453 class SkDrawPosTextCommand : public SkDrawCommand { | 399 class SkDrawPosTextCommand : public SkDrawCommand { |
| 454 public: | 400 public: |
| 455 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[
], | 401 SkDrawPosTextCommand(const void* text, size_t byteLength, const SkPoint pos[
], |
| 456 const SkPaint& paint); | 402 const SkPaint& paint); |
| 457 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; } | 403 virtual ~SkDrawPosTextCommand() { delete [] fPos; delete [] fText; } |
| 458 void execute(SkCanvas* canvas) const override; | 404 void execute(SkCanvas* canvas) const override; |
| 459 Json::Value toJSON() const override; | |
| 460 static SkDrawPosTextCommand* fromJSON(Json::Value& command); | |
| 461 | |
| 462 private: | 405 private: |
| 463 char* fText; | 406 char* fText; |
| 464 size_t fByteLength; | 407 size_t fByteLength; |
| 465 SkPoint* fPos; | 408 SkPoint* fPos; |
| 466 SkPaint fPaint; | 409 SkPaint fPaint; |
| 467 | 410 |
| 468 typedef SkDrawCommand INHERITED; | 411 typedef SkDrawCommand INHERITED; |
| 469 }; | 412 }; |
| 470 | 413 |
| 471 class SkDrawTextOnPathCommand : public SkDrawCommand { | 414 class SkDrawTextOnPathCommand : public SkDrawCommand { |
| 472 public: | 415 public: |
| 473 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& p
ath, | 416 SkDrawTextOnPathCommand(const void* text, size_t byteLength, const SkPath& p
ath, |
| 474 const SkMatrix* matrix, const SkPaint& paint); | 417 const SkMatrix* matrix, const SkPaint& paint); |
| 475 virtual ~SkDrawTextOnPathCommand() { delete [] fText; } | 418 virtual ~SkDrawTextOnPathCommand() { delete [] fText; } |
| 476 void execute(SkCanvas* canvas) const override; | 419 void execute(SkCanvas* canvas) const override; |
| 477 Json::Value toJSON() const override; | |
| 478 static SkDrawTextOnPathCommand* fromJSON(Json::Value& command); | |
| 479 | |
| 480 private: | 420 private: |
| 481 char* fText; | 421 char* fText; |
| 482 size_t fByteLength; | 422 size_t fByteLength; |
| 483 SkPath fPath; | 423 SkPath fPath; |
| 484 SkMatrix fMatrix; | 424 SkMatrix fMatrix; |
| 485 SkPaint fPaint; | 425 SkPaint fPaint; |
| 486 | 426 |
| 487 typedef SkDrawCommand INHERITED; | 427 typedef SkDrawCommand INHERITED; |
| 488 }; | 428 }; |
| 489 | 429 |
| 490 class SkDrawPosTextHCommand : public SkDrawCommand { | 430 class SkDrawPosTextHCommand : public SkDrawCommand { |
| 491 public: | 431 public: |
| 492 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xp
os[], | 432 SkDrawPosTextHCommand(const void* text, size_t byteLength, const SkScalar xp
os[], |
| 493 SkScalar constY, const SkPaint& paint); | 433 SkScalar constY, const SkPaint& paint); |
| 494 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; } | 434 virtual ~SkDrawPosTextHCommand() { delete [] fXpos; delete [] fText; } |
| 495 void execute(SkCanvas* canvas) const override; | 435 void execute(SkCanvas* canvas) const override; |
| 496 | |
| 497 private: | 436 private: |
| 498 SkScalar* fXpos; | 437 SkScalar* fXpos; |
| 499 char* fText; | 438 char* fText; |
| 500 size_t fByteLength; | 439 size_t fByteLength; |
| 501 SkScalar fConstY; | 440 SkScalar fConstY; |
| 502 SkPaint fPaint; | 441 SkPaint fPaint; |
| 503 | 442 |
| 504 typedef SkDrawCommand INHERITED; | 443 typedef SkDrawCommand INHERITED; |
| 505 }; | 444 }; |
| 506 | 445 |
| 507 class SkDrawTextBlobCommand : public SkDrawCommand { | 446 class SkDrawTextBlobCommand : public SkDrawCommand { |
| 508 public: | 447 public: |
| 509 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const
SkPaint& paint); | 448 SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x, SkScalar y, const
SkPaint& paint); |
| 510 | 449 |
| 511 void execute(SkCanvas* canvas) const override; | 450 void execute(SkCanvas* canvas) const override; |
| 512 bool render(SkCanvas* canvas) const override; | 451 bool render(SkCanvas* canvas) const override; |
| 513 Json::Value toJSON() const override; | |
| 514 static SkDrawTextBlobCommand* fromJSON(Json::Value& command); | |
| 515 | 452 |
| 516 private: | 453 private: |
| 517 SkAutoTUnref<const SkTextBlob> fBlob; | 454 SkAutoTUnref<const SkTextBlob> fBlob; |
| 518 SkScalar fXPos; | 455 SkScalar fXPos; |
| 519 SkScalar fYPos; | 456 SkScalar fYPos; |
| 520 SkPaint fPaint; | 457 SkPaint fPaint; |
| 521 | 458 |
| 522 typedef SkDrawCommand INHERITED; | 459 typedef SkDrawCommand INHERITED; |
| 523 }; | 460 }; |
| 524 | 461 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 537 SkPaint fPaint; | 474 SkPaint fPaint; |
| 538 | 475 |
| 539 typedef SkDrawCommand INHERITED; | 476 typedef SkDrawCommand INHERITED; |
| 540 }; | 477 }; |
| 541 | 478 |
| 542 | 479 |
| 543 class SkDrawRectCommand : public SkDrawCommand { | 480 class SkDrawRectCommand : public SkDrawCommand { |
| 544 public: | 481 public: |
| 545 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint); | 482 SkDrawRectCommand(const SkRect& rect, const SkPaint& paint); |
| 546 void execute(SkCanvas* canvas) const override; | 483 void execute(SkCanvas* canvas) const override; |
| 547 Json::Value toJSON() const override; | |
| 548 static SkDrawRectCommand* fromJSON(Json::Value& command); | |
| 549 | 484 |
| 550 const SkRect& rect() const { return fRect; } | 485 const SkRect& rect() const { return fRect; } |
| 551 const SkPaint& paint() const { return fPaint; } | 486 const SkPaint& paint() const { return fPaint; } |
| 552 private: | 487 private: |
| 553 SkRect fRect; | 488 SkRect fRect; |
| 554 SkPaint fPaint; | 489 SkPaint fPaint; |
| 555 | 490 |
| 556 typedef SkDrawCommand INHERITED; | 491 typedef SkDrawCommand INHERITED; |
| 557 }; | 492 }; |
| 558 | 493 |
| 559 class SkDrawRRectCommand : public SkDrawCommand { | 494 class SkDrawRRectCommand : public SkDrawCommand { |
| 560 public: | 495 public: |
| 561 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint); | 496 SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint); |
| 562 void execute(SkCanvas* canvas) const override; | 497 void execute(SkCanvas* canvas) const override; |
| 563 bool render(SkCanvas* canvas) const override; | 498 bool render(SkCanvas* canvas) const override; |
| 564 Json::Value toJSON() const override; | |
| 565 static SkDrawRRectCommand* fromJSON(Json::Value& command); | |
| 566 | |
| 567 private: | 499 private: |
| 568 SkRRect fRRect; | 500 SkRRect fRRect; |
| 569 SkPaint fPaint; | 501 SkPaint fPaint; |
| 570 | 502 |
| 571 typedef SkDrawCommand INHERITED; | 503 typedef SkDrawCommand INHERITED; |
| 572 }; | 504 }; |
| 573 | 505 |
| 574 class SkDrawDRRectCommand : public SkDrawCommand { | 506 class SkDrawDRRectCommand : public SkDrawCommand { |
| 575 public: | 507 public: |
| 576 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner, | 508 SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner, |
| 577 const SkPaint& paint); | 509 const SkPaint& paint); |
| 578 void execute(SkCanvas* canvas) const override; | 510 void execute(SkCanvas* canvas) const override; |
| 579 bool render(SkCanvas* canvas) const override; | 511 bool render(SkCanvas* canvas) const override; |
| 580 Json::Value toJSON() const override; | |
| 581 static SkDrawDRRectCommand* fromJSON(Json::Value& command); | |
| 582 | |
| 583 private: | 512 private: |
| 584 SkRRect fOuter; | 513 SkRRect fOuter; |
| 585 SkRRect fInner; | 514 SkRRect fInner; |
| 586 SkPaint fPaint; | 515 SkPaint fPaint; |
| 587 | 516 |
| 588 typedef SkDrawCommand INHERITED; | 517 typedef SkDrawCommand INHERITED; |
| 589 }; | 518 }; |
| 590 | 519 |
| 591 class SkDrawVerticesCommand : public SkDrawCommand { | 520 class SkDrawVerticesCommand : public SkDrawCommand { |
| 592 public: | 521 public: |
| 593 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount, | 522 SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount, |
| 594 const SkPoint vertices[], const SkPoint texs[], | 523 const SkPoint vertices[], const SkPoint texs[], |
| 595 const SkColor colors[], SkXfermode* xfermode, | 524 const SkColor colors[], SkXfermode* xfermode, |
| 596 const uint16_t indices[], int indexCount, | 525 const uint16_t indices[], int indexCount, |
| 597 const SkPaint& paint); | 526 const SkPaint& paint); |
| 598 virtual ~SkDrawVerticesCommand(); | 527 virtual ~SkDrawVerticesCommand(); |
| 599 void execute(SkCanvas* canvas) const override; | 528 void execute(SkCanvas* canvas) const override; |
| 600 | |
| 601 private: | 529 private: |
| 602 SkCanvas::VertexMode fVmode; | 530 SkCanvas::VertexMode fVmode; |
| 603 int fVertexCount; | 531 int fVertexCount; |
| 604 SkPoint* fVertices; | 532 SkPoint* fVertices; |
| 605 SkPoint* fTexs; | 533 SkPoint* fTexs; |
| 606 SkColor* fColors; | 534 SkColor* fColors; |
| 607 SkXfermode* fXfermode; | 535 SkXfermode* fXfermode; |
| 608 uint16_t* fIndices; | 536 uint16_t* fIndices; |
| 609 int fIndexCount; | 537 int fIndexCount; |
| 610 SkPaint fPaint; | 538 SkPaint fPaint; |
| 611 | 539 |
| 612 typedef SkDrawCommand INHERITED; | 540 typedef SkDrawCommand INHERITED; |
| 613 }; | 541 }; |
| 614 | 542 |
| 615 class SkSaveCommand : public SkDrawCommand { | 543 class SkSaveCommand : public SkDrawCommand { |
| 616 public: | 544 public: |
| 617 SkSaveCommand(); | 545 SkSaveCommand(); |
| 618 void execute(SkCanvas* canvas) const override; | 546 void execute(SkCanvas* canvas) const override; |
| 619 Action action() const override { return kPushLayer_Action; } | 547 Action action() const override { return kPushLayer_Action; } |
| 620 static SkSaveCommand* fromJSON(Json::Value& command); | |
| 621 | |
| 622 private: | 548 private: |
| 623 typedef SkDrawCommand INHERITED; | 549 typedef SkDrawCommand INHERITED; |
| 624 }; | 550 }; |
| 625 | 551 |
| 626 class SkSaveLayerCommand : public SkDrawCommand { | 552 class SkSaveLayerCommand : public SkDrawCommand { |
| 627 public: | 553 public: |
| 628 SkSaveLayerCommand(const SkCanvas::SaveLayerRec&); | 554 SkSaveLayerCommand(const SkCanvas::SaveLayerRec&); |
| 629 virtual ~SkSaveLayerCommand(); | |
| 630 void execute(SkCanvas* canvas) const override; | 555 void execute(SkCanvas* canvas) const override; |
| 631 Json::Value toJSON() const override; | |
| 632 static SkSaveLayerCommand* fromJSON(Json::Value& command); | |
| 633 void vizExecute(SkCanvas* canvas) const override; | 556 void vizExecute(SkCanvas* canvas) const override; |
| 634 Action action() const override{ return kPushLayer_Action; } | 557 Action action() const override{ return kPushLayer_Action; } |
| 635 void setActive(bool active) override { fActive = active; } | 558 void setActive(bool active) override { fActive = active; } |
| 636 bool active() const override { return fActive; } | 559 bool active() const override { return fActive; } |
| 637 | 560 |
| 638 const SkPaint* paint() const { return fPaintPtr; } | 561 const SkPaint* paint() const { return fPaintPtr; } |
| 639 | 562 |
| 640 private: | 563 private: |
| 641 SkRect fBounds; | 564 SkRect fBounds; |
| 642 SkPaint fPaint; | 565 SkPaint fPaint; |
| 643 SkPaint* fPaintPtr; | 566 SkPaint* fPaintPtr; |
| 644 const SkImageFilter* fBackdrop; | 567 uint32_t fSaveLayerFlags; |
| 645 uint32_t fSaveLayerFlags; | |
| 646 | 568 |
| 647 bool fActive; | 569 bool fActive; |
| 648 | 570 |
| 649 typedef SkDrawCommand INHERITED; | 571 typedef SkDrawCommand INHERITED; |
| 650 }; | 572 }; |
| 651 | 573 |
| 652 class SkSetMatrixCommand : public SkDrawCommand { | 574 class SkSetMatrixCommand : public SkDrawCommand { |
| 653 public: | 575 public: |
| 654 SkSetMatrixCommand(const SkMatrix& matrix); | 576 SkSetMatrixCommand(const SkMatrix& matrix); |
| 655 void setUserMatrix(const SkMatrix&) override; | 577 void setUserMatrix(const SkMatrix&) override; |
| 656 void execute(SkCanvas* canvas) const override; | 578 void execute(SkCanvas* canvas) const override; |
| 657 Json::Value toJSON() const override; | |
| 658 static SkSetMatrixCommand* fromJSON(Json::Value& command); | |
| 659 | |
| 660 private: | 579 private: |
| 661 SkMatrix fUserMatrix; | 580 SkMatrix fUserMatrix; |
| 662 SkMatrix fMatrix; | 581 SkMatrix fMatrix; |
| 663 | 582 |
| 664 typedef SkDrawCommand INHERITED; | 583 typedef SkDrawCommand INHERITED; |
| 665 }; | 584 }; |
| 666 | 585 |
| 667 #endif | 586 #endif |
| OLD | NEW |