blob: 45aaaf2c78c35001e2d354e12a53402c0655ae11 [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
15SkDrawCommand::SkDrawCommand() {
16 fVisible = true;
17}
18
19SkDrawCommand::~SkDrawCommand() {
chudy@google.com97cee972012-08-07 20:41:37 +000020 fInfo.deleteAll();
chudy@google.com902ebe52012-06-29 14:21:22 +000021}
22
23const char* SkDrawCommand::GetCommandString(DrawType type) {
24 switch (type) {
25 case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break;
26 case DRAW_CLEAR: return "Clear";
27 case CLIP_PATH: return "Clip Path";
28 case CLIP_REGION: return "Clip Region";
29 case CLIP_RECT: return "Clip Rect";
30 case CONCAT: return "Concat";
31 case DRAW_BITMAP: return "Draw Bitmap";
32 case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix";
33 case DRAW_BITMAP_NINE: return "Draw Bitmap Nine";
robertphillips@google.com84d320e2012-09-20 19:09:17 +000034 case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect";
chudy@google.com902ebe52012-06-29 14:21:22 +000035 case DRAW_DATA: return "Draw Data";
36 case DRAW_PAINT: return "Draw Paint";
37 case DRAW_PATH: return "Draw Path";
38 case DRAW_PICTURE: return "Draw Picture";
39 case DRAW_POINTS: return "Draw Points";
40 case DRAW_POS_TEXT: return "Draw Pos Text";
41 case DRAW_POS_TEXT_H: return "Draw Pos Text H";
42 case DRAW_RECT: return "Draw Rect";
43 case DRAW_SPRITE: return "Draw Sprite";
44 case DRAW_TEXT: return "Draw Text";
45 case DRAW_TEXT_ON_PATH: return "Draw Text On Path";
46 case DRAW_VERTICES: return "Draw Vertices";
47 case RESTORE: return "Restore";
48 case ROTATE: return "Rotate";
49 case SAVE: return "Save";
50 case SAVE_LAYER: return "Save Layer";
51 case SCALE: return "Scale";
52 case SET_MATRIX: return "Set Matrix";
53 case SKEW: return "Skew";
54 case TRANSLATE: return "Translate";
55 default:
56 SkDebugf("DrawType error 0x%08x\n", type);
57 SkASSERT(0);
58 break;
59 }
60 SkDEBUGFAIL("DrawType UNUSED\n");
61 return NULL;
62}
63
chudy@google.com97cee972012-08-07 20:41:37 +000064SkString SkDrawCommand::toString() {
65 return SkString(GetCommandString(fDrawType));
chudy@google.com902ebe52012-06-29 14:21:22 +000066}
67
68Clear::Clear(SkColor color) {
69 this->fColor = color;
70 this->fDrawType = DRAW_CLEAR;
chudy@google.com97cee972012-08-07 20:41:37 +000071 this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
chudy@google.com902ebe52012-06-29 14:21:22 +000072}
73
74void Clear::execute(SkCanvas* canvas) {
75 canvas->clear(this->fColor);
76}
77
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000078ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +000079 this->fPath = &path;
80 this->fOp = op;
81 this->fDoAA = doAA;
82 this->fDrawType = CLIP_PATH;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000083 this->fBitmap = bitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +000084
chudy@google.com97cee972012-08-07 20:41:37 +000085 this->fInfo.push(SkObjectParser::PathToString(path));
86 this->fInfo.push(SkObjectParser::RegionOpToString(op));
87 this->fInfo.push(SkObjectParser::BoolToString(doAA));
chudy@google.com902ebe52012-06-29 14:21:22 +000088}
89
90void ClipPath::execute(SkCanvas* canvas) {
91 canvas->clipPath(*this->fPath, this->fOp, this->fDoAA);
92}
93
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +000094const SkBitmap* ClipPath::getBitmap() const {
95 return &fBitmap;
96}
97
chudy@google.com902ebe52012-06-29 14:21:22 +000098ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) {
99 this->fRegion = &region;
100 this->fOp = op;
101 this->fDrawType = CLIP_REGION;
102
chudy@google.com97cee972012-08-07 20:41:37 +0000103 this->fInfo.push(SkObjectParser::RegionToString(region));
104 this->fInfo.push(SkObjectParser::RegionOpToString(op));
chudy@google.com902ebe52012-06-29 14:21:22 +0000105}
106
107void ClipRegion::execute(SkCanvas* canvas) {
108 canvas->clipRegion(*this->fRegion, this->fOp);
109}
110
111ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
112 this->fRect = ▭
113 this->fOp = op;
114 this->fDoAA = doAA;
115 this->fDrawType = CLIP_RECT;
116
chudy@google.com97cee972012-08-07 20:41:37 +0000117 this->fInfo.push(SkObjectParser::RectToString(rect));
118 this->fInfo.push(SkObjectParser::RegionOpToString(op));
119 this->fInfo.push(SkObjectParser::BoolToString(doAA));
chudy@google.com902ebe52012-06-29 14:21:22 +0000120}
121
122void ClipRect::execute(SkCanvas* canvas) {
123 canvas->clipRect(*this->fRect, this->fOp, this->fDoAA);
124}
125
126Concat::Concat(const SkMatrix& matrix) {
127 this->fMatrix = &matrix;
128 this->fDrawType = CONCAT;
129
chudy@google.com97cee972012-08-07 20:41:37 +0000130 this->fInfo.push(SkObjectParser::MatrixToString(matrix));
chudy@google.com902ebe52012-06-29 14:21:22 +0000131}
132
133void Concat::execute(SkCanvas* canvas) {
134 canvas->concat(*this->fMatrix);
135}
136
137DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
138 const SkPaint* paint) {
139 this->fBitmap = &bitmap;
140 this->fLeft = left;
141 this->fTop = top;
142 this->fPaint = paint;
143 this->fDrawType = DRAW_BITMAP;
144
chudy@google.com97cee972012-08-07 20:41:37 +0000145 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
146 this->fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
147 this->fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000148}
149
150void DrawBitmap::execute(SkCanvas* canvas) {
151 canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
152}
153
154DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
155 const SkMatrix& matrix, const SkPaint* paint) {
156 this->fBitmap = &bitmap;
157 this->fMatrix = &matrix;
158 this->fPaint = paint;
159 this->fDrawType = DRAW_BITMAP_MATRIX;
160
chudy@google.com97cee972012-08-07 20:41:37 +0000161 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
162 this->fInfo.push(SkObjectParser::MatrixToString(matrix));
163 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000164}
165
166void DrawBitmapMatrix::execute(SkCanvas* canvas) {
167 canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint);
168}
169
170DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
171 const SkRect& dst, const SkPaint* paint) {
172 this->fBitmap = &bitmap;
173 this->fCenter = &center;
174 this->fDst = &dst;
175 this->fPaint = paint;
176 this->fDrawType = DRAW_BITMAP_NINE;
177
chudy@google.com97cee972012-08-07 20:41:37 +0000178 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
179 this->fInfo.push(SkObjectParser::IRectToString(center));
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000180 this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000181 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000182}
183
184void DrawBitmapNine::execute(SkCanvas* canvas) {
185 canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint);
186}
187
reed@google.com71121732012-09-18 15:14:33 +0000188DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
chudy@google.com902ebe52012-06-29 14:21:22 +0000189 const SkRect& dst, const SkPaint* paint) {
190 this->fBitmap = &bitmap;
191 this->fSrc = src;
192 this->fDst = &dst;
193 this->fPaint = paint;
robertphillips@google.com84d320e2012-09-20 19:09:17 +0000194 this->fDrawType = DRAW_BITMAP_RECT_TO_RECT;
chudy@google.com902ebe52012-06-29 14:21:22 +0000195
chudy@google.com97cee972012-08-07 20:41:37 +0000196 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000197 if (src) this->fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
198 this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000199 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000200}
201
202void DrawBitmapRect::execute(SkCanvas* canvas) {
robertphillips@google.com84d320e2012-09-20 19:09:17 +0000203 canvas->drawBitmapRectToRect(*this->fBitmap, this->fSrc, *this->fDst, this->fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000204}
205
206DrawData::DrawData(const void* data, size_t length) {
207 this->fData = data;
208 this->fLength = length;
209 this->fDrawType = DRAW_DATA;
210 // TODO(chudy): See if we can't display data and length.
211}
212
213void DrawData::execute(SkCanvas* canvas) {
214 canvas->drawData(this->fData, this->fLength);
215}
216
217DrawPaint::DrawPaint(const SkPaint& paint) {
218 this->fPaint = &paint;
219 this->fDrawType = DRAW_PAINT;
220
chudy@google.com97cee972012-08-07 20:41:37 +0000221 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000222}
223
224void DrawPaint::execute(SkCanvas* canvas) {
225 canvas->drawPaint(*this->fPaint);
226}
227
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000228DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000229 this->fPath = &path;
230 this->fPaint = &paint;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000231 this->fBitmap = bitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000232 this->fDrawType = DRAW_PATH;
233
chudy@google.com97cee972012-08-07 20:41:37 +0000234 this->fInfo.push(SkObjectParser::PathToString(path));
235 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000236}
237
238void DrawPath::execute(SkCanvas* canvas) {
239 canvas->drawPath(*this->fPath, *this->fPaint);
240}
241
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000242const SkBitmap* DrawPath::getBitmap() const {
243 return &fBitmap;
244}
245
chudy@google.com902ebe52012-06-29 14:21:22 +0000246DrawPicture::DrawPicture(SkPicture& picture) {
247 this->fPicture = &picture;
248 this->fDrawType = DRAW_PICTURE;
chudy@google.com97cee972012-08-07 20:41:37 +0000249 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
chudy@google.com902ebe52012-06-29 14:21:22 +0000250}
251
252void DrawPicture::execute(SkCanvas* canvas) {
253 canvas->drawPicture(*this->fPicture);
254}
255
256DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
257 const SkPoint pts[], const SkPaint& paint) {
258 this->fMode = mode;
259 this->fCount = count;
260 this->fPts = pts;
261 this->fPaint = &paint;
262 this->fDrawType = DRAW_POINTS;
263
chudy@google.com97cee972012-08-07 20:41:37 +0000264 this->fInfo.push(SkObjectParser::PointsToString(pts, count));
skia.committer@gmail.com04ba4482012-09-07 02:01:30 +0000265 this->fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar(count),
robertphillips@google.com94acc702012-09-06 18:43:21 +0000266 "Points: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000267 this->fInfo.push(SkObjectParser::PointModeToString(mode));
chudy@google.com902ebe52012-06-29 14:21:22 +0000268}
269
270void DrawPoints::execute(SkCanvas* canvas) {
271 canvas->drawPoints(this->fMode, this->fCount, this->fPts, *this->fPaint);
272}
273
274DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
275 const SkPaint& paint) {
276 this->fText = text;
277 this->fByteLength = byteLength;
278 this->fPos = pos;
279 this->fPaint = &paint;
280 this->fDrawType = DRAW_POS_TEXT;
281
chudy@google.com97cee972012-08-07 20:41:37 +0000282 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
chudy@google.com902ebe52012-06-29 14:21:22 +0000283 // TODO(chudy): Test that this works.
chudy@google.com97cee972012-08-07 20:41:37 +0000284 this->fInfo.push(SkObjectParser::PointsToString(pos, 1));
285 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000286}
287
288void DrawPosText::execute(SkCanvas* canvas) {
289 canvas->drawPosText(this->fText, this->fByteLength, this->fPos, *this->fPaint);
290}
291
292
293DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
294 const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
295 this->fText = text;
296 this->fByteLength = byteLength;
297 this->fXpos = xpos;
298 this->fConstY = constY;
299 this->fPaint = &paint;
300 this->fDrawType = DRAW_POS_TEXT_H;
301
chudy@google.com97cee972012-08-07 20:41:37 +0000302 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
303 this->fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
304 this->fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
305 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000306}
307
308void DrawPosTextH::execute(SkCanvas* canvas) {
309 canvas->drawPosTextH(this->fText, this->fByteLength, this->fXpos, this->fConstY,
310 *this->fPaint);
311}
312
313DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) {
314 this->fRect = ▭
315 this->fPaint = &paint;
316 this->fDrawType = DRAW_RECT;
317
chudy@google.com97cee972012-08-07 20:41:37 +0000318 this->fInfo.push(SkObjectParser::RectToString(rect));
319 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000320}
321
322void DrawRectC::execute(SkCanvas* canvas) {
323 canvas->drawRect(*this->fRect, *this->fPaint);
324}
325
326DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
327 const SkPaint* paint) {
328 this->fBitmap = &bitmap;
329 this->fLeft = left;
330 this->fTop = top;
331 this->fPaint = paint;
332 this->fDrawType = DRAW_SPRITE;
333
chudy@google.com97cee972012-08-07 20:41:37 +0000334 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
335 this->fInfo.push(SkObjectParser::IntToString(left, "Left: "));
336 this->fInfo.push(SkObjectParser::IntToString(top, "Top: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000337}
338
339void DrawSprite::execute(SkCanvas* canvas) {
340 canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
341}
342
343DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
344 const SkPaint& paint) {
345 this->fText = text;
346 this->fByteLength = byteLength;
347 this->fX = x;
348 this->fY = y;
349 this->fPaint = &paint;
350 this->fDrawType = DRAW_TEXT;
351
chudy@google.com97cee972012-08-07 20:41:37 +0000352 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
353 this->fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
354 this->fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
355 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000356}
357
358void DrawTextC::execute(SkCanvas* canvas) {
359 canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this->fPaint);
360}
361
362DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
363 const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) {
364 this->fText = text;
365 this->fByteLength = byteLength;
366 this->fPath = &path;
367 this->fMatrix = matrix;
368 this->fPaint = &paint;
369 this->fDrawType = DRAW_TEXT_ON_PATH;
370
chudy@google.com97cee972012-08-07 20:41:37 +0000371 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
372 this->fInfo.push(SkObjectParser::PathToString(path));
373 if (matrix) this->fInfo.push(SkObjectParser::MatrixToString(*matrix));
374 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000375}
376
377void DrawTextOnPath::execute(SkCanvas* canvas) {
378 canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath,
379 this->fMatrix, *this->fPaint);
380}
381
382DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
383 const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
384 SkXfermode* xfermode, const uint16_t indices[], int indexCount,
385 const SkPaint& paint) {
386 this->fVmode = vmode;
387 this->fVertexCount = vertexCount;
388 this->fTexs = texs;
389 this->fColors = colors;
390 this->fXfermode = xfermode;
391 this->fIndices = indices;
392 this->fIndexCount = indexCount;
393 this->fPaint = &paint;
394 this->fDrawType = DRAW_VERTICES;
395 // TODO(chudy)
chudy@google.com97cee972012-08-07 20:41:37 +0000396 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
chudy@google.com902ebe52012-06-29 14:21:22 +0000397}
398
399void DrawVertices::execute(SkCanvas* canvas) {
400 canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices,
401 this->fTexs, this->fColors, this->fXfermode, this->fIndices,
402 this->fIndexCount, *this->fPaint);
403}
404
405Restore::Restore() {
406 this->fDrawType = RESTORE;
chudy@google.com97cee972012-08-07 20:41:37 +0000407 this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000408}
409
410void Restore::execute(SkCanvas* canvas) {
411 canvas->restore();
412}
413
414Rotate::Rotate(SkScalar degrees) {
415 this->fDegrees = degrees;
416 this->fDrawType = ROTATE;
417
chudy@google.com97cee972012-08-07 20:41:37 +0000418 this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000419}
420
421void Rotate::execute(SkCanvas* canvas) {
422 canvas->rotate(this->fDegrees);
423}
424
425Save::Save(SkCanvas::SaveFlags flags) {
426 this->fFlags = flags;
427 this->fDrawType = SAVE;
chudy@google.com97cee972012-08-07 20:41:37 +0000428 this->fInfo.push(SkObjectParser::SaveFlagsToString(flags));
chudy@google.com902ebe52012-06-29 14:21:22 +0000429}
430
431void Save::execute(SkCanvas* canvas) {
432 canvas->save(this->fFlags);
433}
434
435SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint,
436 SkCanvas::SaveFlags flags) {
437 this->fBounds = bounds;
438 this->fPaint = paint;
439 this->fFlags = flags;
440 this->fDrawType = SAVE_LAYER;
441
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000442 if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000443 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
444 this->fInfo.push(SkObjectParser::SaveFlagsToString(flags));
chudy@google.com902ebe52012-06-29 14:21:22 +0000445}
446
447void SaveLayer::execute(SkCanvas* canvas) {
448 canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags);
449}
450
451Scale::Scale(SkScalar sx, SkScalar sy) {
452 this->fSx = sx;
453 this->fSy = sy;
454 this->fDrawType = SCALE;
455
chudy@google.com97cee972012-08-07 20:41:37 +0000456 this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
457 this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000458}
459
460void Scale::execute(SkCanvas* canvas) {
461 canvas->scale(this->fSx, this->fSy);
462}
463
464SetMatrix::SetMatrix(const SkMatrix& matrix) {
465 this->fMatrix = &matrix;
466 this->fDrawType = SET_MATRIX;
467
chudy@google.com97cee972012-08-07 20:41:37 +0000468 this->fInfo.push(SkObjectParser::MatrixToString(matrix));
chudy@google.com902ebe52012-06-29 14:21:22 +0000469}
470
471void SetMatrix::execute(SkCanvas* canvas) {
472 canvas->setMatrix(*this->fMatrix);
473}
474
475Skew::Skew(SkScalar sx, SkScalar sy) {
476 this->fSx = sx;
477 this->fSy = sy;
478 this->fDrawType = SKEW;
479
chudy@google.com97cee972012-08-07 20:41:37 +0000480 this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
481 this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000482}
483
484void Skew::execute(SkCanvas* canvas) {
485 canvas->skew(this->fSx, this->fSy);
486}
487
488Translate::Translate(SkScalar dx, SkScalar dy) {
489 this->fDx = dx;
490 this->fDy = dy;
491 this->fDrawType = TRANSLATE;
492
chudy@google.com97cee972012-08-07 20:41:37 +0000493 this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
494 this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000495}
496
497void Translate::execute(SkCanvas* canvas) {
498 canvas->translate(this->fDx, this->fDy);
499}