blob: 6d63657084a9b6f28c77254bb196ff4a5add6386 [file] [log] [blame]
mtklein9c5052f2016-08-06 12:51:51 -07001/*
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 Malitaab244f02017-05-03 19:16:58 +000017#include "SkTemplates.h"
mtklein9c5052f2016-08-06 12:51:51 -070018
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050019class SkLiteDL final {
mtklein9c5052f2016-08-06 12:51:51 -070020public:
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050021 ~SkLiteDL();
mtklein0c753e52016-08-09 07:40:23 -070022
Mike Kleinda901092017-04-11 11:32:33 -040023 void draw(SkCanvas* canvas) const;
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050024
25 void reset();
mtklein1da01c12016-08-17 10:20:27 -070026 bool empty() const { return fUsed == 0; }
mtkleinec559592016-08-06 20:31:30 -070027
reed6ae69692016-09-02 04:56:53 -070028#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
29 void setDrawFilter(SkDrawFilter*);
30#endif
31
Mike Klein7cc49d62017-08-14 10:39:28 -040032 void flush();
33
mtklein9c5052f2016-08-06 12:51:51 -070034 void save();
Mike Kleinb34ab042017-05-01 21:34:14 +000035 void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, const SkImage*,
Florin Malita53f77bd2017-04-28 13:48:37 -040036 const SkMatrix*, SkCanvas::SaveLayerFlags);
mtklein9c5052f2016-08-06 12:51:51 -070037 void restore();
38
39 void concat (const SkMatrix&);
40 void setMatrix (const SkMatrix&);
mtkleincbdf0072016-08-19 09:05:27 -070041 void translate(SkScalar, SkScalar);
mtklein29de8d92016-08-07 11:35:08 -070042 void translateZ(SkScalar);
mtklein9c5052f2016-08-06 12:51:51 -070043
Mike Reedc1f77742016-12-09 09:00:50 -050044 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);
mtklein9c5052f2016-08-06 12:51:51 -070048
mtklein6f8411d2016-08-06 15:28:11 -070049 void drawPaint (const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070050 void drawPath (const SkPath&, const SkPaint&);
51 void drawRect (const SkRect&, const SkPaint&);
msarett44df6512016-08-25 13:54:30 -070052 void drawRegion(const SkRegion&, const SkPaint&);
mtklein6f8411d2016-08-06 15:28:11 -070053 void drawOval (const SkRect&, const SkPaint&);
bsalomonac3aa242016-08-19 11:25:19 -070054 void drawArc (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&);
mtklein6f8411d2016-08-06 15:28:11 -070055 void drawRRect (const SkRRect&, const SkPaint&);
56 void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070057
mtklein29de8d92016-08-07 11:35:08 -070058 void drawAnnotation (const SkRect&, const char*, SkData*);
59 void drawDrawable (SkDrawable*, const SkMatrix*);
60 void drawPicture (const SkPicture*, const SkMatrix*, const SkPaint*);
mtklein9c5052f2016-08-06 12:51:51 -070061
mtkleinec559592016-08-06 20:31:30 -070062 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&);
mtklein29de8d92016-08-07 11:35:08 -070065 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&);
mtkleinec559592016-08-06 20:31:30 -070067 void drawTextBlob (const SkTextBlob*, SkScalar,SkScalar, const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070068
Mike Kleinb25c3522016-10-03 11:02:53 -040069 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*,
mtkleinec559592016-08-06 20:31:30 -070072 SkCanvas::SrcRectConstraint);
Mike Kleinb25c3522016-10-03 11:02:53 -040073 void drawImageLattice(sk_sp<const SkImage>, const SkCanvas::Lattice&,
74 const SkRect&, const SkPaint*);
mtklein9c5052f2016-08-06 12:51:51 -070075
76 void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4],
Mike Reedfaba3712016-11-03 14:45:31 -040077 SkBlendMode, const SkPaint&);
mtklein29de8d92016-08-07 11:35:08 -070078 void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&);
Mike Reede88a1cb2017-03-17 09:50:46 -040079 void drawVertices(const SkVertices*, SkBlendMode, const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070080 void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
Mike Reedfaba3712016-11-03 14:45:31 -040081 SkBlendMode, const SkRect*, const SkPaint*);
Mike Reed4204da22017-05-17 08:53:36 -040082 void drawShadowRec(const SkPath&, const SkDrawShadowRec&);
mtklein9c5052f2016-08-06 12:51:51 -070083
84private:
mtkleinb2028332016-08-09 15:13:18 -070085 template <typename T, typename... Args>
86 void* push(size_t, Args&&...);
87
mtklein64806192016-08-16 17:18:27 -070088 template <typename Fn, typename... Args>
Mike Kleinda901092017-04-11 11:32:33 -040089 void map(const Fn[], Args...) const;
mtkleinb2028332016-08-09 15:13:18 -070090
91 SkAutoTMalloc<uint8_t> fBytes;
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050092 size_t fUsed = 0;
93 size_t fReserved = 0;
mtklein9c5052f2016-08-06 12:51:51 -070094};
95
96#endif//SkLiteDL_DEFINED