blob: 322be7bc829a47aa5ce50e7b6008bcc04874ed6e [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,
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000138 const SkPaint* paint, SkBitmap& resizedBitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000139 this->fBitmap = &bitmap;
140 this->fLeft = left;
141 this->fTop = top;
142 this->fPaint = paint;
143 this->fDrawType = DRAW_BITMAP;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000144 this->fResizedBitmap = resizedBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000145
chudy@google.com97cee972012-08-07 20:41:37 +0000146 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
147 this->fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
148 this->fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000149}
150
151void DrawBitmap::execute(SkCanvas* canvas) {
152 canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
153}
154
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000155const SkBitmap* DrawBitmap::getBitmap() const {
156 return &fResizedBitmap;
157}
158
chudy@google.com902ebe52012-06-29 14:21:22 +0000159DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap,
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000160 const SkMatrix& matrix, const SkPaint* paint, SkBitmap& resizedBitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000161 this->fBitmap = &bitmap;
162 this->fMatrix = &matrix;
163 this->fPaint = paint;
164 this->fDrawType = DRAW_BITMAP_MATRIX;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000165 this->fResizedBitmap = resizedBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000166
chudy@google.com97cee972012-08-07 20:41:37 +0000167 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
168 this->fInfo.push(SkObjectParser::MatrixToString(matrix));
169 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000170}
171
172void DrawBitmapMatrix::execute(SkCanvas* canvas) {
173 canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint);
174}
175
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000176const SkBitmap* DrawBitmapMatrix::getBitmap() const {
177 return &fResizedBitmap;
178}
179
chudy@google.com902ebe52012-06-29 14:21:22 +0000180DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000181 const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000182 this->fBitmap = &bitmap;
183 this->fCenter = &center;
184 this->fDst = &dst;
185 this->fPaint = paint;
186 this->fDrawType = DRAW_BITMAP_NINE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000187 this->fResizedBitmap = resizedBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000188
chudy@google.com97cee972012-08-07 20:41:37 +0000189 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
190 this->fInfo.push(SkObjectParser::IRectToString(center));
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000191 this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000192 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000193}
194
195void DrawBitmapNine::execute(SkCanvas* canvas) {
196 canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint);
197}
198
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000199const SkBitmap* DrawBitmapNine::getBitmap() const {
200 return &fResizedBitmap;
201}
202
reed@google.com71121732012-09-18 15:14:33 +0000203DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000204 const SkRect& dst, const SkPaint* paint, SkBitmap& resizedBitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000205 this->fBitmap = &bitmap;
206 this->fSrc = src;
207 this->fDst = &dst;
208 this->fPaint = paint;
robertphillips@google.com84d320e2012-09-20 19:09:17 +0000209 this->fDrawType = DRAW_BITMAP_RECT_TO_RECT;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000210 this->fResizedBitmap = resizedBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000211
chudy@google.com97cee972012-08-07 20:41:37 +0000212 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000213 if (src) this->fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
214 this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000215 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000216}
217
218void DrawBitmapRect::execute(SkCanvas* canvas) {
robertphillips@google.com84d320e2012-09-20 19:09:17 +0000219 canvas->drawBitmapRectToRect(*this->fBitmap, this->fSrc, *this->fDst, this->fPaint);
chudy@google.com902ebe52012-06-29 14:21:22 +0000220}
221
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000222const SkBitmap* DrawBitmapRect::getBitmap() const {
223 return &fResizedBitmap;
224}
225
chudy@google.com902ebe52012-06-29 14:21:22 +0000226DrawData::DrawData(const void* data, size_t length) {
227 this->fData = data;
228 this->fLength = length;
229 this->fDrawType = DRAW_DATA;
230 // TODO(chudy): See if we can't display data and length.
231}
232
233void DrawData::execute(SkCanvas* canvas) {
234 canvas->drawData(this->fData, this->fLength);
235}
236
237DrawPaint::DrawPaint(const SkPaint& paint) {
238 this->fPaint = &paint;
239 this->fDrawType = DRAW_PAINT;
240
chudy@google.com97cee972012-08-07 20:41:37 +0000241 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000242}
243
244void DrawPaint::execute(SkCanvas* canvas) {
245 canvas->drawPaint(*this->fPaint);
246}
247
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000248DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000249 this->fPath = &path;
250 this->fPaint = &paint;
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000251 this->fBitmap = bitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000252 this->fDrawType = DRAW_PATH;
253
chudy@google.com97cee972012-08-07 20:41:37 +0000254 this->fInfo.push(SkObjectParser::PathToString(path));
255 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000256}
257
258void DrawPath::execute(SkCanvas* canvas) {
259 canvas->drawPath(*this->fPath, *this->fPaint);
260}
261
robertphillips@google.com6dec8fc2012-11-21 17:11:02 +0000262const SkBitmap* DrawPath::getBitmap() const {
263 return &fBitmap;
264}
265
chudy@google.com902ebe52012-06-29 14:21:22 +0000266DrawPicture::DrawPicture(SkPicture& picture) {
267 this->fPicture = &picture;
268 this->fDrawType = DRAW_PICTURE;
chudy@google.com97cee972012-08-07 20:41:37 +0000269 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
chudy@google.com902ebe52012-06-29 14:21:22 +0000270}
271
272void DrawPicture::execute(SkCanvas* canvas) {
273 canvas->drawPicture(*this->fPicture);
274}
275
276DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count,
277 const SkPoint pts[], const SkPaint& paint) {
278 this->fMode = mode;
279 this->fCount = count;
280 this->fPts = pts;
281 this->fPaint = &paint;
282 this->fDrawType = DRAW_POINTS;
283
chudy@google.com97cee972012-08-07 20:41:37 +0000284 this->fInfo.push(SkObjectParser::PointsToString(pts, count));
skia.committer@gmail.com04ba4482012-09-07 02:01:30 +0000285 this->fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar(count),
robertphillips@google.com94acc702012-09-06 18:43:21 +0000286 "Points: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000287 this->fInfo.push(SkObjectParser::PointModeToString(mode));
chudy@google.com902ebe52012-06-29 14:21:22 +0000288}
289
290void DrawPoints::execute(SkCanvas* canvas) {
291 canvas->drawPoints(this->fMode, this->fCount, this->fPts, *this->fPaint);
292}
293
294DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
295 const SkPaint& paint) {
296 this->fText = text;
297 this->fByteLength = byteLength;
298 this->fPos = pos;
299 this->fPaint = &paint;
300 this->fDrawType = DRAW_POS_TEXT;
301
chudy@google.com97cee972012-08-07 20:41:37 +0000302 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
chudy@google.com902ebe52012-06-29 14:21:22 +0000303 // TODO(chudy): Test that this works.
chudy@google.com97cee972012-08-07 20:41:37 +0000304 this->fInfo.push(SkObjectParser::PointsToString(pos, 1));
305 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000306}
307
308void DrawPosText::execute(SkCanvas* canvas) {
309 canvas->drawPosText(this->fText, this->fByteLength, this->fPos, *this->fPaint);
310}
311
312
313DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength,
314 const SkScalar xpos[], SkScalar constY, const SkPaint& paint) {
315 this->fText = text;
316 this->fByteLength = byteLength;
317 this->fXpos = xpos;
318 this->fConstY = constY;
319 this->fPaint = &paint;
320 this->fDrawType = DRAW_POS_TEXT_H;
321
chudy@google.com97cee972012-08-07 20:41:37 +0000322 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
323 this->fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
324 this->fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
325 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000326}
327
328void DrawPosTextH::execute(SkCanvas* canvas) {
329 canvas->drawPosTextH(this->fText, this->fByteLength, this->fXpos, this->fConstY,
330 *this->fPaint);
331}
332
333DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) {
334 this->fRect = ▭
335 this->fPaint = &paint;
336 this->fDrawType = DRAW_RECT;
337
chudy@google.com97cee972012-08-07 20:41:37 +0000338 this->fInfo.push(SkObjectParser::RectToString(rect));
339 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000340}
341
342void DrawRectC::execute(SkCanvas* canvas) {
343 canvas->drawRect(*this->fRect, *this->fPaint);
344}
345
346DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top,
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000347 const SkPaint* paint, SkBitmap& resizedBitmap) {
chudy@google.com902ebe52012-06-29 14:21:22 +0000348 this->fBitmap = &bitmap;
349 this->fLeft = left;
350 this->fTop = top;
351 this->fPaint = paint;
352 this->fDrawType = DRAW_SPRITE;
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000353 this->fResizedBitmap = resizedBitmap;
chudy@google.com902ebe52012-06-29 14:21:22 +0000354
chudy@google.com97cee972012-08-07 20:41:37 +0000355 this->fInfo.push(SkObjectParser::BitmapToString(bitmap));
356 this->fInfo.push(SkObjectParser::IntToString(left, "Left: "));
357 this->fInfo.push(SkObjectParser::IntToString(top, "Top: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000358}
359
360void DrawSprite::execute(SkCanvas* canvas) {
361 canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint);
362}
363
robertphillips@google.com53ec73d2012-11-26 13:09:17 +0000364const SkBitmap* DrawSprite::getBitmap() const {
365 return &fResizedBitmap;
366}
367
chudy@google.com902ebe52012-06-29 14:21:22 +0000368DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y,
369 const SkPaint& paint) {
370 this->fText = text;
371 this->fByteLength = byteLength;
372 this->fX = x;
373 this->fY = y;
374 this->fPaint = &paint;
375 this->fDrawType = DRAW_TEXT;
376
chudy@google.com97cee972012-08-07 20:41:37 +0000377 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
378 this->fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
379 this->fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
380 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000381}
382
383void DrawTextC::execute(SkCanvas* canvas) {
384 canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this->fPaint);
385}
386
387DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength,
388 const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) {
389 this->fText = text;
390 this->fByteLength = byteLength;
391 this->fPath = &path;
392 this->fMatrix = matrix;
393 this->fPaint = &paint;
394 this->fDrawType = DRAW_TEXT_ON_PATH;
395
chudy@google.com97cee972012-08-07 20:41:37 +0000396 this->fInfo.push(SkObjectParser::TextToString(text, byteLength));
397 this->fInfo.push(SkObjectParser::PathToString(path));
398 if (matrix) this->fInfo.push(SkObjectParser::MatrixToString(*matrix));
399 this->fInfo.push(SkObjectParser::PaintToString(paint));
chudy@google.com902ebe52012-06-29 14:21:22 +0000400}
401
402void DrawTextOnPath::execute(SkCanvas* canvas) {
403 canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath,
404 this->fMatrix, *this->fPaint);
405}
406
407DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount,
408 const SkPoint vertices[], const SkPoint texs[], const SkColor colors[],
409 SkXfermode* xfermode, const uint16_t indices[], int indexCount,
410 const SkPaint& paint) {
411 this->fVmode = vmode;
412 this->fVertexCount = vertexCount;
413 this->fTexs = texs;
414 this->fColors = colors;
415 this->fXfermode = xfermode;
416 this->fIndices = indices;
417 this->fIndexCount = indexCount;
418 this->fPaint = &paint;
419 this->fDrawType = DRAW_VERTICES;
420 // TODO(chudy)
chudy@google.com97cee972012-08-07 20:41:37 +0000421 this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
chudy@google.com902ebe52012-06-29 14:21:22 +0000422}
423
424void DrawVertices::execute(SkCanvas* canvas) {
425 canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices,
426 this->fTexs, this->fColors, this->fXfermode, this->fIndices,
427 this->fIndexCount, *this->fPaint);
428}
429
430Restore::Restore() {
431 this->fDrawType = RESTORE;
chudy@google.com97cee972012-08-07 20:41:37 +0000432 this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
chudy@google.com902ebe52012-06-29 14:21:22 +0000433}
434
435void Restore::execute(SkCanvas* canvas) {
436 canvas->restore();
437}
438
tomhudson@google.com0699e022012-11-27 16:09:42 +0000439void Restore::trackSaveState(int* state) {
440 (*state)--;
441}
442
chudy@google.com902ebe52012-06-29 14:21:22 +0000443Rotate::Rotate(SkScalar degrees) {
444 this->fDegrees = degrees;
445 this->fDrawType = ROTATE;
446
chudy@google.com97cee972012-08-07 20:41:37 +0000447 this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000448}
449
450void Rotate::execute(SkCanvas* canvas) {
451 canvas->rotate(this->fDegrees);
452}
453
454Save::Save(SkCanvas::SaveFlags flags) {
455 this->fFlags = flags;
456 this->fDrawType = SAVE;
chudy@google.com97cee972012-08-07 20:41:37 +0000457 this->fInfo.push(SkObjectParser::SaveFlagsToString(flags));
chudy@google.com902ebe52012-06-29 14:21:22 +0000458}
459
460void Save::execute(SkCanvas* canvas) {
461 canvas->save(this->fFlags);
462}
463
tomhudson@google.com0699e022012-11-27 16:09:42 +0000464void Save::trackSaveState(int* state) {
465 (*state)++;
466}
467
chudy@google.com902ebe52012-06-29 14:21:22 +0000468SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint,
469 SkCanvas::SaveFlags flags) {
470 this->fBounds = bounds;
471 this->fPaint = paint;
472 this->fFlags = flags;
473 this->fDrawType = SAVE_LAYER;
474
robertphillips@google.com30d35f22012-11-06 16:45:36 +0000475 if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
chudy@google.com97cee972012-08-07 20:41:37 +0000476 if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint));
477 this->fInfo.push(SkObjectParser::SaveFlagsToString(flags));
chudy@google.com902ebe52012-06-29 14:21:22 +0000478}
479
480void SaveLayer::execute(SkCanvas* canvas) {
481 canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags);
482}
483
tomhudson@google.com0699e022012-11-27 16:09:42 +0000484void SaveLayer::trackSaveState(int* state) {
485 (*state)++;
486}
487
chudy@google.com902ebe52012-06-29 14:21:22 +0000488Scale::Scale(SkScalar sx, SkScalar sy) {
489 this->fSx = sx;
490 this->fSy = sy;
491 this->fDrawType = SCALE;
492
chudy@google.com97cee972012-08-07 20:41:37 +0000493 this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
494 this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000495}
496
497void Scale::execute(SkCanvas* canvas) {
498 canvas->scale(this->fSx, this->fSy);
499}
500
501SetMatrix::SetMatrix(const SkMatrix& matrix) {
502 this->fMatrix = &matrix;
503 this->fDrawType = SET_MATRIX;
504
chudy@google.com97cee972012-08-07 20:41:37 +0000505 this->fInfo.push(SkObjectParser::MatrixToString(matrix));
chudy@google.com902ebe52012-06-29 14:21:22 +0000506}
507
508void SetMatrix::execute(SkCanvas* canvas) {
509 canvas->setMatrix(*this->fMatrix);
510}
511
512Skew::Skew(SkScalar sx, SkScalar sy) {
513 this->fSx = sx;
514 this->fSy = sy;
515 this->fDrawType = SKEW;
516
chudy@google.com97cee972012-08-07 20:41:37 +0000517 this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
518 this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000519}
520
521void Skew::execute(SkCanvas* canvas) {
522 canvas->skew(this->fSx, this->fSy);
523}
524
525Translate::Translate(SkScalar dx, SkScalar dy) {
526 this->fDx = dx;
527 this->fDy = dy;
528 this->fDrawType = TRANSLATE;
529
chudy@google.com97cee972012-08-07 20:41:37 +0000530 this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
531 this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
chudy@google.com902ebe52012-06-29 14:21:22 +0000532}
533
534void Translate::execute(SkCanvas* canvas) {
535 canvas->translate(this->fDx, this->fDy);
536}