• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SkLiteDL_DEFINED
9 #define SkLiteDL_DEFINED
10 
11 #include "SkCanvas.h"
12 #include "SkPaint.h"
13 #include "SkPath.h"
14 #include "SkDrawable.h"
15 #include "SkRect.h"
16 #include "SkTDArray.h"
17 
18 class SkLiteDL final {
19 public:
20     ~SkLiteDL();
21 
22     void draw(SkCanvas* canvas);
23 
24     void reset();
empty()25     bool empty() const { return fUsed == 0; }
26 
27 #ifdef SK_SUPPORT_LEGACY_DRAWFILTER
28     void setDrawFilter(SkDrawFilter*);
29 #endif
30 
31     void save();
32     void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, SkCanvas::SaveLayerFlags);
33     void restore();
34 
35     void    concat (const SkMatrix&);
36     void setMatrix (const SkMatrix&);
37     void translate(SkScalar, SkScalar);
38     void translateZ(SkScalar);
39 
40     void clipPath  (const   SkPath&, SkClipOp, bool aa);
41     void clipRect  (const   SkRect&, SkClipOp, bool aa);
42     void clipRRect (const  SkRRect&, SkClipOp, bool aa);
43     void clipRegion(const SkRegion&, SkClipOp);
44 
45     void drawPaint (const SkPaint&);
46     void drawPath  (const SkPath&, const SkPaint&);
47     void drawRect  (const SkRect&, const SkPaint&);
48     void drawRegion(const SkRegion&, const SkPaint&);
49     void drawOval  (const SkRect&, const SkPaint&);
50     void drawArc   (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&);
51     void drawRRect (const SkRRect&, const SkPaint&);
52     void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
53 
54     void drawAnnotation     (const SkRect&, const char*, SkData*);
55     void drawDrawable       (SkDrawable*, const SkMatrix*);
56     void drawPicture        (const SkPicture*, const SkMatrix*, const SkPaint*);
57     void drawShadowedPicture(const SkPicture*, const SkMatrix*,
58                              const SkPaint*, const SkShadowParams& params);
59 
60     void drawText       (const void*, size_t, SkScalar, SkScalar, const SkPaint&);
61     void drawPosText    (const void*, size_t, const SkPoint[], const SkPaint&);
62     void drawPosTextH   (const void*, size_t, const SkScalar[], SkScalar, const SkPaint&);
63     void drawTextOnPath (const void*, size_t, const SkPath&, const SkMatrix*, const SkPaint&);
64     void drawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*, const SkPaint&);
65     void drawTextBlob   (const SkTextBlob*, SkScalar,SkScalar, const SkPaint&);
66 
67     void drawImage    (sk_sp<const SkImage>, SkScalar,SkScalar,             const SkPaint*);
68     void drawImageNine(sk_sp<const SkImage>, const SkIRect&, const SkRect&, const SkPaint*);
69     void drawImageRect(sk_sp<const SkImage>, const SkRect*, const SkRect&,  const SkPaint*,
70                        SkCanvas::SrcRectConstraint);
71     void drawImageLattice(sk_sp<const SkImage>, const SkCanvas::Lattice&,
72                           const SkRect&, const SkPaint*);
73 
74     void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4],
75                    SkBlendMode, const SkPaint&);
76     void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&);
77     void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&);
78     void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
79                    SkBlendMode, const SkRect*, const SkPaint*);
80 
81 private:
82     template <typename T, typename... Args>
83     void* push(size_t, Args&&...);
84 
85     template <typename Fn, typename... Args>
86     void map(const Fn[], Args...);
87 
88     SkAutoTMalloc<uint8_t> fBytes;
89     size_t                 fUsed = 0;
90     size_t                 fReserved = 0;
91 };
92 
93 #endif//SkLiteDL_DEFINED
94