mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 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" |
Florin Malita | ab244f0 | 2017-05-03 19:16:58 +0000 | [diff] [blame] | 17 | #include "SkTemplates.h" |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 18 | |
Derek Sollenberger | d7875f5 | 2017-03-01 15:33:23 -0500 | [diff] [blame] | 19 | class SkLiteDL final { |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 20 | public: |
Derek Sollenberger | d7875f5 | 2017-03-01 15:33:23 -0500 | [diff] [blame] | 21 | ~SkLiteDL(); |
mtklein | 0c753e5 | 2016-08-09 07:40:23 -0700 | [diff] [blame] | 22 | |
Mike Klein | da90109 | 2017-04-11 11:32:33 -0400 | [diff] [blame] | 23 | void draw(SkCanvas* canvas) const; |
Derek Sollenberger | d7875f5 | 2017-03-01 15:33:23 -0500 | [diff] [blame] | 24 | |
| 25 | void reset(); |
mtklein | 1da01c1 | 2016-08-17 10:20:27 -0700 | [diff] [blame] | 26 | bool empty() const { return fUsed == 0; } |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 27 | |
reed | 6ae6969 | 2016-09-02 04:56:53 -0700 | [diff] [blame] | 28 | #ifdef SK_SUPPORT_LEGACY_DRAWFILTER |
| 29 | void setDrawFilter(SkDrawFilter*); |
| 30 | #endif |
| 31 | |
Mike Klein | 7cc49d6 | 2017-08-14 10:39:28 -0400 | [diff] [blame] | 32 | void flush(); |
| 33 | |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 34 | void save(); |
Mike Klein | b34ab04 | 2017-05-01 21:34:14 +0000 | [diff] [blame] | 35 | void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, const SkImage*, |
Florin Malita | 53f77bd | 2017-04-28 13:48:37 -0400 | [diff] [blame] | 36 | const SkMatrix*, SkCanvas::SaveLayerFlags); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 37 | void restore(); |
| 38 | |
| 39 | void concat (const SkMatrix&); |
| 40 | void setMatrix (const SkMatrix&); |
mtklein | cbdf007 | 2016-08-19 09:05:27 -0700 | [diff] [blame] | 41 | void translate(SkScalar, SkScalar); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 42 | void translateZ(SkScalar); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 43 | |
Mike Reed | c1f7774 | 2016-12-09 09:00:50 -0500 | [diff] [blame] | 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); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 48 | |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 49 | void drawPaint (const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 50 | void drawPath (const SkPath&, const SkPaint&); |
| 51 | void drawRect (const SkRect&, const SkPaint&); |
msarett | 44df651 | 2016-08-25 13:54:30 -0700 | [diff] [blame] | 52 | void drawRegion(const SkRegion&, const SkPaint&); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 53 | void drawOval (const SkRect&, const SkPaint&); |
bsalomon | ac3aa24 | 2016-08-19 11:25:19 -0700 | [diff] [blame] | 54 | void drawArc (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 55 | void drawRRect (const SkRRect&, const SkPaint&); |
| 56 | void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 57 | |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 58 | void drawAnnotation (const SkRect&, const char*, SkData*); |
| 59 | void drawDrawable (SkDrawable*, const SkMatrix*); |
| 60 | void drawPicture (const SkPicture*, const SkMatrix*, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 61 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 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&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 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&); |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 67 | void drawTextBlob (const SkTextBlob*, SkScalar,SkScalar, const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 68 | |
Mike Klein | b25c352 | 2016-10-03 11:02:53 -0400 | [diff] [blame] | 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*, |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 72 | SkCanvas::SrcRectConstraint); |
Mike Klein | b25c352 | 2016-10-03 11:02:53 -0400 | [diff] [blame] | 73 | void drawImageLattice(sk_sp<const SkImage>, const SkCanvas::Lattice&, |
| 74 | const SkRect&, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 75 | |
| 76 | void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], |
Mike Reed | faba371 | 2016-11-03 14:45:31 -0400 | [diff] [blame] | 77 | SkBlendMode, const SkPaint&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 78 | void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&); |
Mike Reed | e88a1cb | 2017-03-17 09:50:46 -0400 | [diff] [blame] | 79 | void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 80 | void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, |
Mike Reed | faba371 | 2016-11-03 14:45:31 -0400 | [diff] [blame] | 81 | SkBlendMode, const SkRect*, const SkPaint*); |
Mike Reed | 4204da2 | 2017-05-17 08:53:36 -0400 | [diff] [blame] | 82 | void drawShadowRec(const SkPath&, const SkDrawShadowRec&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 83 | |
| 84 | private: |
mtklein | b202833 | 2016-08-09 15:13:18 -0700 | [diff] [blame] | 85 | template <typename T, typename... Args> |
| 86 | void* push(size_t, Args&&...); |
| 87 | |
mtklein | 6480619 | 2016-08-16 17:18:27 -0700 | [diff] [blame] | 88 | template <typename Fn, typename... Args> |
Mike Klein | da90109 | 2017-04-11 11:32:33 -0400 | [diff] [blame] | 89 | void map(const Fn[], Args...) const; |
mtklein | b202833 | 2016-08-09 15:13:18 -0700 | [diff] [blame] | 90 | |
| 91 | SkAutoTMalloc<uint8_t> fBytes; |
Derek Sollenberger | d7875f5 | 2017-03-01 15:33:23 -0500 | [diff] [blame] | 92 | size_t fUsed = 0; |
| 93 | size_t fReserved = 0; |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | #endif//SkLiteDL_DEFINED |