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 "SkBitmap.h"
12 #include "SkCanvas.h"
13 #include "SkDrawShadowInfo.h"
14 #include "SkFlattenable.h"
15 #include "SkJSONWriter.h"
16 #include "SkTLazy.h"
17 #include "SkPath.h"
18 #include "SkRegion.h"
19 #include "SkRRect.h"
20 #include "SkRSXform.h"
21 #include "SkString.h"
22 #include "SkTDArray.h"
23 #include "SkVertices.h"
24 #include "UrlDataManager.h"
25 
26 class SkDrawCommand {
27 public:
28     enum OpType {
29         kBeginDrawPicture_OpType,
30         kClear_OpType,
31         kClipPath_OpType,
32         kClipRegion_OpType,
33         kClipRect_OpType,
34         kClipRRect_OpType,
35         kConcat_OpType,
36         kDrawAnnotation_OpType,
37         kDrawBitmap_OpType,
38         kDrawBitmapLattice_OpType,
39         kDrawBitmapNine_OpType,
40         kDrawBitmapRect_OpType,
41         kDrawDRRect_OpType,
42         kDrawImage_OpType,
43         kDrawImageLattice_OpType,
44         kDrawImageNine_OpType,
45         kDrawImageRect_OpType,
46         kDrawImageSet_OpType,
47         kDrawOval_OpType,
48         kDrawArc_OpType,
49         kDrawPaint_OpType,
50         kDrawPatch_OpType,
51         kDrawPath_OpType,
52         kDrawPoints_OpType,
53         kDrawRect_OpType,
54         kDrawEdgeAARect_OpType,
55         kDrawRRect_OpType,
56         kDrawRegion_OpType,
57         kDrawShadow_OpType,
58         kDrawTextBlob_OpType,
59         kDrawVertices_OpType,
60         kDrawAtlas_OpType,
61         kDrawDrawable_OpType,
62         kEndDrawPicture_OpType,
63         kRestore_OpType,
64         kSave_OpType,
65         kSaveLayer_OpType,
66         kSetMatrix_OpType,
67 
68         kLast_OpType = kSetMatrix_OpType
69     };
70 
71     static const int kOpTypeCount = kLast_OpType + 1;
72 
73     static void WritePNG(SkBitmap bitmap, SkWStream& out);
74 
75     SkDrawCommand(OpType opType);
76 
~SkDrawCommand()77     virtual ~SkDrawCommand() {}
78 
isVisible()79     bool isVisible() const {
80         return fVisible;
81     }
82 
setVisible(bool toggle)83     void setVisible(bool toggle) {
84         fVisible = toggle;
85     }
86 
87     virtual void execute(SkCanvas*) const = 0;
88 
render(SkCanvas * canvas)89     virtual bool render(SkCanvas* canvas) const { return false; }
90 
91     virtual void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const;
92 
93     static const char* GetCommandString(OpType type);
94 
95     // Helper methods for converting things to JSON
96     static void MakeJsonColor(SkJSONWriter&, const SkColor color);
97     static void MakeJsonColor4f(SkJSONWriter&, const SkColor4f& color);
98     static void MakeJsonPoint(SkJSONWriter&, const SkPoint& point);
99     static void MakeJsonPoint(SkJSONWriter&, SkScalar x, SkScalar y);
100     static void MakeJsonPoint3(SkJSONWriter&, const SkPoint3& point);
101     static void MakeJsonRect(SkJSONWriter&, const SkRect& rect);
102     static void MakeJsonIRect(SkJSONWriter&, const SkIRect&);
103     static void MakeJsonMatrix(SkJSONWriter&, const SkMatrix&);
104     static void MakeJsonPath(SkJSONWriter&, const SkPath& path);
105     static void MakeJsonRegion(SkJSONWriter&, const SkRegion& region);
106     static void MakeJsonPaint(SkJSONWriter&, const SkPaint& paint, UrlDataManager& urlDataManager);
107     static void MakeJsonLattice(SkJSONWriter&, const SkCanvas::Lattice& lattice);
108 
109     static void flatten(const SkFlattenable* flattenable, SkJSONWriter& writer,
110                         UrlDataManager& urlDataManager);
111     static bool flatten(const SkImage& image, SkJSONWriter& writer,
112                         UrlDataManager& urlDataManager);
113     static bool flatten(const SkBitmap& bitmap, SkJSONWriter& writer,
114                         UrlDataManager& urlDataManager);
115 
116 private:
117     OpType fOpType;
118     bool   fVisible;
119 };
120 
121 class SkRestoreCommand : public SkDrawCommand {
122 public:
123     SkRestoreCommand();
124     void execute(SkCanvas* canvas) const override;
125 
126 private:
127     typedef SkDrawCommand INHERITED;
128 };
129 
130 class SkClearCommand : public SkDrawCommand {
131 public:
132     SkClearCommand(SkColor color);
133     void execute(SkCanvas* canvas) const override;
134     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
135 
136 private:
137     SkColor fColor;
138 
139     typedef SkDrawCommand INHERITED;
140 };
141 
142 class SkClipPathCommand : public SkDrawCommand {
143 public:
144     SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA);
145     void execute(SkCanvas* canvas) const override;
146     bool render(SkCanvas* canvas) const override;
147     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
148 
149 private:
150     SkPath   fPath;
151     SkClipOp fOp;
152     bool     fDoAA;
153 
154     typedef SkDrawCommand INHERITED;
155 };
156 
157 class SkClipRegionCommand : public SkDrawCommand {
158 public:
159     SkClipRegionCommand(const SkRegion& region, SkClipOp op);
160     void execute(SkCanvas* canvas) const override;
161     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
162 
163 private:
164     SkRegion fRegion;
165     SkClipOp fOp;
166 
167     typedef SkDrawCommand INHERITED;
168 };
169 
170 class SkClipRectCommand : public SkDrawCommand {
171 public:
172     SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA);
173     void execute(SkCanvas* canvas) const override;
174     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
175 
176 private:
177     SkRect   fRect;
178     SkClipOp fOp;
179     bool     fDoAA;
180 
181     typedef SkDrawCommand INHERITED;
182 };
183 
184 class SkClipRRectCommand : public SkDrawCommand {
185 public:
186     SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA);
187     void execute(SkCanvas* canvas) const override;
188     bool render(SkCanvas* canvas) const override;
189     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
190 
191 private:
192     SkRRect  fRRect;
193     SkClipOp fOp;
194     bool     fDoAA;
195 
196     typedef SkDrawCommand INHERITED;
197 };
198 
199 class SkConcatCommand : public SkDrawCommand {
200 public:
201     SkConcatCommand(const SkMatrix& matrix);
202     void execute(SkCanvas* canvas) const override;
203     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
204 
205 private:
206     SkMatrix fMatrix;
207 
208     typedef SkDrawCommand INHERITED;
209 };
210 
211 class SkDrawAnnotationCommand : public SkDrawCommand {
212 public:
213     SkDrawAnnotationCommand(const SkRect&, const char key[], sk_sp<SkData> value);
214     void execute(SkCanvas* canvas) const override;
215     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
216 
217 private:
218     SkRect          fRect;
219     SkString        fKey;
220     sk_sp<SkData>   fValue;
221 
222     typedef SkDrawCommand INHERITED;
223 };
224 
225 class SkDrawBitmapCommand : public SkDrawCommand {
226 public:
227     SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
228                         const SkPaint* paint);
229     void execute(SkCanvas* canvas) const override;
230     bool render(SkCanvas* canvas) const override;
231     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
232 
233 private:
234     SkBitmap         fBitmap;
235     SkScalar         fLeft;
236     SkScalar         fTop;
237     SkTLazy<SkPaint> fPaint;
238 
239     typedef SkDrawCommand INHERITED;
240 };
241 
242 class SkDrawBitmapLatticeCommand : public SkDrawCommand {
243 public:
244     SkDrawBitmapLatticeCommand(const SkBitmap& bitmap, const SkCanvas::Lattice& lattice,
245                                const SkRect& dst, const SkPaint* paint);
246     void execute(SkCanvas* canvas) const override;
247     bool render(SkCanvas* canvas) const override;
248     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
249 
250 private:
251     SkBitmap          fBitmap;
252     SkCanvas::Lattice fLattice;
253     SkRect            fDst;
254     SkTLazy<SkPaint>  fPaint;
255 
256     typedef SkDrawCommand INHERITED;
257 };
258 
259 class SkDrawBitmapNineCommand : public SkDrawCommand {
260 public:
261     SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
262                             const SkRect& dst, const SkPaint* paint);
263     void execute(SkCanvas* canvas) const override;
264     bool render(SkCanvas* canvas) const override;
265     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
266 
267 private:
268     SkBitmap         fBitmap;
269     SkIRect          fCenter;
270     SkRect           fDst;
271     SkTLazy<SkPaint> fPaint;
272 
273     typedef SkDrawCommand INHERITED;
274 };
275 
276 class SkDrawBitmapRectCommand : public SkDrawCommand {
277 public:
278     SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
279                             const SkRect& dst, const SkPaint* paint,
280                             SkCanvas::SrcRectConstraint);
281     void execute(SkCanvas* canvas) const override;
282     bool render(SkCanvas* canvas) const override;
283     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
284 
285 private:
286     SkBitmap                      fBitmap;
287     SkTLazy<SkRect>               fSrc;
288     SkRect                        fDst;
289     SkTLazy<SkPaint>              fPaint;
290     SkCanvas::SrcRectConstraint   fConstraint;
291 
292     typedef SkDrawCommand INHERITED;
293 };
294 
295 class SkDrawImageCommand : public SkDrawCommand {
296 public:
297     SkDrawImageCommand(const SkImage* image, SkScalar left, SkScalar top, const SkPaint* paint);
298     void execute(SkCanvas* canvas) const override;
299     bool render(SkCanvas* canvas) const override;
300     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
301 
302 private:
303     sk_sp<const SkImage> fImage;
304     SkScalar             fLeft;
305     SkScalar             fTop;
306     SkTLazy<SkPaint>     fPaint;
307 
308     typedef SkDrawCommand INHERITED;
309 };
310 
311 class SkDrawImageLatticeCommand : public SkDrawCommand {
312 public:
313     SkDrawImageLatticeCommand(const SkImage* image, const SkCanvas::Lattice& lattice,
314                               const SkRect& dst, const SkPaint* paint);
315     void execute(SkCanvas* canvas) const override;
316     bool render(SkCanvas* canvas) const override;
317     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
318 
319 private:
320     sk_sp<const SkImage>        fImage;
321     SkCanvas::Lattice           fLattice;
322     SkRect                      fDst;
323     SkTLazy<SkPaint>            fPaint;
324 
325     typedef SkDrawCommand INHERITED;
326 };
327 
328 class SkDrawImageNineCommand : public SkDrawCommand {
329 public:
330     SkDrawImageNineCommand(const SkImage* image, const SkIRect& center,
331                            const SkRect& dst, const SkPaint* paint);
332     void execute(SkCanvas* canvas) const override;
333     bool render(SkCanvas* canvas) const override;
334     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
335 
336 private:
337     sk_sp<const SkImage> fImage;
338     SkIRect              fCenter;
339     SkRect               fDst;
340     SkTLazy<SkPaint>     fPaint;
341 
342     typedef SkDrawCommand INHERITED;
343 };
344 
345 class SkDrawImageRectCommand : public SkDrawCommand {
346 public:
347     SkDrawImageRectCommand(const SkImage* image, const SkRect* src, const SkRect& dst,
348                            const SkPaint* paint, SkCanvas::SrcRectConstraint constraint);
349     void execute(SkCanvas* canvas) const override;
350     bool render(SkCanvas* canvas) const override;
351     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
352 
353 private:
354     sk_sp<const SkImage>        fImage;
355     SkTLazy<SkRect>             fSrc;
356     SkRect                      fDst;
357     SkTLazy<SkPaint>            fPaint;
358     SkCanvas::SrcRectConstraint fConstraint;
359 
360     typedef SkDrawCommand INHERITED;
361 };
362 
363 class SkDrawImageSetCommand : public SkDrawCommand {
364 public:
365     SkDrawImageSetCommand(const SkCanvas::ImageSetEntry[], int count, SkFilterQuality, SkBlendMode);
366     void execute(SkCanvas* canvas) const override;
367 
368 private:
369     SkAutoTArray<SkCanvas::ImageSetEntry> fSet;
370     int fCount;
371     SkFilterQuality fFilterQuality;
372     SkBlendMode fMode;
373 
374     typedef SkDrawCommand INHERITED;
375 };
376 
377 class SkDrawOvalCommand : public SkDrawCommand {
378 public:
379     SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint);
380     void execute(SkCanvas* canvas) const override;
381     bool render(SkCanvas* canvas) const override;
382     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
383 
384 private:
385     SkRect  fOval;
386     SkPaint fPaint;
387 
388     typedef SkDrawCommand INHERITED;
389 };
390 
391 class SkDrawArcCommand : public SkDrawCommand {
392 public:
393     SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter,
394                      const SkPaint& paint);
395     void execute(SkCanvas* canvas) const override;
396     bool render(SkCanvas* canvas) const override;
397     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
398 
399 private:
400     SkRect   fOval;
401     SkScalar fStartAngle;
402     SkScalar fSweepAngle;
403     bool     fUseCenter;
404     SkPaint  fPaint;
405 
406     typedef SkDrawCommand INHERITED;
407 };
408 
409 class SkDrawPaintCommand : public SkDrawCommand {
410 public:
411     SkDrawPaintCommand(const SkPaint& paint);
412     void execute(SkCanvas* canvas) const override;
413     bool render(SkCanvas* canvas) const override;
414     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
415 
416 private:
417     SkPaint fPaint;
418 
419     typedef SkDrawCommand INHERITED;
420 };
421 
422 class SkDrawBehindCommand : public SkDrawCommand {
423 public:
424     SkDrawBehindCommand(const SkPaint& paint);
425     void execute(SkCanvas* canvas) const override;
426     bool render(SkCanvas* canvas) const override;
427     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
428 
429 private:
430     SkPaint fPaint;
431 
432     typedef SkDrawCommand INHERITED;
433 };
434 
435 class SkDrawPathCommand : public SkDrawCommand {
436 public:
437     SkDrawPathCommand(const SkPath& path, const SkPaint& paint);
438     void execute(SkCanvas* canvas) const override;
439     bool render(SkCanvas* canvas) const override;
440     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
441 
442 private:
443     SkPath   fPath;
444     SkPaint  fPaint;
445 
446     typedef SkDrawCommand INHERITED;
447 };
448 
449 class SkBeginDrawPictureCommand : public SkDrawCommand {
450 public:
451     SkBeginDrawPictureCommand(const SkPicture* picture,
452                               const SkMatrix* matrix,
453                               const SkPaint* paint);
454 
455     void execute(SkCanvas* canvas) const override;
456     bool render(SkCanvas* canvas) const override;
457 
458 private:
459     sk_sp<const SkPicture> fPicture;
460     SkTLazy<SkMatrix>      fMatrix;
461     SkTLazy<SkPaint>       fPaint;
462 
463     typedef SkDrawCommand INHERITED;
464 };
465 
466 class SkEndDrawPictureCommand : public SkDrawCommand {
467 public:
468     SkEndDrawPictureCommand(bool restore);
469 
470     void execute(SkCanvas* canvas) const override;
471 
472 private:
473     bool fRestore;
474 
475     typedef SkDrawCommand INHERITED;
476 };
477 
478 class SkDrawPointsCommand : public SkDrawCommand {
479 public:
480     SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, const SkPoint pts[],
481                         const SkPaint& paint);
482     void execute(SkCanvas* canvas) const override;
483     bool render(SkCanvas* canvas) const override;
484     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
485 
486 private:
487     SkCanvas::PointMode fMode;
488     SkTDArray<SkPoint>  fPts;
489     SkPaint             fPaint;
490 
491     typedef SkDrawCommand INHERITED;
492 };
493 
494 class SkDrawRegionCommand : public SkDrawCommand {
495 public:
496     SkDrawRegionCommand(const SkRegion& region, const SkPaint& paint);
497     void execute(SkCanvas* canvas) const override;
498     bool render(SkCanvas* canvas) const override;
499     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
500 
501 private:
502     SkRegion fRegion;
503     SkPaint  fPaint;
504 
505     typedef SkDrawCommand INHERITED;
506 };
507 
508 class SkDrawTextBlobCommand : public SkDrawCommand {
509 public:
510     SkDrawTextBlobCommand(sk_sp<SkTextBlob> blob, SkScalar x, SkScalar y, const SkPaint& paint);
511 
512     void execute(SkCanvas* canvas) const override;
513     bool render(SkCanvas* canvas) const override;
514     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
515 
516 private:
517     sk_sp<SkTextBlob> fBlob;
518     SkScalar          fXPos;
519     SkScalar          fYPos;
520     SkPaint           fPaint;
521 
522     typedef SkDrawCommand INHERITED;
523 };
524 
525 class SkDrawPatchCommand : public SkDrawCommand {
526 public:
527     SkDrawPatchCommand(const SkPoint cubics[12], const SkColor colors[4],
528                        const SkPoint texCoords[4], SkBlendMode bmode,
529                        const SkPaint& paint);
530     void execute(SkCanvas* canvas) const override;
531     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
532 
533 private:
534     SkPoint fCubics[12];
535     SkColor* fColorsPtr;
536     SkColor  fColors[4];
537     SkPoint* fTexCoordsPtr;
538     SkPoint  fTexCoords[4];
539     SkBlendMode fBlendMode;
540     SkPaint fPaint;
541 
542     typedef SkDrawCommand INHERITED;
543 };
544 
545 
546 class SkDrawRectCommand : public SkDrawCommand {
547 public:
548     SkDrawRectCommand(const SkRect& rect, const SkPaint& paint);
549     void execute(SkCanvas* canvas) const override;
550     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
551 
552 private:
553     SkRect  fRect;
554     SkPaint fPaint;
555 
556     typedef SkDrawCommand INHERITED;
557 };
558 
559 class SkDrawEdgeAARectCommand : public SkDrawCommand {
560 public:
561     SkDrawEdgeAARectCommand(const SkRect& rect, SkCanvas::QuadAAFlags aa, SkColor color,
562                             SkBlendMode mode);
563     void execute(SkCanvas* canvas) const override;
564 
565 private:
566     SkRect  fRect;
567     SkCanvas::QuadAAFlags fAA;
568     SkColor fColor;
569     SkBlendMode fMode;
570 
571     typedef SkDrawCommand INHERITED;
572 };
573 
574 class SkDrawRRectCommand : public SkDrawCommand {
575 public:
576     SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint);
577     void execute(SkCanvas* canvas) const override;
578     bool render(SkCanvas* canvas) const override;
579     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
580 
581 private:
582     SkRRect fRRect;
583     SkPaint fPaint;
584 
585     typedef SkDrawCommand INHERITED;
586 };
587 
588 class SkDrawDRRectCommand : public SkDrawCommand {
589 public:
590     SkDrawDRRectCommand(const SkRRect& outer, const SkRRect& inner,
591                         const SkPaint& paint);
592     void execute(SkCanvas* canvas) const override;
593     bool render(SkCanvas* canvas) const override;
594     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
595 
596 private:
597     SkRRect fOuter;
598     SkRRect fInner;
599     SkPaint fPaint;
600 
601     typedef SkDrawCommand INHERITED;
602 };
603 
604 class SkDrawVerticesCommand : public SkDrawCommand {
605 public:
606     SkDrawVerticesCommand(sk_sp<SkVertices>, SkBlendMode, const SkPaint&);
607 
608     void execute(SkCanvas* canvas) const override;
609 
610 private:
611     sk_sp<SkVertices>   fVertices;
612     SkBlendMode         fBlendMode;
613     SkPaint             fPaint;
614 
615     typedef SkDrawCommand INHERITED;
616 };
617 
618 class SkDrawAtlasCommand : public SkDrawCommand {
619 public:
620     SkDrawAtlasCommand(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
621                        SkBlendMode, const SkRect*, const SkPaint*);
622 
623     void execute(SkCanvas* canvas) const override;
624 
625 private:
626     sk_sp<const SkImage> fImage;
627     SkTDArray<SkRSXform> fXform;
628     SkTDArray<SkRect>    fTex;
629     SkTDArray<SkColor>   fColors;
630     SkBlendMode          fBlendMode;
631     SkTLazy<SkRect>      fCull;
632     SkTLazy<SkPaint>     fPaint;
633 
634     typedef SkDrawCommand INHERITED;
635 };
636 
637 class SkSaveCommand : public SkDrawCommand {
638 public:
639     SkSaveCommand();
640     void execute(SkCanvas* canvas) const override;
641 
642 private:
643     typedef SkDrawCommand INHERITED;
644 };
645 
646 class SkSaveLayerCommand : public SkDrawCommand {
647 public:
648     SkSaveLayerCommand(const SkCanvas::SaveLayerRec&);
649     void execute(SkCanvas* canvas) const override;
650     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
651 
652 private:
653     SkTLazy<SkRect>            fBounds;
654     SkTLazy<SkPaint>           fPaint;
655     sk_sp<const SkImageFilter> fBackdrop;
656     uint32_t                   fSaveLayerFlags;
657 
658     typedef SkDrawCommand INHERITED;
659 };
660 
661 class SkSetMatrixCommand : public SkDrawCommand {
662 public:
663     SkSetMatrixCommand(const SkMatrix& matrix);
664     void execute(SkCanvas* canvas) const override;
665     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
666 
667 private:
668     SkMatrix fMatrix;
669 
670     typedef SkDrawCommand INHERITED;
671 };
672 
673 class SkDrawShadowCommand : public SkDrawCommand {
674 public:
675     SkDrawShadowCommand(const SkPath& path, const SkDrawShadowRec& rec);
676     void execute(SkCanvas* canvas) const override;
677     bool render(SkCanvas* canvas) const override;
678     void toJSON(SkJSONWriter& writer, UrlDataManager& urlDataManager) const override;
679 
680 private:
681     SkPath           fPath;
682     SkDrawShadowRec  fShadowRec;
683 
684     typedef SkDrawCommand INHERITED;
685 };
686 
687 class SkDrawDrawableCommand : public SkDrawCommand {
688 public:
689     SkDrawDrawableCommand(SkDrawable*, const SkMatrix*);
690     void execute(SkCanvas* canvas) const override;
691 
692 private:
693     sk_sp<SkDrawable> fDrawable;
694     SkTLazy<SkMatrix> fMatrix;
695 
696     typedef SkDrawCommand INHERITED;
697 };
698 #endif
699