blob: bd41ff3913ba56f0de7e236e8ed29502b056066c [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#include "SkLiteDL.h"
9#include "SkLiteRecorder.h"
10#include "SkSurface.h"
11
12SkLiteRecorder::SkLiteRecorder()
Florin Malita439ace92016-12-02 12:05:41 -050013 : INHERITED(1, 1)
mtklein9c5052f2016-08-06 12:51:51 -070014 , fDL(nullptr) {}
15
Derek Sollenbergerd7875f52017-03-01 15:33:23 -050016void SkLiteRecorder::reset(SkLiteDL* dl, const SkIRect& bounds) {
Adrienne Walker6a280a52017-05-01 13:45:01 -070017 this->resetCanvas(bounds.right(), bounds.bottom());
mtklein9c5052f2016-08-06 12:51:51 -070018 fDL = dl;
19}
20
21sk_sp<SkSurface> SkLiteRecorder::onNewSurface(const SkImageInfo&, const SkSurfaceProps&) {
22 return nullptr;
23}
24
reed6ae69692016-09-02 04:56:53 -070025#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
26SkDrawFilter* SkLiteRecorder::setDrawFilter(SkDrawFilter* df) {
27 fDL->setDrawFilter(df);
Florin Malita439ace92016-12-02 12:05:41 -050028 return this->INHERITED::setDrawFilter(df);
reed6ae69692016-09-02 04:56:53 -070029}
30#endif
31
Mike Klein7cc49d62017-08-14 10:39:28 -040032void SkLiteRecorder::onFlush() { fDL->flush(); }
33
mtklein9c5052f2016-08-06 12:51:51 -070034void SkLiteRecorder::willSave() { fDL->save(); }
35SkCanvas::SaveLayerStrategy SkLiteRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
Florin Malita53f77bd2017-04-28 13:48:37 -040036 fDL->saveLayer(rec.fBounds, rec.fPaint, rec.fBackdrop, rec.fClipMask, rec.fClipMatrix,
37 rec.fSaveLayerFlags);
mtklein9c5052f2016-08-06 12:51:51 -070038 return SkCanvas::kNoLayer_SaveLayerStrategy;
39}
40void SkLiteRecorder::willRestore() { fDL->restore(); }
41
mtkleincbdf0072016-08-19 09:05:27 -070042void SkLiteRecorder::didConcat (const SkMatrix& matrix) { fDL-> concat(matrix); }
43void SkLiteRecorder::didSetMatrix(const SkMatrix& matrix) { fDL->setMatrix(matrix); }
44void SkLiteRecorder::didTranslate(SkScalar dx, SkScalar dy) { fDL->translate(dx, dy); }
mtklein9c5052f2016-08-06 12:51:51 -070045
Mike Reedc1f77742016-12-09 09:00:50 -050046void SkLiteRecorder::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle style) {
mtklein9c5052f2016-08-06 12:51:51 -070047 fDL->clipRect(rect, op, style==kSoft_ClipEdgeStyle);
Florin Malita439ace92016-12-02 12:05:41 -050048 this->INHERITED::onClipRect(rect, op, style);
mtklein9c5052f2016-08-06 12:51:51 -070049}
Mike Reedc1f77742016-12-09 09:00:50 -050050void SkLiteRecorder::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle style) {
mtklein9c5052f2016-08-06 12:51:51 -070051 fDL->clipRRect(rrect, op, style==kSoft_ClipEdgeStyle);
Florin Malita439ace92016-12-02 12:05:41 -050052 this->INHERITED::onClipRRect(rrect, op, style);
mtklein9c5052f2016-08-06 12:51:51 -070053}
Mike Reedc1f77742016-12-09 09:00:50 -050054void SkLiteRecorder::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle style) {
mtklein9c5052f2016-08-06 12:51:51 -070055 fDL->clipPath(path, op, style==kSoft_ClipEdgeStyle);
Florin Malita439ace92016-12-02 12:05:41 -050056 this->INHERITED::onClipPath(path, op, style);
mtklein9c5052f2016-08-06 12:51:51 -070057}
Mike Reedc1f77742016-12-09 09:00:50 -050058void SkLiteRecorder::onClipRegion(const SkRegion& region, SkClipOp op) {
mtklein9c5052f2016-08-06 12:51:51 -070059 fDL->clipRegion(region, op);
Florin Malita439ace92016-12-02 12:05:41 -050060 this->INHERITED::onClipRegion(region, op);
mtklein9c5052f2016-08-06 12:51:51 -070061}
62
63void SkLiteRecorder::onDrawPaint(const SkPaint& paint) {
64 fDL->drawPaint(paint);
65}
66void SkLiteRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
67 fDL->drawPath(path, paint);
68}
69void SkLiteRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) {
70 fDL->drawRect(rect, paint);
71}
msarett44df6512016-08-25 13:54:30 -070072void SkLiteRecorder::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
73 fDL->drawRegion(region, paint);
74}
bsalomonac3aa242016-08-19 11:25:19 -070075void SkLiteRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
mtklein9c5052f2016-08-06 12:51:51 -070076 fDL->drawOval(oval, paint);
77}
bsalomonac3aa242016-08-19 11:25:19 -070078void SkLiteRecorder::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
79 bool useCenter, const SkPaint& paint) {
80 fDL->drawArc(oval, startAngle, sweepAngle, useCenter, paint);
81}
mtklein9c5052f2016-08-06 12:51:51 -070082void SkLiteRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
83 fDL->drawRRect(rrect, paint);
84}
85void SkLiteRecorder::onDrawDRRect(const SkRRect& out, const SkRRect& in, const SkPaint& paint) {
86 fDL->drawDRRect(out, in, paint);
87}
88
89void SkLiteRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
90 fDL->drawDrawable(drawable, matrix);
91}
92void SkLiteRecorder::onDrawPicture(const SkPicture* picture,
93 const SkMatrix* matrix,
94 const SkPaint* paint) {
95 fDL->drawPicture(picture, matrix, paint);
96}
97void SkLiteRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* val) {
98 fDL->drawAnnotation(rect, key, val);
99}
100
101void SkLiteRecorder::onDrawText(const void* text, size_t bytes,
102 SkScalar x, SkScalar y,
103 const SkPaint& paint) {
104 fDL->drawText(text, bytes, x, y, paint);
105}
106void SkLiteRecorder::onDrawPosText(const void* text, size_t bytes,
107 const SkPoint pos[],
108 const SkPaint& paint) {
109 fDL->drawPosText(text, bytes, pos, paint);
110}
111void SkLiteRecorder::onDrawPosTextH(const void* text, size_t bytes,
112 const SkScalar xs[], SkScalar y,
113 const SkPaint& paint) {
114 fDL->drawPosTextH(text, bytes, xs, y, paint);
115}
116void SkLiteRecorder::onDrawTextOnPath(const void* text, size_t bytes,
117 const SkPath& path, const SkMatrix* matrix,
118 const SkPaint& paint) {
119 fDL->drawTextOnPath(text, bytes, path, matrix, paint);
120}
121void SkLiteRecorder::onDrawTextRSXform(const void* text, size_t bytes,
122 const SkRSXform xform[], const SkRect* cull,
123 const SkPaint& paint) {
mtklein29de8d92016-08-07 11:35:08 -0700124 fDL->drawTextRSXform(text, bytes, xform, cull, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700125}
126void SkLiteRecorder::onDrawTextBlob(const SkTextBlob* blob,
127 SkScalar x, SkScalar y,
128 const SkPaint& paint) {
129 fDL->drawTextBlob(blob, x,y, paint);
130}
131
132void SkLiteRecorder::onDrawBitmap(const SkBitmap& bm,
133 SkScalar x, SkScalar y,
134 const SkPaint* paint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400135 fDL->drawImage(SkImage::MakeFromBitmap(bm), x,y, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700136}
137void SkLiteRecorder::onDrawBitmapNine(const SkBitmap& bm,
138 const SkIRect& center, const SkRect& dst,
139 const SkPaint* paint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400140 fDL->drawImageNine(SkImage::MakeFromBitmap(bm), center, dst, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700141}
142void SkLiteRecorder::onDrawBitmapRect(const SkBitmap& bm,
143 const SkRect* src, const SkRect& dst,
144 const SkPaint* paint, SrcRectConstraint constraint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400145 fDL->drawImageRect(SkImage::MakeFromBitmap(bm), src, dst, paint, constraint);
mtklein9c5052f2016-08-06 12:51:51 -0700146}
msarett16882062016-08-16 09:31:08 -0700147void SkLiteRecorder::onDrawBitmapLattice(const SkBitmap& bm,
148 const SkCanvas::Lattice& lattice, const SkRect& dst,
149 const SkPaint* paint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400150 fDL->drawImageLattice(SkImage::MakeFromBitmap(bm), lattice, dst, paint);
msarett16882062016-08-16 09:31:08 -0700151}
mtklein9c5052f2016-08-06 12:51:51 -0700152
153void SkLiteRecorder::onDrawImage(const SkImage* img,
154 SkScalar x, SkScalar y,
155 const SkPaint* paint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400156 fDL->drawImage(sk_ref_sp(img), x,y, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700157}
158void SkLiteRecorder::onDrawImageNine(const SkImage* img,
159 const SkIRect& center, const SkRect& dst,
160 const SkPaint* paint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400161 fDL->drawImageNine(sk_ref_sp(img), center, dst, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700162}
163void SkLiteRecorder::onDrawImageRect(const SkImage* img,
164 const SkRect* src, const SkRect& dst,
165 const SkPaint* paint, SrcRectConstraint constraint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400166 fDL->drawImageRect(sk_ref_sp(img), src, dst, paint, constraint);
mtklein9c5052f2016-08-06 12:51:51 -0700167}
168void SkLiteRecorder::onDrawImageLattice(const SkImage* img,
169 const SkCanvas::Lattice& lattice, const SkRect& dst,
170 const SkPaint* paint) {
Mike Kleinb25c3522016-10-03 11:02:53 -0400171 fDL->drawImageLattice(sk_ref_sp(img), lattice, dst, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700172}
173
174
175void SkLiteRecorder::onDrawPatch(const SkPoint cubics[12],
176 const SkColor colors[4], const SkPoint texCoords[4],
Mike Reedfaba3712016-11-03 14:45:31 -0400177 SkBlendMode bmode, const SkPaint& paint) {
178 fDL->drawPatch(cubics, colors, texCoords, bmode, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700179}
180void SkLiteRecorder::onDrawPoints(SkCanvas::PointMode mode,
181 size_t count, const SkPoint pts[],
182 const SkPaint& paint) {
183 fDL->drawPoints(mode, count, pts, paint);
184}
Mike Reede88a1cb2017-03-17 09:50:46 -0400185void SkLiteRecorder::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
186 const SkPaint& paint) {
187 fDL->drawVertices(vertices, mode, paint);
188}
mtklein9c5052f2016-08-06 12:51:51 -0700189void SkLiteRecorder::onDrawAtlas(const SkImage* atlas,
190 const SkRSXform xforms[],
191 const SkRect texs[],
192 const SkColor colors[],
193 int count,
Mike Reedfaba3712016-11-03 14:45:31 -0400194 SkBlendMode bmode,
mtklein9c5052f2016-08-06 12:51:51 -0700195 const SkRect* cull,
196 const SkPaint* paint) {
Mike Reedfaba3712016-11-03 14:45:31 -0400197 fDL->drawAtlas(atlas, xforms, texs, colors, count, bmode, cull, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700198}
Mike Reed4204da22017-05-17 08:53:36 -0400199void SkLiteRecorder::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
200 fDL->drawShadowRec(path, rec);
201}