|
1 |
|
2 /* |
|
3 * Copyright 2011 Google Inc. |
|
4 * |
|
5 * Use of this source code is governed by a BSD-style license that can be |
|
6 * found in the LICENSE file. |
|
7 */ |
|
8 #include "SkProxyCanvas.h" |
|
9 |
|
10 SkProxyCanvas::SkProxyCanvas(SkCanvas* proxy) : fProxy(proxy) { |
|
11 SkSafeRef(fProxy); |
|
12 } |
|
13 |
|
14 SkProxyCanvas::~SkProxyCanvas() { |
|
15 SkSafeUnref(fProxy); |
|
16 } |
|
17 |
|
18 void SkProxyCanvas::setProxy(SkCanvas* proxy) { |
|
19 SkRefCnt_SafeAssign(fProxy, proxy); |
|
20 } |
|
21 |
|
22 ///////////////////////////////// Overrides /////////// |
|
23 |
|
24 void SkProxyCanvas::willSave(SaveFlags flags) { |
|
25 fProxy->save(flags); |
|
26 this->INHERITED::willSave(flags); |
|
27 } |
|
28 |
|
29 SkCanvas::SaveLayerStrategy SkProxyCanvas::willSaveLayer(const SkRect* bounds, const SkPaint* paint, |
|
30 SaveFlags flags) { |
|
31 fProxy->saveLayer(bounds, paint, flags); |
|
32 this->INHERITED::willSaveLayer(bounds, paint, flags); |
|
33 // No need for a layer. |
|
34 return kNoLayer_SaveLayerStrategy; |
|
35 } |
|
36 |
|
37 void SkProxyCanvas::willRestore() { |
|
38 fProxy->restore(); |
|
39 this->INHERITED::willRestore(); |
|
40 } |
|
41 |
|
42 void SkProxyCanvas::didTranslate(SkScalar dx, SkScalar dy) { |
|
43 fProxy->translate(dx, dy); |
|
44 this->INHERITED::didTranslate(dx, dy); |
|
45 } |
|
46 |
|
47 void SkProxyCanvas::didScale(SkScalar sx, SkScalar sy) { |
|
48 fProxy->scale(sx, sy); |
|
49 this->INHERITED::didScale(sx, sy); |
|
50 } |
|
51 |
|
52 void SkProxyCanvas::didRotate(SkScalar degrees) { |
|
53 fProxy->rotate(degrees); |
|
54 this->INHERITED::didRotate(degrees); |
|
55 } |
|
56 |
|
57 void SkProxyCanvas::didSkew(SkScalar sx, SkScalar sy) { |
|
58 fProxy->skew(sx, sy); |
|
59 this->INHERITED::didSkew(sx, sy); |
|
60 } |
|
61 |
|
62 void SkProxyCanvas::didConcat(const SkMatrix& matrix) { |
|
63 fProxy->concat(matrix); |
|
64 this->INHERITED::didConcat(matrix); |
|
65 } |
|
66 |
|
67 void SkProxyCanvas::didSetMatrix(const SkMatrix& matrix) { |
|
68 fProxy->setMatrix(matrix); |
|
69 this->INHERITED::didSetMatrix(matrix); |
|
70 } |
|
71 |
|
72 void SkProxyCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
|
73 fProxy->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle); |
|
74 } |
|
75 |
|
76 void SkProxyCanvas::onClipRRect(const SkRRect& rrect, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
|
77 fProxy->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle); |
|
78 } |
|
79 |
|
80 void SkProxyCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edgeStyle) { |
|
81 fProxy->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle); |
|
82 } |
|
83 |
|
84 void SkProxyCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) { |
|
85 fProxy->clipRegion(deviceRgn, op); |
|
86 } |
|
87 |
|
88 void SkProxyCanvas::drawPaint(const SkPaint& paint) { |
|
89 fProxy->drawPaint(paint); |
|
90 } |
|
91 |
|
92 void SkProxyCanvas::drawPoints(PointMode mode, size_t count, |
|
93 const SkPoint pts[], const SkPaint& paint) { |
|
94 fProxy->drawPoints(mode, count, pts, paint); |
|
95 } |
|
96 |
|
97 void SkProxyCanvas::drawOval(const SkRect& rect, const SkPaint& paint) { |
|
98 fProxy->drawOval(rect, paint); |
|
99 } |
|
100 |
|
101 void SkProxyCanvas::drawRect(const SkRect& rect, const SkPaint& paint) { |
|
102 fProxy->drawRect(rect, paint); |
|
103 } |
|
104 |
|
105 void SkProxyCanvas::drawRRect(const SkRRect& rrect, const SkPaint& paint) { |
|
106 fProxy->drawRRect(rrect, paint); |
|
107 } |
|
108 |
|
109 void SkProxyCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, |
|
110 const SkPaint& paint) { |
|
111 fProxy->drawDRRect(outer, inner, paint); |
|
112 } |
|
113 |
|
114 void SkProxyCanvas::drawPath(const SkPath& path, const SkPaint& paint) { |
|
115 fProxy->drawPath(path, paint); |
|
116 } |
|
117 |
|
118 void SkProxyCanvas::drawBitmap(const SkBitmap& bitmap, SkScalar x, SkScalar y, |
|
119 const SkPaint* paint) { |
|
120 fProxy->drawBitmap(bitmap, x, y, paint); |
|
121 } |
|
122 |
|
123 void SkProxyCanvas::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, |
|
124 const SkRect& dst, const SkPaint* paint, |
|
125 DrawBitmapRectFlags flags) { |
|
126 fProxy->drawBitmapRectToRect(bitmap, src, dst, paint, flags); |
|
127 } |
|
128 |
|
129 void SkProxyCanvas::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m, |
|
130 const SkPaint* paint) { |
|
131 fProxy->drawBitmapMatrix(bitmap, m, paint); |
|
132 } |
|
133 |
|
134 void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, |
|
135 const SkPaint* paint) { |
|
136 fProxy->drawSprite(bitmap, x, y, paint); |
|
137 } |
|
138 |
|
139 void SkProxyCanvas::drawText(const void* text, size_t byteLength, SkScalar x, |
|
140 SkScalar y, const SkPaint& paint) { |
|
141 fProxy->drawText(text, byteLength, x, y, paint); |
|
142 } |
|
143 |
|
144 void SkProxyCanvas::drawPosText(const void* text, size_t byteLength, |
|
145 const SkPoint pos[], const SkPaint& paint) { |
|
146 fProxy->drawPosText(text, byteLength, pos, paint); |
|
147 } |
|
148 |
|
149 void SkProxyCanvas::drawPosTextH(const void* text, size_t byteLength, |
|
150 const SkScalar xpos[], SkScalar constY, |
|
151 const SkPaint& paint) { |
|
152 fProxy->drawPosTextH(text, byteLength, xpos, constY, paint); |
|
153 } |
|
154 |
|
155 void SkProxyCanvas::drawTextOnPath(const void* text, size_t byteLength, |
|
156 const SkPath& path, const SkMatrix* matrix, |
|
157 const SkPaint& paint) { |
|
158 fProxy->drawTextOnPath(text, byteLength, path, matrix, paint); |
|
159 } |
|
160 |
|
161 void SkProxyCanvas::drawPicture(SkPicture& picture) { |
|
162 fProxy->drawPicture(picture); |
|
163 } |
|
164 |
|
165 void SkProxyCanvas::drawVertices(VertexMode vmode, int vertexCount, |
|
166 const SkPoint vertices[], const SkPoint texs[], |
|
167 const SkColor colors[], SkXfermode* xmode, |
|
168 const uint16_t indices[], int indexCount, |
|
169 const SkPaint& paint) { |
|
170 fProxy->drawVertices(vmode, vertexCount, vertices, texs, colors, |
|
171 xmode, indices, indexCount, paint); |
|
172 } |
|
173 |
|
174 void SkProxyCanvas::drawData(const void* data, size_t length) { |
|
175 fProxy->drawData(data, length); |
|
176 } |
|
177 |
|
178 void SkProxyCanvas::beginCommentGroup(const char* description) { |
|
179 fProxy->beginCommentGroup(description); |
|
180 } |
|
181 |
|
182 void SkProxyCanvas::addComment(const char* kywd, const char* value) { |
|
183 fProxy->addComment(kywd, value); |
|
184 } |
|
185 |
|
186 void SkProxyCanvas::endCommentGroup() { |
|
187 fProxy->endCommentGroup(); |
|
188 } |
|
189 |
|
190 SkBounder* SkProxyCanvas::setBounder(SkBounder* bounder) { |
|
191 return fProxy->setBounder(bounder); |
|
192 } |
|
193 |
|
194 SkDrawFilter* SkProxyCanvas::setDrawFilter(SkDrawFilter* filter) { |
|
195 return fProxy->setDrawFilter(filter); |
|
196 } |