blob: bc5ffbe0526ffc9ef59e1859aeee647ab5e4a7a2 [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()
13 : SkCanvas({0,0,1,1}, SkCanvas::kConservativeRasterClip_InitFlag)
14 , fDL(nullptr) {}
15
16void SkLiteRecorder::reset(SkLiteDL* dl) {
17 this->resetForNextPicture(dl->getBounds().roundOut());
18 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);
28 return SkCanvas::setDrawFilter(df);
29}
30#endif
31
mtklein9c5052f2016-08-06 12:51:51 -070032void SkLiteRecorder::willSave() { fDL->save(); }
33SkCanvas::SaveLayerStrategy SkLiteRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
34 fDL->saveLayer(rec.fBounds, rec.fPaint, rec.fBackdrop, rec.fSaveLayerFlags);
35 return SkCanvas::kNoLayer_SaveLayerStrategy;
36}
37void SkLiteRecorder::willRestore() { fDL->restore(); }
38
mtkleincbdf0072016-08-19 09:05:27 -070039void SkLiteRecorder::didConcat (const SkMatrix& matrix) { fDL-> concat(matrix); }
40void SkLiteRecorder::didSetMatrix(const SkMatrix& matrix) { fDL->setMatrix(matrix); }
41void SkLiteRecorder::didTranslate(SkScalar dx, SkScalar dy) { fDL->translate(dx, dy); }
mtklein9c5052f2016-08-06 12:51:51 -070042
43void SkLiteRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle style) {
44 fDL->clipRect(rect, op, style==kSoft_ClipEdgeStyle);
liyuqian91c42712016-09-12 13:00:50 -070045 SkCanvas::onClipRect(rect, op, style);
mtklein9c5052f2016-08-06 12:51:51 -070046}
47void SkLiteRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle style) {
48 fDL->clipRRect(rrect, op, style==kSoft_ClipEdgeStyle);
liyuqian91c42712016-09-12 13:00:50 -070049 SkCanvas::onClipRRect(rrect, op, style);
mtklein9c5052f2016-08-06 12:51:51 -070050}
51void SkLiteRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle style) {
52 fDL->clipPath(path, op, style==kSoft_ClipEdgeStyle);
liyuqian91c42712016-09-12 13:00:50 -070053 SkCanvas::onClipPath(path, op, style);
mtklein9c5052f2016-08-06 12:51:51 -070054}
55void SkLiteRecorder::onClipRegion(const SkRegion& region, SkRegion::Op op) {
56 fDL->clipRegion(region, op);
liyuqian91c42712016-09-12 13:00:50 -070057 SkCanvas::onClipRegion(region, op);
mtklein9c5052f2016-08-06 12:51:51 -070058}
59
60void SkLiteRecorder::onDrawPaint(const SkPaint& paint) {
61 fDL->drawPaint(paint);
62}
63void SkLiteRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
64 fDL->drawPath(path, paint);
65}
66void SkLiteRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) {
67 fDL->drawRect(rect, paint);
68}
msarett44df6512016-08-25 13:54:30 -070069void SkLiteRecorder::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
70 fDL->drawRegion(region, paint);
71}
bsalomonac3aa242016-08-19 11:25:19 -070072void SkLiteRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
mtklein9c5052f2016-08-06 12:51:51 -070073 fDL->drawOval(oval, paint);
74}
bsalomonac3aa242016-08-19 11:25:19 -070075void SkLiteRecorder::onDrawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
76 bool useCenter, const SkPaint& paint) {
77 fDL->drawArc(oval, startAngle, sweepAngle, useCenter, paint);
78}
mtklein9c5052f2016-08-06 12:51:51 -070079void SkLiteRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
80 fDL->drawRRect(rrect, paint);
81}
82void SkLiteRecorder::onDrawDRRect(const SkRRect& out, const SkRRect& in, const SkPaint& paint) {
83 fDL->drawDRRect(out, in, paint);
84}
85
86void SkLiteRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
87 fDL->drawDrawable(drawable, matrix);
88}
89void SkLiteRecorder::onDrawPicture(const SkPicture* picture,
90 const SkMatrix* matrix,
91 const SkPaint* paint) {
92 fDL->drawPicture(picture, matrix, paint);
93}
94void SkLiteRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* val) {
95 fDL->drawAnnotation(rect, key, val);
96}
97
98void SkLiteRecorder::onDrawText(const void* text, size_t bytes,
99 SkScalar x, SkScalar y,
100 const SkPaint& paint) {
101 fDL->drawText(text, bytes, x, y, paint);
102}
103void SkLiteRecorder::onDrawPosText(const void* text, size_t bytes,
104 const SkPoint pos[],
105 const SkPaint& paint) {
106 fDL->drawPosText(text, bytes, pos, paint);
107}
108void SkLiteRecorder::onDrawPosTextH(const void* text, size_t bytes,
109 const SkScalar xs[], SkScalar y,
110 const SkPaint& paint) {
111 fDL->drawPosTextH(text, bytes, xs, y, paint);
112}
113void SkLiteRecorder::onDrawTextOnPath(const void* text, size_t bytes,
114 const SkPath& path, const SkMatrix* matrix,
115 const SkPaint& paint) {
116 fDL->drawTextOnPath(text, bytes, path, matrix, paint);
117}
118void SkLiteRecorder::onDrawTextRSXform(const void* text, size_t bytes,
119 const SkRSXform xform[], const SkRect* cull,
120 const SkPaint& paint) {
mtklein29de8d92016-08-07 11:35:08 -0700121 fDL->drawTextRSXform(text, bytes, xform, cull, paint);
mtklein9c5052f2016-08-06 12:51:51 -0700122}
123void SkLiteRecorder::onDrawTextBlob(const SkTextBlob* blob,
124 SkScalar x, SkScalar y,
125 const SkPaint& paint) {
126 fDL->drawTextBlob(blob, x,y, paint);
127}
128
129void SkLiteRecorder::onDrawBitmap(const SkBitmap& bm,
130 SkScalar x, SkScalar y,
131 const SkPaint* paint) {
132 fDL->drawBitmap(bm, x,y, paint);
133}
134void SkLiteRecorder::onDrawBitmapNine(const SkBitmap& bm,
135 const SkIRect& center, const SkRect& dst,
136 const SkPaint* paint) {
137 fDL->drawBitmapNine(bm, center, dst, paint);
138}
139void SkLiteRecorder::onDrawBitmapRect(const SkBitmap& bm,
140 const SkRect* src, const SkRect& dst,
141 const SkPaint* paint, SrcRectConstraint constraint) {
mtkleinec559592016-08-06 20:31:30 -0700142 fDL->drawBitmapRect(bm, src, dst, paint, constraint);
mtklein9c5052f2016-08-06 12:51:51 -0700143}
msarett16882062016-08-16 09:31:08 -0700144void SkLiteRecorder::onDrawBitmapLattice(const SkBitmap& bm,
145 const SkCanvas::Lattice& lattice, const SkRect& dst,
146 const SkPaint* paint) {
147 fDL->drawBitmapLattice(bm, lattice, dst, paint);
148}
mtklein9c5052f2016-08-06 12:51:51 -0700149
150void SkLiteRecorder::onDrawImage(const SkImage* img,
151 SkScalar x, SkScalar y,
152 const SkPaint* paint) {
153 fDL->drawImage(img, x,y, paint);
154}
155void SkLiteRecorder::onDrawImageNine(const SkImage* img,
156 const SkIRect& center, const SkRect& dst,
157 const SkPaint* paint) {
158 fDL->drawImageNine(img, center, dst, paint);
159}
160void SkLiteRecorder::onDrawImageRect(const SkImage* img,
161 const SkRect* src, const SkRect& dst,
162 const SkPaint* paint, SrcRectConstraint constraint) {
mtkleinec559592016-08-06 20:31:30 -0700163 fDL->drawImageRect(img, src, dst, paint, constraint);
mtklein9c5052f2016-08-06 12:51:51 -0700164}
165void SkLiteRecorder::onDrawImageLattice(const SkImage* img,
166 const SkCanvas::Lattice& lattice, const SkRect& dst,
167 const SkPaint* paint) {
168 fDL->drawImageLattice(img, lattice, dst, paint);
169}
170
171
172void SkLiteRecorder::onDrawPatch(const SkPoint cubics[12],
173 const SkColor colors[4], const SkPoint texCoords[4],
174 SkXfermode* xfermode, const SkPaint& paint) {
175 fDL->drawPatch(cubics, colors, texCoords, xfermode, paint);
176}
177void SkLiteRecorder::onDrawPoints(SkCanvas::PointMode mode,
178 size_t count, const SkPoint pts[],
179 const SkPaint& paint) {
180 fDL->drawPoints(mode, count, pts, paint);
181}
182void SkLiteRecorder::onDrawVertices(SkCanvas::VertexMode mode,
183 int count, const SkPoint vertices[],
184 const SkPoint texs[], const SkColor colors[],
185 SkXfermode* xfermode,
186 const uint16_t indices[], int indexCount,
187 const SkPaint& paint) {
188 fDL->drawVertices(mode, count, vertices, texs, colors, xfermode, indices, indexCount, paint);
189}
190void SkLiteRecorder::onDrawAtlas(const SkImage* atlas,
191 const SkRSXform xforms[],
192 const SkRect texs[],
193 const SkColor colors[],
194 int count,
195 SkXfermode::Mode xfermode,
196 const SkRect* cull,
197 const SkPaint* paint) {
198 fDL->drawAtlas(atlas, xforms, texs, colors, count, xfermode, cull, paint);
199}
200
201void SkLiteRecorder::didTranslateZ(SkScalar dz) {
202 fDL->translateZ(dz);
203}
204void SkLiteRecorder::onDrawShadowedPicture(const SkPicture* picture,
205 const SkMatrix* matrix,
vjiaoblacke6f5d562016-08-25 06:30:23 -0700206 const SkPaint* paint,
207 const SkShadowParams& params) {
208 fDL->drawShadowedPicture(picture, matrix, paint, params);
mtklein9c5052f2016-08-06 12:51:51 -0700209}