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