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" |
| 17 | |
| 18 | class SkLiteDL final : public SkDrawable { |
| 19 | public: |
| 20 | static sk_sp<SkLiteDL> New(SkRect); |
mtklein | 883c8ef | 2016-08-16 09:36:18 -0700 | [diff] [blame] | 21 | void reset(SkRect); |
mtklein | 0c753e5 | 2016-08-09 07:40:23 -0700 | [diff] [blame] | 22 | |
mtklein | 03591a7 | 2016-08-07 13:35:46 -0700 | [diff] [blame] | 23 | void makeThreadsafe(); |
mtklein | 1da01c1 | 2016-08-17 10:20:27 -0700 | [diff] [blame] | 24 | bool empty() const { return fUsed == 0; } |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 25 | |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 26 | void save(); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 27 | void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, SkCanvas::SaveLayerFlags); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 28 | void restore(); |
| 29 | |
| 30 | void concat (const SkMatrix&); |
| 31 | void setMatrix (const SkMatrix&); |
mtklein | cbdf007 | 2016-08-19 09:05:27 -0700 | [diff] [blame] | 32 | void translate(SkScalar, SkScalar); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 33 | void translateZ(SkScalar); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 34 | |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 35 | void clipPath (const SkPath&, SkRegion::Op, bool aa); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 36 | void clipRect (const SkRect&, SkRegion::Op, bool aa); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 37 | void clipRRect (const SkRRect&, SkRegion::Op, bool aa); |
| 38 | void clipRegion(const SkRegion&, SkRegion::Op); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 39 | |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 40 | void drawPaint (const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 41 | void drawPath (const SkPath&, const SkPaint&); |
| 42 | void drawRect (const SkRect&, const SkPaint&); |
msarett | 44df651 | 2016-08-25 13:54:30 -0700 | [diff] [blame^] | 43 | void drawRegion(const SkRegion&, const SkPaint&); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 44 | void drawOval (const SkRect&, const SkPaint&); |
bsalomon | ac3aa24 | 2016-08-19 11:25:19 -0700 | [diff] [blame] | 45 | void drawArc (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 46 | void drawRRect (const SkRRect&, const SkPaint&); |
| 47 | void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 48 | |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 49 | void drawAnnotation (const SkRect&, const char*, SkData*); |
| 50 | void drawDrawable (SkDrawable*, const SkMatrix*); |
| 51 | void drawPicture (const SkPicture*, const SkMatrix*, const SkPaint*); |
vjiaoblack | e6f5d56 | 2016-08-25 06:30:23 -0700 | [diff] [blame] | 52 | void drawShadowedPicture(const SkPicture*, const SkMatrix*, |
| 53 | const SkPaint*, const SkShadowParams& params); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 54 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 55 | void drawText (const void*, size_t, SkScalar, SkScalar, const SkPaint&); |
| 56 | void drawPosText (const void*, size_t, const SkPoint[], const SkPaint&); |
| 57 | void drawPosTextH (const void*, size_t, const SkScalar[], SkScalar, const SkPaint&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 58 | void drawTextOnPath (const void*, size_t, const SkPath&, const SkMatrix*, const SkPaint&); |
| 59 | void drawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*, const SkPaint&); |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 60 | void drawTextBlob (const SkTextBlob*, SkScalar,SkScalar, 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 drawBitmap (const SkBitmap&, SkScalar, SkScalar, const SkPaint*); |
| 63 | void drawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, const SkPaint*); |
| 64 | void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, |
| 65 | SkCanvas::SrcRectConstraint); |
msarett | 1688206 | 2016-08-16 09:31:08 -0700 | [diff] [blame] | 66 | void drawBitmapLattice(const SkBitmap&, const SkCanvas::Lattice&, const SkRect&, |
| 67 | const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 68 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 69 | void drawImage (const SkImage*, SkScalar,SkScalar, const SkPaint*); |
| 70 | void drawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*); |
| 71 | void drawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*, |
| 72 | SkCanvas::SrcRectConstraint); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 73 | void drawImageLattice(const SkImage*, const SkCanvas::Lattice&, const SkRect&, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 74 | |
| 75 | void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], |
mtklein | 03591a7 | 2016-08-07 13:35:46 -0700 | [diff] [blame] | 76 | SkXfermode*, const SkPaint&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 77 | void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 78 | void drawVertices(SkCanvas::VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[], |
mtklein | 03591a7 | 2016-08-07 13:35:46 -0700 | [diff] [blame] | 79 | SkXfermode*, const uint16_t[], int, 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, |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 81 | SkXfermode::Mode, const SkRect*, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 82 | |
| 83 | private: |
mtklein | 883c8ef | 2016-08-16 09:36:18 -0700 | [diff] [blame] | 84 | SkLiteDL(SkRect); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 85 | ~SkLiteDL(); |
| 86 | |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 87 | SkRect onGetBounds() override; |
| 88 | void onDraw(SkCanvas*) override; |
| 89 | |
mtklein | b202833 | 2016-08-09 15:13:18 -0700 | [diff] [blame] | 90 | template <typename T, typename... Args> |
| 91 | void* push(size_t, Args&&...); |
| 92 | |
mtklein | 6480619 | 2016-08-16 17:18:27 -0700 | [diff] [blame] | 93 | template <typename Fn, typename... Args> |
| 94 | void map(const Fn[], Args...); |
mtklein | b202833 | 2016-08-09 15:13:18 -0700 | [diff] [blame] | 95 | |
| 96 | SkAutoTMalloc<uint8_t> fBytes; |
| 97 | size_t fUsed; |
| 98 | size_t fReserved; |
| 99 | SkRect fBounds; |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | #endif//SkLiteDL_DEFINED |