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