1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkNWayCanvas.h"
SkNWayCanvas::SkNWayCanvas(int width, int height)
: INHERITED(width, height) {}
SkNWayCanvas::~SkNWayCanvas() {
this->removeAll();
}
void SkNWayCanvas::addCanvas(SkCanvas* canvas) {
if (canvas) {
canvas->ref();
*fList.append() = canvas;
}
}
void SkNWayCanvas::removeCanvas(SkCanvas* canvas) {
int index = fList.find(canvas);
if (index >= 0) {
canvas->unref();
fList.removeShuffle(index);
}
}
void SkNWayCanvas::removeAll() {
fList.unrefAll();
fList.reset();
}
///////////////////////////////////////////////////////////////////////////
// These are forwarded to the N canvases we're referencing
class SkNWayCanvas::Iter {
public:
Iter(const SkTDArray<SkCanvas*>& list) : fList(list) {
fIndex = 0;
}
bool next() {
if (fIndex < fList.count()) {
fCanvas = fList[fIndex++];
return true;
}
return false;
}
SkCanvas* operator->() { return fCanvas; }
private:
const SkTDArray<SkCanvas*>& fList;
int fIndex;
SkCanvas* fCanvas;
};
void SkNWayCanvas::willSave() {
Iter iter(fList);
while (iter.next()) {
iter->save();
}
this->INHERITED::willSave();
}
SkCanvas::SaveLayerStrategy SkNWayCanvas::getSaveLayerStrategy(const SaveLayerRec& rec) {
Iter iter(fList);
while (iter.next()) {
iter->saveLayer(rec);
}
this->INHERITED::getSaveLayerStrategy(rec);
// No need for a layer.
return kNoLayer_SaveLayerStrategy;
}
void SkNWayCanvas::willRestore() {
Iter iter(fList);
while (iter.next()) {
iter->restore();
}
this->INHERITED::willRestore();
}
void SkNWayCanvas::didConcat(const SkMatrix& matrix) {
Iter iter(fList);
while (iter.next()) {
iter->concat(matrix);
}
this->INHERITED::didConcat(matrix);
}
void SkNWayCanvas::didSetMatrix(const SkMatrix& matrix) {
Iter iter(fList);
while (iter.next()) {
iter->setMatrix(matrix);
}
this->INHERITED::didSetMatrix(matrix);
}
void SkNWayCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
}
this->INHERITED::onClipRect(rect, op, edgeStyle);
}
void SkNWayCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
}
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
void SkNWayCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
}
this->INHERITED::onClipPath(path, op, edgeStyle);
}
void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
Iter iter(fList);
while (iter.next()) {
iter->clipRegion(deviceRgn, op);
}
this->INHERITED::onClipRegion(deviceRgn, op);
}
void SkNWayCanvas::onDrawPaint(const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPaint(paint);
}
}
void SkNWayCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPoints(mode, count, pts, paint);
}
}
void SkNWayCanvas::onDrawRect(const SkRect& rect, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawRect(rect, paint);
}
}
void SkNWayCanvas::onDrawOval(const SkRect& rect, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawOval(rect, paint);
}
}
void SkNWayCanvas::onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
bool useCenter, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawArc(rect, startAngle, sweepAngle, useCenter, paint);
}
}
void SkNWayCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawRRect(rrect, paint);
}
}
void SkNWayCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawDRRect(outer, inner, paint);
}
}
void SkNWayCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPath(path, paint);
}
}
void SkNWayCanvas::onDrawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawBitmap(bitmap, x, y, paint);
}
}
void SkNWayCanvas::onDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
Iter iter(fList);
while (iter.next()) {
iter->legacy_drawBitmapRect(bitmap, src, dst, paint, (SrcRectConstraint)constraint);
}
}
void SkNWayCanvas::onDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawBitmapNine(bitmap, center, dst, paint);
}
}
void SkNWayCanvas::onDrawImage(const SkImage* image, SkScalar left, SkScalar top,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawImage(image, left, top, paint);
}
}
void SkNWayCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const SkRect& dst,
const SkPaint* paint, SrcRectConstraint constraint) {
Iter iter(fList);
while (iter.next()) {
iter->legacy_drawImageRect(image, src, dst, paint, constraint);
}
}
void SkNWayCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawText(text, byteLength, x, y, paint);
}
}
void SkNWayCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPosText(text, byteLength, pos, paint);
}
}
void SkNWayCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
SkScalar constY, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPosTextH(text, byteLength, xpos, constY, paint);
}
}
void SkNWayCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
const SkMatrix* matrix, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawTextOnPath(text, byteLength, path, matrix, paint);
}
}
void SkNWayCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
const SkRect* cull, const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawTextRSXform(text, byteLength, xform, cull, paint);
}
}
void SkNWayCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint &paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawTextBlob(blob, x, y, paint);
}
}
void SkNWayCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
const SkPaint* paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPicture(picture, matrix, paint);
}
}
void SkNWayCanvas::onDrawVertices(VertexMode vmode, int vertexCount,
const SkPoint vertices[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawVertices(vmode, vertexCount, vertices, texs, colors, xmode,
indices, indexCount, paint);
}
}
void SkNWayCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
const SkPoint texCoords[4], SkXfermode* xmode,
const SkPaint& paint) {
Iter iter(fList);
while (iter.next()) {
iter->drawPatch(cubics, colors, texCoords, xmode, paint);
}
}
void SkNWayCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* data) {
Iter iter(fList);
while (iter.next()) {
iter->drawAnnotation(rect, key, data);
}
}
#ifdef SK_SUPPORT_LEGACY_DRAWFILTER
SkDrawFilter* SkNWayCanvas::setDrawFilter(SkDrawFilter* filter) {
Iter iter(fList);
while (iter.next()) {
iter->setDrawFilter(filter);
}
return this->INHERITED::setDrawFilter(filter);
}
#endif
|