blob: 00441fdf84044c90f3427a849c8e96d8d3f03d9a [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
25void SkLiteRecorder::willSave() { fDL->save(); }
26SkCanvas::SaveLayerStrategy SkLiteRecorder::getSaveLayerStrategy(const SaveLayerRec& rec) {
27 fDL->saveLayer(rec.fBounds, rec.fPaint, rec.fBackdrop, rec.fSaveLayerFlags);
28 return SkCanvas::kNoLayer_SaveLayerStrategy;
29}
30void SkLiteRecorder::willRestore() { fDL->restore(); }
31
32void SkLiteRecorder::didConcat (const SkMatrix& matrix) { fDL-> concat(matrix); }
33void SkLiteRecorder::didSetMatrix(const SkMatrix& matrix) { fDL->setMatrix(matrix); }
34
35void SkLiteRecorder::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle style) {
36 fDL->clipRect(rect, op, style==kSoft_ClipEdgeStyle);
37 SkCanvas::onClipRect(rect, op, style);
38}
39void SkLiteRecorder::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle style) {
40 fDL->clipRRect(rrect, op, style==kSoft_ClipEdgeStyle);
41 SkCanvas::onClipRRect(rrect, op, style);
42}
43void SkLiteRecorder::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle style) {
44 fDL->clipPath(path, op, style==kSoft_ClipEdgeStyle);
45 SkCanvas::onClipPath(path, op, style);
46}
47void SkLiteRecorder::onClipRegion(const SkRegion& region, SkRegion::Op op) {
48 fDL->clipRegion(region, op);
49 SkCanvas::onClipRegion(region, op);
50}
51
52void SkLiteRecorder::onDrawPaint(const SkPaint& paint) {
53 fDL->drawPaint(paint);
54}
55void SkLiteRecorder::onDrawPath(const SkPath& path, const SkPaint& paint) {
56 fDL->drawPath(path, paint);
57}
58void SkLiteRecorder::onDrawRect(const SkRect& rect, const SkPaint& paint) {
59 fDL->drawRect(rect, paint);
60}
61void SkLiteRecorder::onDrawOval(const SkRect& oval, const SkPaint& paint) {
62 fDL->drawOval(oval, paint);
63}
64void SkLiteRecorder::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
65 fDL->drawRRect(rrect, paint);
66}
67void SkLiteRecorder::onDrawDRRect(const SkRRect& out, const SkRRect& in, const SkPaint& paint) {
68 fDL->drawDRRect(out, in, paint);
69}
70
71void SkLiteRecorder::onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix) {
72 fDL->drawDrawable(drawable, matrix);
73}
74void SkLiteRecorder::onDrawPicture(const SkPicture* picture,
75 const SkMatrix* matrix,
76 const SkPaint* paint) {
77 fDL->drawPicture(picture, matrix, paint);
78}
79void SkLiteRecorder::onDrawAnnotation(const SkRect& rect, const char key[], SkData* val) {
80 fDL->drawAnnotation(rect, key, val);
81}
82
83void SkLiteRecorder::onDrawText(const void* text, size_t bytes,
84 SkScalar x, SkScalar y,
85 const SkPaint& paint) {
86 fDL->drawText(text, bytes, x, y, paint);
87}
88void SkLiteRecorder::onDrawPosText(const void* text, size_t bytes,
89 const SkPoint pos[],
90 const SkPaint& paint) {
91 fDL->drawPosText(text, bytes, pos, paint);
92}
93void SkLiteRecorder::onDrawPosTextH(const void* text, size_t bytes,
94 const SkScalar xs[], SkScalar y,
95 const SkPaint& paint) {
96 fDL->drawPosTextH(text, bytes, xs, y, paint);
97}
98void SkLiteRecorder::onDrawTextOnPath(const void* text, size_t bytes,
99 const SkPath& path, const SkMatrix* matrix,
100 const SkPaint& paint) {
101 fDL->drawTextOnPath(text, bytes, path, matrix, paint);
102}
103void SkLiteRecorder::onDrawTextRSXform(const void* text, size_t bytes,
104 const SkRSXform xform[], const SkRect* cull,
105 const SkPaint& paint) {
106 fDL->drawTextRSXForm(text, bytes, xform, cull, paint);
107}
108void SkLiteRecorder::onDrawTextBlob(const SkTextBlob* blob,
109 SkScalar x, SkScalar y,
110 const SkPaint& paint) {
111 fDL->drawTextBlob(blob, x,y, paint);
112}
113
114void SkLiteRecorder::onDrawBitmap(const SkBitmap& bm,
115 SkScalar x, SkScalar y,
116 const SkPaint* paint) {
117 fDL->drawBitmap(bm, x,y, paint);
118}
119void SkLiteRecorder::onDrawBitmapNine(const SkBitmap& bm,
120 const SkIRect& center, const SkRect& dst,
121 const SkPaint* paint) {
122 fDL->drawBitmapNine(bm, center, dst, paint);
123}
124void SkLiteRecorder::onDrawBitmapRect(const SkBitmap& bm,
125 const SkRect* src, const SkRect& dst,
126 const SkPaint* paint, SrcRectConstraint constraint) {
127 fDL->drawBitmapRect(bm, src, dst, paint, constraint == kStrict_SrcRectConstraint);
128}
129
130void SkLiteRecorder::onDrawImage(const SkImage* img,
131 SkScalar x, SkScalar y,
132 const SkPaint* paint) {
133 fDL->drawImage(img, x,y, paint);
134}
135void SkLiteRecorder::onDrawImageNine(const SkImage* img,
136 const SkIRect& center, const SkRect& dst,
137 const SkPaint* paint) {
138 fDL->drawImageNine(img, center, dst, paint);
139}
140void SkLiteRecorder::onDrawImageRect(const SkImage* img,
141 const SkRect* src, const SkRect& dst,
142 const SkPaint* paint, SrcRectConstraint constraint) {
143 fDL->drawImageRect(img, src, dst, paint, constraint == kStrict_SrcRectConstraint);
144}
145void SkLiteRecorder::onDrawImageLattice(const SkImage* img,
146 const SkCanvas::Lattice& lattice, const SkRect& dst,
147 const SkPaint* paint) {
148 fDL->drawImageLattice(img, lattice, dst, paint);
149}
150
151
152void SkLiteRecorder::onDrawPatch(const SkPoint cubics[12],
153 const SkColor colors[4], const SkPoint texCoords[4],
154 SkXfermode* xfermode, const SkPaint& paint) {
155 fDL->drawPatch(cubics, colors, texCoords, xfermode, paint);
156}
157void SkLiteRecorder::onDrawPoints(SkCanvas::PointMode mode,
158 size_t count, const SkPoint pts[],
159 const SkPaint& paint) {
160 fDL->drawPoints(mode, count, pts, paint);
161}
162void SkLiteRecorder::onDrawVertices(SkCanvas::VertexMode mode,
163 int count, const SkPoint vertices[],
164 const SkPoint texs[], const SkColor colors[],
165 SkXfermode* xfermode,
166 const uint16_t indices[], int indexCount,
167 const SkPaint& paint) {
168 fDL->drawVertices(mode, count, vertices, texs, colors, xfermode, indices, indexCount, paint);
169}
170void SkLiteRecorder::onDrawAtlas(const SkImage* atlas,
171 const SkRSXform xforms[],
172 const SkRect texs[],
173 const SkColor colors[],
174 int count,
175 SkXfermode::Mode xfermode,
176 const SkRect* cull,
177 const SkPaint* paint) {
178 fDL->drawAtlas(atlas, xforms, texs, colors, count, xfermode, cull, paint);
179}
180
181void SkLiteRecorder::didTranslateZ(SkScalar dz) {
182 fDL->translateZ(dz);
183}
184void SkLiteRecorder::onDrawShadowedPicture(const SkPicture* picture,
185 const SkMatrix* matrix,
186 const SkPaint* paint) {
187 fDL->drawShadowedPicture(picture, matrix, paint);
188}