blob: a6041bc2d6f74dd77160071520d3a609efc7f44c [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
Mike Klein7cc49d62017-08-14 10:39:28 -040028 void flush();
29
mtklein9c5052f2016-08-06 12:51:51 -070030 void save();
Mike Kleinb34ab042017-05-01 21:34:14 +000031 void saveLayer(const SkRect*, const SkPaint*, const SkImageFilter*, const SkImage*,
Florin Malita53f77bd2017-04-28 13:48:37 -040032 const SkMatrix*, SkCanvas::SaveLayerFlags);
Mike Reed148b7fd2018-12-18 17:38:18 -050033 void saveBehind(const SkRect*);
mtklein9c5052f2016-08-06 12:51:51 -070034 void restore();
35
36 void concat (const SkMatrix&);
37 void setMatrix (const SkMatrix&);
mtkleincbdf0072016-08-19 09:05:27 -070038 void translate(SkScalar, SkScalar);
mtklein29de8d92016-08-07 11:35:08 -070039 void translateZ(SkScalar);
mtklein9c5052f2016-08-06 12:51:51 -070040
Mike Reedc1f77742016-12-09 09:00:50 -050041 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);
mtklein9c5052f2016-08-06 12:51:51 -070045
mtklein6f8411d2016-08-06 15:28:11 -070046 void drawPaint (const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070047 void drawPath (const SkPath&, const SkPaint&);
48 void drawRect (const SkRect&, const SkPaint&);
Michael Ludwig75451902019-01-23 11:14:29 -050049 void drawEdgeAARect(const SkRect&, SkCanvas::QuadAAFlags, SkColor, SkBlendMode);
msarett44df6512016-08-25 13:54:30 -070050 void drawRegion(const SkRegion&, const SkPaint&);
mtklein6f8411d2016-08-06 15:28:11 -070051 void drawOval (const SkRect&, const SkPaint&);
bsalomonac3aa242016-08-19 11:25:19 -070052 void drawArc (const SkRect&, SkScalar, SkScalar, bool, const SkPaint&);
mtklein6f8411d2016-08-06 15:28:11 -070053 void drawRRect (const SkRRect&, const SkPaint&);
54 void drawDRRect(const SkRRect&, const SkRRect&, const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070055
mtklein29de8d92016-08-07 11:35:08 -070056 void drawAnnotation (const SkRect&, const char*, SkData*);
57 void drawDrawable (SkDrawable*, const SkMatrix*);
58 void drawPicture (const SkPicture*, const SkMatrix*, const SkPaint*);
mtklein9c5052f2016-08-06 12:51:51 -070059
mtkleinec559592016-08-06 20:31:30 -070060 void drawTextBlob (const SkTextBlob*, SkScalar,SkScalar, const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070061
Mike Kleinb25c3522016-10-03 11:02:53 -040062 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*,
mtkleinec559592016-08-06 20:31:30 -070065 SkCanvas::SrcRectConstraint);
Mike Kleinb25c3522016-10-03 11:02:53 -040066 void drawImageLattice(sk_sp<const SkImage>, const SkCanvas::Lattice&,
67 const SkRect&, const SkPaint*);
Brian Salomond003d222018-11-26 13:25:05 -050068 void drawImageSet(const SkCanvas::ImageSetEntry[], int count, SkFilterQuality, SkBlendMode);
mtklein9c5052f2016-08-06 12:51:51 -070069
70 void drawPatch(const SkPoint[12], const SkColor[4], const SkPoint[4],
Mike Reedfaba3712016-11-03 14:45:31 -040071 SkBlendMode, const SkPaint&);
mtklein29de8d92016-08-07 11:35:08 -070072 void drawPoints(SkCanvas::PointMode, size_t, const SkPoint[], const SkPaint&);
Ruiqi Maoc97a3392018-08-15 10:44:19 -040073 void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode,
Ruiqi Maof5101492018-06-29 14:32:21 -040074 const SkPaint&);
mtklein9c5052f2016-08-06 12:51:51 -070075 void drawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
Mike Reedfaba3712016-11-03 14:45:31 -040076 SkBlendMode, const SkRect*, const SkPaint*);
Mike Reed4204da22017-05-17 08:53:36 -040077 void drawShadowRec(const SkPath&, const SkDrawShadowRec&);
mtklein9c5052f2016-08-06 12:51:51 -070078
79private:
mtkleinb2028332016-08-09 15:13:18 -070080 template <typename T, typename... Args>
81 void* push(size_t, Args&&...);
82
mtklein64806192016-08-16 17:18:27 -070083 template <typename Fn, typename... Args>
Mike Kleinda901092017-04-11 11:32:33 -040084 void map(const Fn[], Args...) const;
mtkleinb2028332016-08-09 15:13:18 -070085
86 SkAutoTMalloc<uint8_t> fBytes;
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050087 size_t fUsed = 0;
88 size_t fReserved = 0;
mtklein9c5052f2016-08-06 12:51:51 -070089};
90
91#endif//SkLiteDL_DEFINED