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 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 18 | class GrContext; |
| 19 | |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 20 | class SkLiteDL final : public SkDrawable { |
| 21 | public: |
| 22 | static sk_sp<SkLiteDL> New(SkRect); |
| 23 | |
mtklein | 0c753e5 | 2016-08-09 07:40:23 -0700 | [diff] [blame^] | 24 | static void PurgeFreelist(); |
| 25 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 26 | void optimizeFor(GrContext*); |
mtklein | 03591a7 | 2016-08-07 13:35:46 -0700 | [diff] [blame] | 27 | void makeThreadsafe(); |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 28 | |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 29 | void save(); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 30 | void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, SkCanvas::SaveLayerFlags); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 31 | void restore(); |
| 32 | |
| 33 | void concat (const SkMatrix&); |
| 34 | void setMatrix (const SkMatrix&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 35 | void translateZ(SkScalar); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 36 | |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 37 | void clipPath (const SkPath&, SkRegion::Op, bool aa); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 38 | void clipRect (const SkRect&, SkRegion::Op, bool aa); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 39 | void clipRRect (const SkRRect&, SkRegion::Op, bool aa); |
| 40 | void clipRegion(const SkRegion&, SkRegion::Op); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 41 | |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 42 | void drawPaint (const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 43 | void drawPath (const SkPath&, const SkPaint&); |
| 44 | void drawRect (const SkRect&, const SkPaint&); |
mtklein | 6f8411d | 2016-08-06 15:28:11 -0700 | [diff] [blame] | 45 | void drawOval (const SkRect&, const SkPaint&); |
| 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*); |
| 52 | void drawShadowedPicture(const SkPicture*, const SkMatrix*, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 53 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 54 | void drawText (const void*, size_t, SkScalar, SkScalar, const SkPaint&); |
| 55 | void drawPosText (const void*, size_t, const SkPoint[], const SkPaint&); |
| 56 | void drawPosTextH (const void*, size_t, const SkScalar[], SkScalar, const SkPaint&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 57 | void drawTextOnPath (const void*, size_t, const SkPath&, const SkMatrix*, const SkPaint&); |
| 58 | void drawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*, const SkPaint&); |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 59 | void drawTextBlob (const SkTextBlob*, SkScalar,SkScalar, const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 60 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 61 | void drawBitmap (const SkBitmap&, SkScalar, SkScalar, const SkPaint*); |
| 62 | void drawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&, const SkPaint*); |
| 63 | void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint*, |
| 64 | SkCanvas::SrcRectConstraint); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 65 | |
mtklein | ec55959 | 2016-08-06 20:31:30 -0700 | [diff] [blame] | 66 | void drawImage (const SkImage*, SkScalar,SkScalar, const SkPaint*); |
| 67 | void drawImageNine(const SkImage*, const SkIRect&, const SkRect&, const SkPaint*); |
| 68 | void drawImageRect(const SkImage*, const SkRect*, const SkRect&, const SkPaint*, |
| 69 | SkCanvas::SrcRectConstraint); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 70 | void drawImageLattice(const SkImage*, const SkCanvas::Lattice&, const SkRect&, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 71 | |
| 72 | void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4], |
mtklein | 03591a7 | 2016-08-07 13:35:46 -0700 | [diff] [blame] | 73 | SkXfermode*, const SkPaint&); |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 74 | void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 75 | void drawVertices(SkCanvas::VertexMode, int, const SkPoint[], const SkPoint[], const SkColor[], |
mtklein | 03591a7 | 2016-08-07 13:35:46 -0700 | [diff] [blame] | 76 | SkXfermode*, const uint16_t[], int, const SkPaint&); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 77 | void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int, |
mtklein | 29de8d9 | 2016-08-07 11:35:08 -0700 | [diff] [blame] | 78 | SkXfermode::Mode, const SkRect*, const SkPaint*); |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 79 | |
| 80 | private: |
| 81 | SkLiteDL(); |
| 82 | ~SkLiteDL(); |
| 83 | |
| 84 | void internal_dispose() const override; |
| 85 | |
| 86 | SkRect onGetBounds() override; |
| 87 | void onDraw(SkCanvas*) override; |
| 88 | |
| 89 | SkLiteDL* fNext; |
mtklein | 765b6e6 | 2016-08-08 12:23:02 -0700 | [diff] [blame] | 90 | int fUsesRemaining; |
mtklein | 9c5052f | 2016-08-06 12:51:51 -0700 | [diff] [blame] | 91 | SkRect fBounds; |
| 92 | SkTDArray<uint8_t> fBytes; |
| 93 | }; |
| 94 | |
| 95 | #endif//SkLiteDL_DEFINED |