blob: de24611f8b6484ca95b12ebe75ce0369fb56d710 [file] [log] [blame]
chudy@google.com902ebe52012-06-29 14:21:22 +00001
2/*
3 * Copyright 2012 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
9
chudy@google.com902ebe52012-06-29 14:21:22 +000010#include "SkDrawCommand.h"
11#include "SkObjectParser.h"
12
13// TODO(chudy): Refactor into non subclass model.
14
skia.committer@gmail.coma5d3e772013-05-30 07:01:29 +000015SkDrawCommand::SkDrawCommand(DrawType type)
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000016 : fDrawType(type)
17 , fVisible(true) {
18}
19
chudy@google.com902ebe52012-06-29 14:21:22 +000020SkDrawCommand::SkDrawCommand() {
21 fVisible = true;
22}
23
24SkDrawCommand::~SkDrawCommand() {
chudy@google.com97cee972012-08-07 20:41:37 +000025 fInfo.deleteAll();
chudy@google.com902ebe52012-06-29 14:21:22 +000026}
27
28const char* SkDrawCommand::GetCommandString(DrawType type) {
29 switch (type) {
30 case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break;
31 case DRAW_CLEAR: return "Clear";
32 case CLIP_PATH: return "Clip Path";
33 case CLIP_REGION: return "Clip Region";
34 case CLIP_RECT: return "Clip Rect";
robertphillips@google.com67baba42013-01-02 20:20:31 +000035 case CLIP_RRECT: return "Clip RRect";
chudy@google.com902ebe52012-06-29 14:21:22 +000036 case CONCAT: return "Concat";
37 case DRAW_BITMAP: return "Draw Bitmap";
38 case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix";
39 case DRAW_BITMAP_NINE: return "Draw Bitmap Nine";
robertphillips@google.com84d320e2012-09-20 19:09:17 +000040 case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect";
chudy@google.com902ebe52012-06-29 14:21:22 +000041 case DRAW_DATA: return "Draw Data";
robertphillips@google.com67baba42013-01-02 20:20:31 +000042 case DRAW_OVAL: return "Draw Oval";
chudy@google.com902ebe52012-06-29 14:21:22 +000043 case DRAW_PAINT: return "Draw Paint";
44 case DRAW_PATH: return "Draw Path";
45 case DRAW_PICTURE: return "Draw Picture";
46 case DRAW_POINTS: return "Draw Points";
47 case DRAW_POS_TEXT: return "Draw Pos Text";
48 case DRAW_POS_TEXT_H: return "Draw Pos Text H";
49 case DRAW_RECT: return "Draw Rect";
robertphillips@google.com67baba42013-01-02 20:20:31 +000050 case DRAW_RRECT: return "Draw RRect";
chudy@google.com902ebe52012-06-29 14:21:22 +000051 case DRAW_SPRITE: return "Draw Sprite";
52 case DRAW_TEXT: return "Draw Text";
53 case DRAW_TEXT_ON_PATH: return "Draw Text On Path";
54 case DRAW_VERTICES: return "Draw Vertices";
55 case RESTORE: return "Restore";
56 case ROTATE: return "Rotate";
57 case SAVE: return "Save";
58 case SAVE_LAYER: return "Save Layer";
59 case SCALE: return "Scale";
60 case SET_MATRIX: return "Set Matrix";
61 case SKEW: return "Skew";
62 case TRANSLATE: return "Translate";
robertphillips@google.come4ce5b82013-02-15 17:19:15 +000063 case NOOP: return "NoOp";
robertphillips@google.com0a4805e2013-05-29 13:24:23 +000064 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup";
65 case COMMENT: return "Comment";
66 case END_COMMENT_GROUP: return "EndCommentGroup";
chudy@google.com902ebe52012-06-29 14:21:22 +000067 default:
68 SkDebugf("DrawType error 0x%08x\n", type);
69 SkASSERT(0);
70 break;
71 }
72 SkDEBUGFAIL("DrawType UNUSED\n");
73 return NULL;
74}
75
chudy@google.com97cee972012-08-07 20:41:37 +000076SkString SkDrawCommand::toString() {
77 return SkString(GetCommandString(fDrawType));
chudy@google.com902ebe52012-06-29 14:21:22 +000078}
79
80Clear::Clear(SkColor color) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000081 fColor = color;
82 fDrawType = DRAW_CLEAR;
83 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
chudy@google.com902ebe52012-06-29 14:21:22 +000084}
85
86void Clear::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +000087 canvas->clear(fColor);
chudy@google.com902ebe52012-06-29 14:21:22 +000088}
89
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +000090namespace {
91
92void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
93 const SkISize& size = canvas->getDeviceSize();
94
95 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
96
97 canvas->translate(size.fWidth/2.0f, size.fHeight/2.0f);
98 if (bounds.width() > bounds.height()) {
99 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.width()),
100 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.width()));
101 } else {
102 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()),
103 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height()));
104 }
105 canvas->translate(-bounds.centerX(), -bounds.centerY());
106}
107
108
109void render_path(SkCanvas* canvas, const SkPath& path) {
110 canvas->clear(0xFFFFFFFF);
111 canvas->save();
112
113 const SkRect& bounds = path.getBounds();
114
115 xlate_and_scale_to_bounds(canvas, bounds);
116
117 SkPaint p;
118 p.setColor(SK_ColorBLACK);
119 p.setStyle(SkPaint::kStroke_Style);
120
121 canvas->drawPath(path, p);
122 canvas->restore();
123}
124
125void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = NULL) {
126 const SkISize& size = canvas->getDeviceSize();
127
128 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width();
129 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height();
130
131 if (input.width() > input.height()) {
132 yScale *= input.height() / (float) input.width();
133 } else {
134 xScale *= input.width() / (float) input.height();
135 }
136
137 SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1,
138 xScale * input.width(),
139 yScale * input.height());
140
141 canvas->clear(0xFFFFFFFF);
142 canvas->drawBitmapRect(input, NULL, dst);
143
144 if (NULL != srcRect) {
145 SkRect r = SkRect::MakeLTRB(srcRect->fLeft * xScale + SK_Scalar1,
146 srcRect->fTop * yScale + SK_Scalar1,
147 srcRect->fRight * xScale + SK_Scalar1,
148 srcRect->fBottom * yScale + SK_Scalar1);
149 SkPaint p;
150 p.setColor(SK_ColorRED);
151 p.setStyle(SkPaint::kStroke_Style);
152
153 canvas->drawRect(r, p);
154 }
155}
156
157void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
158 canvas->clear(0xFFFFFFFF);
159 canvas->save();
160
161 const SkRect& bounds = rrect.getBounds();
162
163 xlate_and_scale_to_bounds(canvas, bounds);
164
165 SkPaint p;
166 p.setColor(SK_ColorBLACK);
167 p.setStyle(SkPaint::kStroke_Style);
168
169 canvas->drawRRect(rrect, p);
170 canvas->restore();
171}
172
173};
174
175
176ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000177 fPath = path;
178 fOp = op;
179 fDoAA = doAA;
180 fDrawType = CLIP_PATH;
chudy@google.com902ebe52012-06-29 14:21:22 +0000181
robertphillips@google.com91217d02013-03-17 18:33:46 +0000182 fInfo.push(SkObjectParser::PathToString(path));
183 fInfo.push(SkObjectParser::RegionOpToString(op));
184 fInfo.push(SkObjectParser::BoolToString(doAA));
chudy@google.com902ebe52012-06-29 14:21:22 +0000185}
186
187void ClipPath::execute(SkCanvas* canvas) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000188 canvas->clipPath(fPath, fOp, fDoAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000189}
190
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000191bool ClipPath::render(SkCanvas* canvas) const {
192 render_path(canvas, fPath);
193 return true;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000194}
195
chudy@google.com902ebe52012-06-29 14:21:22 +0000196ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000197 fRegion = region;
198 fOp = op;
199 fDrawType = CLIP_REGION;
chudy@google.com902ebe52012-06-29 14:21:22 +0000200
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000201 fInfo.push(SkObjectParser::RegionToString(region));
202 fInfo.push(SkObjectParser::RegionOpToString(op));
chudy@google.com902ebe52012-06-29 14:21:22 +0000203}
204
205void ClipRegion::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000206 canvas->clipRegion(fRegion, fOp);
chudy@google.com902ebe52012-06-29 14:21:22 +0000207}
208
209ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000210 fRect = rect;
211 fOp = op;
212 fDoAA = doAA;
213 fDrawType = CLIP_RECT;
chudy@google.com902ebe52012-06-29 14:21:22 +0000214
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000215 fInfo.push(SkObjectParser::RectToString(rect));
216 fInfo.push(SkObjectParser::RegionOpToString(op));
217 fInfo.push(SkObjectParser::BoolToString(doAA));
chudy@google.com902ebe52012-06-29 14:21:22 +0000218}
219
220void ClipRect::execute(SkCanvas* canvas) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000221 canvas->clipRect(fRect, fOp, fDoAA);
chudy@google.com902ebe52012-06-29 14:21:22 +0000222}
223
robertphillips@google.com67baba42013-01-02 20:20:31 +0000224ClipRRect::ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000225 fRRect = rrect;
226 fOp = op;
227 fDoAA = doAA;
228 fDrawType = CLIP_RRECT;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000229
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000230 fInfo.push(SkObjectParser::RRectToString(rrect));
231 fInfo.push(SkObjectParser::RegionOpToString(op));
232 fInfo.push(SkObjectParser::BoolToString(doAA));
robertphillips@google.com67baba42013-01-02 20:20:31 +0000233}
234
235void ClipRRect::execute(SkCanvas* canvas) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000236 canvas->clipRRect(fRRect, fOp, fDoAA);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000237}
238
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000239bool ClipRRect::render(SkCanvas* canvas) const {
240 render_rrect(canvas, fRRect);
241 return true;
242}
243
chudy@google.com902ebe52012-06-29 14:21:22 +0000244Concat::Concat(const SkMatrix& matrix) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000245 fMatrix = matrix;
246 fDrawType = CONCAT;
chudy@google.com902ebe52012-06-29 14:21:22 +0000247
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000248 fInfo.push(SkObjectParser::MatrixToString(matrix));
chudy@google.com902ebe52012-06-29 14:21:22 +0000249}
250
251void Concat::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000252 canvas->concat(fMatrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000253}
254
255DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000256 const SkPaint* paint) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000257 fBitmap = bitmap;
258 fLeft = left;
259 fTop = top;
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000260 if (NULL != paint) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000261 fPaint = *paint;
262 fPaintPtr = &fPaint;
263 } else {
264 fPaintPtr = NULL;
265 }
266 fDrawType = DRAW_BITMAP;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000267
268 fInfo.push(SkObjectParser::BitmapToString(bitmap));
269 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
270 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
271 if (NULL != paint) {
272 fInfo.push(SkObjectParser::PaintToString(*paint));
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000273 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000274}
275
276void DrawBitmap::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000277 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr);
chudy@google.com902ebe52012-06-29 14:21:22 +0000278}
279
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000280bool DrawBitmap::render(SkCanvas* canvas) const {
281 render_bitmap(canvas, fBitmap);
282 return true;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000283}
284
chudy@google.com902ebe52012-06-29 14:21:22 +0000285DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
skia.committer@gmail.com7e328512013-03-23 07:01:28 +0000286 const SkMatrix& matrix,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000287 const SkPaint* paint) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000288 fBitmap = bitmap;
289 fMatrix = matrix;
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000290 if (NULL != paint) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000291 fPaint = *paint;
292 fPaintPtr = &fPaint;
293 } else {
294 fPaintPtr = NULL;
295 }
296 fDrawType = DRAW_BITMAP_MATRIX;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000297
298 fInfo.push(SkObjectParser::BitmapToString(bitmap));
299 fInfo.push(SkObjectParser::MatrixToString(matrix));
300 if (NULL != paint) {
301 fInfo.push(SkObjectParser::PaintToString(*paint));
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000302 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000303}
304
305void DrawBitmapMatrix::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000306 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
chudy@google.com902ebe52012-06-29 14:21:22 +0000307}
308
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000309bool DrawBitmapMatrix::render(SkCanvas* canvas) const {
310 render_bitmap(canvas, fBitmap);
311 return true;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000312}
313
chudy@google.com902ebe52012-06-29 14:21:22 +0000314DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000315 const SkRect& dst, const SkPaint* paint) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000316 fBitmap = bitmap;
317 fCenter = center;
318 fDst = dst;
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000319 if (NULL != paint) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000320 fPaint = *paint;
321 fPaintPtr = &fPaint;
322 } else {
323 fPaintPtr = NULL;
324 }
325 fDrawType = DRAW_BITMAP_NINE;
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000326
327 fInfo.push(SkObjectParser::BitmapToString(bitmap));
328 fInfo.push(SkObjectParser::IRectToString(center));
329 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
330 if (NULL != paint) {
331 fInfo.push(SkObjectParser::PaintToString(*paint));
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000332 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000333}
334
335void DrawBitmapNine::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000336 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr);
chudy@google.com902ebe52012-06-29 14:21:22 +0000337}
338
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000339bool DrawBitmapNine::render(SkCanvas* canvas) const {
340 render_bitmap(canvas, fBitmap);
341 return true;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000342}
343
reed@google.com71121732012-09-18 15:14:33 +0000344DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000345 const SkRect& dst, const SkPaint* paint) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000346 fBitmap = bitmap;
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000347 if (NULL != src) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000348 fSrc = *src;
349 } else {
350 fSrc.setEmpty();
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000351 }
robertphillips@google.com91217d02013-03-17 18:33:46 +0000352 fDst = dst;
353
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000354 if (NULL != paint) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000355 fPaint = *paint;
356 fPaintPtr = &fPaint;
357 } else {
358 fPaintPtr = NULL;
359 }
360 fDrawType = DRAW_BITMAP_RECT_TO_RECT;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000361
362 fInfo.push(SkObjectParser::BitmapToString(bitmap));
363 if (NULL != src) {
364 fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
365 }
366 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
367 if (NULL != paint) {
368 fInfo.push(SkObjectParser::PaintToString(*paint));
robertphillips@google.comb83b6b42013-01-22 14:32:09 +0000369 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000370}
371
372void DrawBitmapRect::execute(SkCanvas* canvas) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000373 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr);
chudy@google.com902ebe52012-06-29 14:21:22 +0000374}
375
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000376bool DrawBitmapRect::render(SkCanvas* canvas) const {
377 render_bitmap(canvas, fBitmap, this->srcRect());
378 return true;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000379}
380
chudy@google.com902ebe52012-06-29 14:21:22 +0000381DrawData::DrawData(const void* data, size_t length) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000382 fData = new char[length];
383 memcpy(fData, data, length);
384 fLength = length;
385 fDrawType = DRAW_DATA;
386
387 // TODO: add display of actual data?
388 SkString* str = new SkString;
robertphillips@google.com77279cb2013-03-25 12:01:45 +0000389 str->appendf("length: %d", (int) length);
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000390 fInfo.push(str);
chudy@google.com902ebe52012-06-29 14:21:22 +0000391}
392
393void DrawData::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000394 canvas->drawData(fData, fLength);
chudy@google.com902ebe52012-06-29 14:21:22 +0000395}
396
skia.committer@gmail.coma5d3e772013-05-30 07:01:29 +0000397BeginCommentGroup::BeginCommentGroup(const char* description)
robertphillips@google.com0a4805e2013-05-29 13:24:23 +0000398 : INHERITED(BEGIN_COMMENT_GROUP)
399 , fDescription(description) {
400 SkString* temp = new SkString;
401 temp->appendf("Description: %s", description);
402 fInfo.push(temp);
403}
404
405Comment::Comment(const char* kywd, const char* value)
406 : INHERITED(COMMENT)
407 , fKywd(kywd)
408 , fValue(value) {
409 SkString* temp = new SkString;
410 temp->appendf("%s: %s", kywd, value);
411 fInfo.push(temp);
412}
413
414EndCommentGroup::EndCommentGroup() : INHERITED(END_COMMENT_GROUP) {
415}
416
robertphillips@google.com67baba42013-01-02 20:20:31 +0000417DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000418 fOval = oval;
419 fPaint = paint;
420 fDrawType = DRAW_OVAL;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000421
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000422 fInfo.push(SkObjectParser::RectToString(oval));
423 fInfo.push(SkObjectParser::PaintToString(paint));
robertphillips@google.com67baba42013-01-02 20:20:31 +0000424}
425
426void DrawOval::execute(SkCanvas* canvas) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000427 canvas->drawOval(fOval, fPaint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000428}
429
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000430bool DrawOval::render(SkCanvas* canvas) const {
431 canvas->clear(0xFFFFFFFF);
432 canvas->save();
433
434 xlate_and_scale_to_bounds(canvas, fOval);
435
436 SkPaint p;
437 p.setColor(SK_ColorBLACK);
438 p.setStyle(SkPaint::kStroke_Style);
439
440 canvas->drawOval(fOval, p);
441 canvas->restore();
442
443 return true;
444}
445
chudy@google.com902ebe52012-06-29 14:21:22 +0000446DrawPaint::DrawPaint(const SkPaint& paint) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000447 fPaint = paint;
448 fDrawType = DRAW_PAINT;
chudy@google.com902ebe52012-06-29 14:21:22 +0000449
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000450 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000451}
452
453void DrawPaint::execute(SkCanvas* canvas) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000454 canvas->drawPaint(fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000455}
456
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000457bool DrawPaint::render(SkCanvas* canvas) const {
458 canvas->clear(0xFFFFFFFF);
459 canvas->drawPaint(fPaint);
460 return true;
461}
462
463DrawPath::DrawPath(const SkPath& path, const SkPaint& paint) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000464 fPath = path;
465 fPaint = paint;
robertphillips@google.com91217d02013-03-17 18:33:46 +0000466 fDrawType = DRAW_PATH;
chudy@google.com902ebe52012-06-29 14:21:22 +0000467
robertphillips@google.com91217d02013-03-17 18:33:46 +0000468 fInfo.push(SkObjectParser::PathToString(path));
469 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000470}
471
472void DrawPath::execute(SkCanvas* canvas) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000473 canvas->drawPath(fPath, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000474}
475
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000476bool DrawPath::render(SkCanvas* canvas) const {
477 render_path(canvas, fPath);
478 return true;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000479}
480
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000481DrawPicture::DrawPicture(SkPicture& picture) :
482 fPicture(picture) {
483 fDrawType = DRAW_PICTURE;
484 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
chudy@google.com902ebe52012-06-29 14:21:22 +0000485}
486
487void DrawPicture::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000488 canvas->drawPicture(fPicture);
chudy@google.com902ebe52012-06-29 14:21:22 +0000489}
490
491DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000492 const SkPoint pts[], const SkPaint& paint) {
493 fMode = mode;
494 fCount = count;
495 fPts = new SkPoint[count];
496 memcpy(fPts, pts, count * sizeof(SkPoint));
497 fPaint = paint;
498 fDrawType = DRAW_POINTS;
chudy@google.com902ebe52012-06-29 14:21:22 +0000499
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000500 fInfo.push(SkObjectParser::PointsToString(pts, count));
501 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
502 "Points: "));
503 fInfo.push(SkObjectParser::PointModeToString(mode));
504 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000505}
506
507void DrawPoints::execute(SkCanvas* canvas) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000508 canvas->drawPoints(fMode, fCount, fPts, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000509}
510
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000511bool DrawPoints::render(SkCanvas* canvas) const {
512 canvas->clear(0xFFFFFFFF);
513 canvas->save();
514
515 SkRect bounds;
516
517 bounds.setEmpty();
518 for (unsigned int i = 0; i < fCount; ++i) {
519 bounds.growToInclude(fPts[i].fX, fPts[i].fY);
520 }
521
522 xlate_and_scale_to_bounds(canvas, bounds);
523
524 SkPaint p;
525 p.setColor(SK_ColorBLACK);
526 p.setStyle(SkPaint::kStroke_Style);
527
528 canvas->drawPoints(fMode, fCount, fPts, p);
529 canvas->restore();
530
531 return true;
532}
533
chudy@google.com902ebe52012-06-29 14:21:22 +0000534DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000535 const SkPaint& paint) {
536 size_t numPts = paint.countText(text, byteLength);
chudy@google.com902ebe52012-06-29 14:21:22 +0000537
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000538 fText = new char[byteLength];
539 memcpy(fText, text, byteLength);
540 fByteLength = byteLength;
541
542 fPos = new SkPoint[numPts];
543 memcpy(fPos, pos, numPts * sizeof(SkPoint));
544
545 fPaint = paint;
546 fDrawType = DRAW_POS_TEXT;
547
548 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
chudy@google.com902ebe52012-06-29 14:21:22 +0000549 // TODO(chudy): Test that this works.
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000550 fInfo.push(SkObjectParser::PointsToString(pos, 1));
551 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000552}
553
554void DrawPosText::execute(SkCanvas* canvas) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000555 canvas->drawPosText(fText, fByteLength, fPos, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000556}
557
558
559DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
skia.committer@gmail.comc76bb232013-03-18 07:01:03 +0000560 const SkScalar xpos[], SkScalar constY,
robertphillips@google.com91217d02013-03-17 18:33:46 +0000561 const SkPaint& paint) {
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000562 size_t numPts = paint.countText(text, byteLength);
563
564 fText = new char[byteLength];
565 memcpy(fText, text, byteLength);
robertphillips@google.com91217d02013-03-17 18:33:46 +0000566 fByteLength = byteLength;
robertphillips@google.coma3a09ab2013-03-22 12:25:30 +0000567
568 fXpos = new SkScalar[numPts];
569 memcpy(fXpos, xpos, numPts * sizeof(SkScalar));
570
robertphillips@google.com91217d02013-03-17 18:33:46 +0000571 fConstY = constY;
572 fPaint = paint;
573 fDrawType = DRAW_POS_TEXT_H;
chudy@google.com902ebe52012-06-29 14:21:22 +0000574
robertphillips@google.com91217d02013-03-17 18:33:46 +0000575 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
576 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
577 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
578 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000579}
580
581void DrawPosTextH::execute(SkCanvas* canvas) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000582 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000583}
584
585DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000586 fRect = rect;
587 fPaint = paint;
588 fDrawType = DRAW_RECT;
chudy@google.com902ebe52012-06-29 14:21:22 +0000589
robertphillips@google.com91217d02013-03-17 18:33:46 +0000590 fInfo.push(SkObjectParser::RectToString(rect));
591 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000592}
593
594void DrawRectC::execute(SkCanvas* canvas) {
robertphillips@google.com91217d02013-03-17 18:33:46 +0000595 canvas->drawRect(fRect, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000596}
597
robertphillips@google.com67baba42013-01-02 20:20:31 +0000598DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000599 fRRect = rrect;
600 fPaint = paint;
601 fDrawType = DRAW_RRECT;
robertphillips@google.com67baba42013-01-02 20:20:31 +0000602
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000603 fInfo.push(SkObjectParser::RRectToString(rrect));
604 fInfo.push(SkObjectParser::PaintToString(paint));
robertphillips@google.com67baba42013-01-02 20:20:31 +0000605}
606
607void DrawRRect::execute(SkCanvas* canvas) {
robertphillips@google.comfebc0ec2013-03-11 22:53:11 +0000608 canvas->drawRRect(fRRect, fPaint);
robertphillips@google.com67baba42013-01-02 20:20:31 +0000609}
610
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000611bool DrawRRect::render(SkCanvas* canvas) const {
612 render_rrect(canvas, fRRect);
613 return true;
614}
615
chudy@google.com902ebe52012-06-29 14:21:22 +0000616DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000617 const SkPaint* paint) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000618 fBitmap = bitmap;
619 fLeft = left;
620 fTop = top;
621 if (NULL != paint) {
622 fPaint = *paint;
623 fPaintPtr = &fPaint;
624 } else {
625 fPaintPtr = NULL;
626 }
627 fDrawType = DRAW_SPRITE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000628
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000629 fInfo.push(SkObjectParser::BitmapToString(bitmap));
630 fInfo.push(SkObjectParser::IntToString(left, "Left: "));
631 fInfo.push(SkObjectParser::IntToString(top, "Top: "));
632 if (NULL != paint) {
633 fInfo.push(SkObjectParser::PaintToString(*paint));
634 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000635}
636
637void DrawSprite::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000638 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr);
chudy@google.com902ebe52012-06-29 14:21:22 +0000639}
640
robertphillips@google.com6ede1fe2013-06-06 23:59:28 +0000641bool DrawSprite::render(SkCanvas* canvas) const {
642 render_bitmap(canvas, fBitmap);
643 return true;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000644}
645
chudy@google.com902ebe52012-06-29 14:21:22 +0000646DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000647 const SkPaint& paint) {
648 fText = new char[byteLength];
649 memcpy(fText, text, byteLength);
650 fByteLength = byteLength;
651 fX = x;
652 fY = y;
653 fPaint = paint;
654 fDrawType = DRAW_TEXT;
chudy@google.com902ebe52012-06-29 14:21:22 +0000655
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000656 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
657 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
658 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
659 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000660}
661
662void DrawTextC::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000663 canvas->drawText(fText, fByteLength, fX, fY, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000664}
665
666DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
skia.committer@gmail.come60ed082013-03-26 07:01:04 +0000667 const SkPath& path, const SkMatrix* matrix,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000668 const SkPaint& paint) {
669 fText = new char[byteLength];
670 memcpy(fText, text, byteLength);
671 fByteLength = byteLength;
672 fPath = path;
673 if (NULL != matrix) {
674 fMatrix = *matrix;
675 } else {
676 fMatrix.setIdentity();
677 }
678 fPaint = paint;
679 fDrawType = DRAW_TEXT_ON_PATH;
chudy@google.com902ebe52012-06-29 14:21:22 +0000680
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000681 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
682 fInfo.push(SkObjectParser::PathToString(path));
683 if (NULL != matrix) {
684 fInfo.push(SkObjectParser::MatrixToString(*matrix));
685 }
686 fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000687}
688
689void DrawTextOnPath::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000690 canvas->drawTextOnPath(fText, fByteLength, fPath,
691 fMatrix.isIdentity() ? NULL : &fMatrix,
692 fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000693}
694
695DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
skia.committer@gmail.come60ed082013-03-26 07:01:04 +0000696 const SkPoint vertices[], const SkPoint texs[],
697 const SkColor colors[], SkXfermode* xfermode,
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000698 const uint16_t indices[], int indexCount,
699 const SkPaint& paint) {
700 fVmode = vmode;
701
702 fVertexCount = vertexCount;
703
704 fVertices = new SkPoint[vertexCount];
705 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
706
707 if (NULL != texs) {
708 fTexs = new SkPoint[vertexCount];
709 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
710 } else {
711 fTexs = NULL;
712 }
713
714 if (NULL != colors) {
715 fColors = new SkColor[vertexCount];
716 memcpy(fColors, colors, vertexCount * sizeof(SkColor));
717 } else {
718 fColors = NULL;
719 }
720
721 fXfermode = xfermode;
722 if (NULL != fXfermode) {
723 fXfermode->ref();
724 }
725
726 if (indexCount > 0) {
727 fIndices = new uint16_t[indexCount];
728 memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
729 } else {
730 fIndices = NULL;
731 }
732
733 fIndexCount = indexCount;
734 fPaint = paint;
735 fDrawType = DRAW_VERTICES;
736
chudy@google.com902ebe52012-06-29 14:21:22 +0000737 // TODO(chudy)
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000738 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
739 fInfo.push(SkObjectParser::PaintToString(paint));
740}
741
742DrawVertices::~DrawVertices() {
743 delete [] fVertices;
744 delete [] fTexs;
745 delete [] fColors;
746 SkSafeUnref(fXfermode);
747 delete [] fIndices;
chudy@google.com902ebe52012-06-29 14:21:22 +0000748}
749
750void DrawVertices::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000751 canvas->drawVertices(fVmode, fVertexCount, fVertices,
752 fTexs, fColors, fXfermode, fIndices,
753 fIndexCount, fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000754}
755
756Restore::Restore() {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000757 fDrawType = RESTORE;
758 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000759}
760
761void Restore::execute(SkCanvas* canvas) {
762 canvas->restore();
763}
764
tomhudson@google.com0699e022012-11-27 16:09:42 +0000765void Restore::trackSaveState(int* state) {
766 (*state)--;
767}
768
chudy@google.com902ebe52012-06-29 14:21:22 +0000769Rotate::Rotate(SkScalar degrees) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000770 fDegrees = degrees;
771 fDrawType = ROTATE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000772
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000773 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000774}
775
776void Rotate::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000777 canvas->rotate(fDegrees);
chudy@google.com902ebe52012-06-29 14:21:22 +0000778}
779
780Save::Save(SkCanvas::SaveFlags flags) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000781 fFlags = flags;
782 fDrawType = SAVE;
783 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
chudy@google.com902ebe52012-06-29 14:21:22 +0000784}
785
786void Save::execute(SkCanvas* canvas) {
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000787 canvas->save(fFlags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000788}
789
tomhudson@google.com0699e022012-11-27 16:09:42 +0000790void Save::trackSaveState(int* state) {
791 (*state)++;
792}
793
chudy@google.com902ebe52012-06-29 14:21:22 +0000794SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000795 SkCanvas::SaveFlags flags) {
796 if (NULL != bounds) {
797 fBounds = *bounds;
798 } else {
799 fBounds.setEmpty();
800 }
chudy@google.com902ebe52012-06-29 14:21:22 +0000801
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000802 if (NULL != paint) {
803 fPaint = *paint;
804 fPaintPtr = &fPaint;
805 } else {
806 fPaintPtr = NULL;
807 }
808 fFlags = flags;
809 fDrawType = SAVE_LAYER;
810
811 if (NULL != bounds) {
812 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
813 }
814 if (NULL != paint) {
815 fInfo.push(SkObjectParser::PaintToString(*paint));
816 }
817 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
chudy@google.com902ebe52012-06-29 14:21:22 +0000818}
819
820void SaveLayer::execute(SkCanvas* canvas) {
skia.committer@gmail.com7e328512013-03-23 07:01:28 +0000821 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds,
robertphillips@google.com24bfdac2013-03-22 16:33:31 +0000822 fPaintPtr,
823 fFlags);
chudy@google.com902ebe52012-06-29 14:21:22 +0000824}
825
tomhudson@google.com0699e022012-11-27 16:09:42 +0000826void SaveLayer::trackSaveState(int* state) {
827 (*state)++;
828}
829
chudy@google.com902ebe52012-06-29 14:21:22 +0000830Scale::Scale(SkScalar sx, SkScalar sy) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000831 fSx = sx;
832 fSy = sy;
833 fDrawType = SCALE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000834
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000835 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
836 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000837}
838
839void Scale::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000840 canvas->scale(fSx, fSy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000841}
842
843SetMatrix::SetMatrix(const SkMatrix& matrix) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000844 fMatrix = matrix;
845 fDrawType = SET_MATRIX;
chudy@google.com902ebe52012-06-29 14:21:22 +0000846
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000847 fInfo.push(SkObjectParser::MatrixToString(matrix));
chudy@google.com902ebe52012-06-29 14:21:22 +0000848}
849
850void SetMatrix::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000851 canvas->setMatrix(fMatrix);
chudy@google.com902ebe52012-06-29 14:21:22 +0000852}
853
854Skew::Skew(SkScalar sx, SkScalar sy) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000855 fSx = sx;
856 fSy = sy;
857 fDrawType = SKEW;
chudy@google.com902ebe52012-06-29 14:21:22 +0000858
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000859 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
860 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000861}
862
863void Skew::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000864 canvas->skew(fSx, fSy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000865}
866
867Translate::Translate(SkScalar dx, SkScalar dy) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000868 fDx = dx;
869 fDy = dy;
870 fDrawType = TRANSLATE;
chudy@google.com902ebe52012-06-29 14:21:22 +0000871
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000872 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
873 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000874}
875
876void Translate::execute(SkCanvas* canvas) {
robertphillips@google.com0df2a9a2013-03-25 11:50:42 +0000877 canvas->translate(fDx, fDy);
chudy@google.com902ebe52012-06-29 14:21:22 +0000878}