1 /*
2  * Copyright 2016 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 SkLiteRecorder_DEFINED
9 #define SkLiteRecorder_DEFINED
10 
11 #include "SkNoDrawCanvas.h"
12 
13 class SkLiteDL;
14 
15 class SkLiteRecorder final : public SkNoDrawCanvas {
16 public:
17     SkLiteRecorder();
18     void reset(SkLiteDL*, const SkIRect& bounds);
19 
20     sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
21 
22 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER
23     SkDrawFilter* setDrawFilter(SkDrawFilter*) override;
24 #endif
25 
26     void willSave() override;
27     SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
28     void willRestore() override;
29 
30     void onFlush() override;
31 
32     void didConcat(const SkMatrix&) override;
33     void didSetMatrix(const SkMatrix&) override;
34     void didTranslate(SkScalar, SkScalar) override;
35 
36     void onClipRect  (const   SkRect&, SkClipOp, ClipEdgeStyle) override;
37     void onClipRRect (const  SkRRect&, SkClipOp, ClipEdgeStyle) override;
38     void onClipPath  (const   SkPath&, SkClipOp, ClipEdgeStyle) override;
39     void onClipRegion(const SkRegion&, SkClipOp) override;
40 
41     void onDrawPaint (const SkPaint&) override;
42     void onDrawPath  (const SkPath&, const SkPaint&) override;
43     void onDrawRect  (const SkRect&, const SkPaint&) override;
44     void onDrawRegion(const SkRegion&, const SkPaint&) override;
45     void onDrawOval  (const SkRect&, const SkPaint&) override;
46     void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
47     void onDrawRRect (const SkRRect&, const SkPaint&) override;
48     void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
49 
50     void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
51     void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
52     void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
53 
54     void onDrawText      (const void*, size_t, SkScalar x, SkScalar y, const SkPaint&) override;
55     void onDrawPosText   (const void*, size_t, const SkPoint[], const SkPaint&) override;
56     void onDrawPosTextH  (const void*, size_t, const SkScalar[], SkScalar, const SkPaint&) override;
57     void onDrawTextOnPath(const void*, size_t,
58                           const SkPath&, const SkMatrix*, const SkPaint&) override;
59     void onDrawTextRSXform(const void*, size_t,
60                            const SkRSXform[], const SkRect*, const SkPaint&) override;
61     void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
62 
63     void onDrawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint*) override;
64     void onDrawBitmapLattice(const SkBitmap&, const Lattice&, const SkRect&,
65                              const SkPaint*) override;
66     void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, const SkPaint*) override;
67     void onDrawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*,
68                           SrcRectConstraint) override;
69 
70     void onDrawImage(const SkImage*, SkScalar, SkScalar, const SkPaint*) override;
71     void onDrawImageLattice(const SkImage*, const Lattice&, const SkRect&, const SkPaint*) override;
72     void onDrawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*) override;
73     void onDrawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*,
74                          SrcRectConstraint) override;
75 
76     void onDrawPatch(const SkPoint[12], const SkColor[4],
77                      const SkPoint[4], SkBlendMode, const SkPaint&) override;
78     void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
79     void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
80     void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
81                      int, SkBlendMode, const SkRect*, const SkPaint*) override;
82     void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
83 
84 private:
85     typedef SkNoDrawCanvas INHERITED;
86 
87     SkLiteDL* fDL;
88 };
89 
90 #endif//SkLiteRecorder_DEFINED
91