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