3 * Copyright 2012 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 #include "SkDrawCommand.h"
11 #include "SkObjectParser.h"
13 // TODO(chudy): Refactor into non subclass model.
15 SkDrawCommand::SkDrawCommand(DrawType type)
20 SkDrawCommand::SkDrawCommand() {
24 SkDrawCommand::~SkDrawCommand() {
28 const char* SkDrawCommand::GetCommandString(DrawType 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";
35 case CLIP_RRECT: return "Clip RRect";
36 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";
40 case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect";
41 case DRAW_DATA: return "Draw Data";
42 case DRAW_OVAL: return "Draw Oval";
43 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";
50 case DRAW_RRECT: return "Draw RRect";
51 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";
63 case NOOP: return "NoOp";
64 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup";
65 case COMMENT: return "Comment";
66 case END_COMMENT_GROUP: return "EndCommentGroup";
68 SkDebugf("DrawType error 0x%08x\n", type);
72 SkDEBUGFAIL("DrawType UNUSED\n");
76 SkString SkDrawCommand::toString() {
77 return SkString(GetCommandString(fDrawType));
80 SkClearCommand::SkClearCommand(SkColor color) {
82 fDrawType = DRAW_CLEAR;
83 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
86 void SkClearCommand::execute(SkCanvas* canvas) {
87 canvas->clear(fColor);
92 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) {
93 const SkISize& size = canvas->getDeviceSize();
95 static const SkScalar kInsetFrac = 0.9f; // Leave a border around object
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()));
102 canvas->scale(SkDoubleToScalar((kInsetFrac*size.fWidth)/bounds.height()),
103 SkDoubleToScalar((kInsetFrac*size.fHeight)/bounds.height()));
105 canvas->translate(-bounds.centerX(), -bounds.centerY());
109 void render_path(SkCanvas* canvas, const SkPath& path) {
110 canvas->clear(0xFFFFFFFF);
113 const SkRect& bounds = path.getBounds();
115 xlate_and_scale_to_bounds(canvas, bounds);
118 p.setColor(SK_ColorBLACK);
119 p.setStyle(SkPaint::kStroke_Style);
121 canvas->drawPath(path, p);
125 void render_bitmap(SkCanvas* canvas, const SkBitmap& input, const SkRect* srcRect = NULL) {
126 const SkISize& size = canvas->getDeviceSize();
128 SkScalar xScale = SkIntToScalar(size.fWidth-2) / input.width();
129 SkScalar yScale = SkIntToScalar(size.fHeight-2) / input.height();
131 if (input.width() > input.height()) {
132 yScale *= input.height() / (float) input.width();
134 xScale *= input.width() / (float) input.height();
137 SkRect dst = SkRect::MakeXYWH(SK_Scalar1, SK_Scalar1,
138 xScale * input.width(),
139 yScale * input.height());
141 canvas->clear(0xFFFFFFFF);
142 canvas->drawBitmapRect(input, NULL, dst);
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);
150 p.setColor(SK_ColorRED);
151 p.setStyle(SkPaint::kStroke_Style);
153 canvas->drawRect(r, p);
157 void render_rrect(SkCanvas* canvas, const SkRRect& rrect) {
158 canvas->clear(0xFFFFFFFF);
161 const SkRect& bounds = rrect.getBounds();
163 xlate_and_scale_to_bounds(canvas, bounds);
166 p.setColor(SK_ColorBLACK);
167 p.setStyle(SkPaint::kStroke_Style);
169 canvas->drawRRect(rrect, p);
176 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA) {
180 fDrawType = CLIP_PATH;
182 fInfo.push(SkObjectParser::PathToString(path));
183 fInfo.push(SkObjectParser::RegionOpToString(op));
184 fInfo.push(SkObjectParser::BoolToString(doAA));
187 void SkClipPathCommand::execute(SkCanvas* canvas) {
188 canvas->clipPath(fPath, fOp, fDoAA);
191 bool SkClipPathCommand::render(SkCanvas* canvas) const {
192 render_path(canvas, fPath);
196 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op) {
199 fDrawType = CLIP_REGION;
201 fInfo.push(SkObjectParser::RegionToString(region));
202 fInfo.push(SkObjectParser::RegionOpToString(op));
205 void SkClipRegionCommand::execute(SkCanvas* canvas) {
206 canvas->clipRegion(fRegion, fOp);
209 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA) {
213 fDrawType = CLIP_RECT;
215 fInfo.push(SkObjectParser::RectToString(rect));
216 fInfo.push(SkObjectParser::RegionOpToString(op));
217 fInfo.push(SkObjectParser::BoolToString(doAA));
220 void SkClipRectCommand::execute(SkCanvas* canvas) {
221 canvas->clipRect(fRect, fOp, fDoAA);
224 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA) {
228 fDrawType = CLIP_RRECT;
230 fInfo.push(SkObjectParser::RRectToString(rrect));
231 fInfo.push(SkObjectParser::RegionOpToString(op));
232 fInfo.push(SkObjectParser::BoolToString(doAA));
235 void SkClipRRectCommand::execute(SkCanvas* canvas) {
236 canvas->clipRRect(fRRect, fOp, fDoAA);
239 bool SkClipRRectCommand::render(SkCanvas* canvas) const {
240 render_rrect(canvas, fRRect);
244 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) {
248 fInfo.push(SkObjectParser::MatrixToString(matrix));
251 void SkConcatCommand::execute(SkCanvas* canvas) {
252 canvas->concat(fMatrix);
255 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top,
256 const SkPaint* paint) {
266 fDrawType = DRAW_BITMAP;
268 fInfo.push(SkObjectParser::BitmapToString(bitmap));
269 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: "));
270 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: "));
272 fInfo.push(SkObjectParser::PaintToString(*paint));
276 void SkDrawBitmapCommand::execute(SkCanvas* canvas) {
277 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr);
280 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const {
281 render_bitmap(canvas, fBitmap);
285 SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap,
286 const SkMatrix& matrix,
287 const SkPaint* paint) {
296 fDrawType = DRAW_BITMAP_MATRIX;
298 fInfo.push(SkObjectParser::BitmapToString(bitmap));
299 fInfo.push(SkObjectParser::MatrixToString(matrix));
301 fInfo.push(SkObjectParser::PaintToString(*paint));
305 void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) {
306 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr);
309 bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const {
310 render_bitmap(canvas, fBitmap);
314 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center,
315 const SkRect& dst, const SkPaint* paint) {
325 fDrawType = DRAW_BITMAP_NINE;
327 fInfo.push(SkObjectParser::BitmapToString(bitmap));
328 fInfo.push(SkObjectParser::IRectToString(center));
329 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
331 fInfo.push(SkObjectParser::PaintToString(*paint));
335 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) {
336 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr);
339 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const {
340 render_bitmap(canvas, fBitmap);
344 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src,
345 const SkRect& dst, const SkPaint* paint,
346 SkCanvas::DrawBitmapRectFlags flags) {
363 fDrawType = DRAW_BITMAP_RECT_TO_RECT;
365 fInfo.push(SkObjectParser::BitmapToString(bitmap));
367 fInfo.push(SkObjectParser::RectToString(*src, "Src: "));
369 fInfo.push(SkObjectParser::RectToString(dst, "Dst: "));
371 fInfo.push(SkObjectParser::PaintToString(*paint));
373 fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: "));
376 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) {
377 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFlags);
380 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
381 render_bitmap(canvas, fBitmap, this->srcRect());
385 SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length) {
386 fData = new char[length];
387 memcpy(fData, data, length);
389 fDrawType = DRAW_DATA;
391 // TODO: add display of actual data?
392 SkString* str = new SkString;
393 str->appendf("length: %d", (int) length);
397 void SkDrawDataCommand::execute(SkCanvas* canvas) {
398 canvas->drawData(fData, fLength);
401 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
402 : INHERITED(BEGIN_COMMENT_GROUP)
403 , fDescription(description) {
404 SkString* temp = new SkString;
405 temp->appendf("Description: %s", description);
409 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value)
413 SkString* temp = new SkString;
414 temp->appendf("%s: %s", kywd, value);
418 SkEndCommentGroupCommand::SkEndCommentGroupCommand() : INHERITED(END_COMMENT_GROUP) {
421 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) {
424 fDrawType = DRAW_OVAL;
426 fInfo.push(SkObjectParser::RectToString(oval));
427 fInfo.push(SkObjectParser::PaintToString(paint));
430 void SkDrawOvalCommand::execute(SkCanvas* canvas) {
431 canvas->drawOval(fOval, fPaint);
434 bool SkDrawOvalCommand::render(SkCanvas* canvas) const {
435 canvas->clear(0xFFFFFFFF);
438 xlate_and_scale_to_bounds(canvas, fOval);
441 p.setColor(SK_ColorBLACK);
442 p.setStyle(SkPaint::kStroke_Style);
444 canvas->drawOval(fOval, p);
450 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) {
452 fDrawType = DRAW_PAINT;
454 fInfo.push(SkObjectParser::PaintToString(paint));
457 void SkDrawPaintCommand::execute(SkCanvas* canvas) {
458 canvas->drawPaint(fPaint);
461 bool SkDrawPaintCommand::render(SkCanvas* canvas) const {
462 canvas->clear(0xFFFFFFFF);
463 canvas->drawPaint(fPaint);
467 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) {
470 fDrawType = DRAW_PATH;
472 fInfo.push(SkObjectParser::PathToString(path));
473 fInfo.push(SkObjectParser::PaintToString(paint));
476 void SkDrawPathCommand::execute(SkCanvas* canvas) {
477 canvas->drawPath(fPath, fPaint);
480 bool SkDrawPathCommand::render(SkCanvas* canvas) const {
481 render_path(canvas, fPath);
485 SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture) :
487 fDrawType = DRAW_PICTURE;
488 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
491 void SkDrawPictureCommand::execute(SkCanvas* canvas) {
492 canvas->drawPicture(fPicture);
495 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count,
496 const SkPoint pts[], const SkPaint& paint) {
499 fPts = new SkPoint[count];
500 memcpy(fPts, pts, count * sizeof(SkPoint));
502 fDrawType = DRAW_POINTS;
504 fInfo.push(SkObjectParser::PointsToString(pts, count));
505 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count),
507 fInfo.push(SkObjectParser::PointModeToString(mode));
508 fInfo.push(SkObjectParser::PaintToString(paint));
511 void SkDrawPointsCommand::execute(SkCanvas* canvas) {
512 canvas->drawPoints(fMode, fCount, fPts, fPaint);
515 bool SkDrawPointsCommand::render(SkCanvas* canvas) const {
516 canvas->clear(0xFFFFFFFF);
522 for (unsigned int i = 0; i < fCount; ++i) {
523 bounds.growToInclude(fPts[i].fX, fPts[i].fY);
526 xlate_and_scale_to_bounds(canvas, bounds);
529 p.setColor(SK_ColorBLACK);
530 p.setStyle(SkPaint::kStroke_Style);
532 canvas->drawPoints(fMode, fCount, fPts, p);
538 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength,
539 const SkPoint pos[], const SkPaint& paint) {
540 size_t numPts = paint.countText(text, byteLength);
542 fText = new char[byteLength];
543 memcpy(fText, text, byteLength);
544 fByteLength = byteLength;
546 fPos = new SkPoint[numPts];
547 memcpy(fPos, pos, numPts * sizeof(SkPoint));
550 fDrawType = DRAW_POS_TEXT;
552 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
553 // TODO(chudy): Test that this works.
554 fInfo.push(SkObjectParser::PointsToString(pos, 1));
555 fInfo.push(SkObjectParser::PaintToString(paint));
558 void SkDrawPosTextCommand::execute(SkCanvas* canvas) {
559 canvas->drawPosText(fText, fByteLength, fPos, fPaint);
563 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength,
564 const SkScalar xpos[], SkScalar constY,
565 const SkPaint& paint) {
566 size_t numPts = paint.countText(text, byteLength);
568 fText = new char[byteLength];
569 memcpy(fText, text, byteLength);
570 fByteLength = byteLength;
572 fXpos = new SkScalar[numPts];
573 memcpy(fXpos, xpos, numPts * sizeof(SkScalar));
577 fDrawType = DRAW_POS_TEXT_H;
579 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
580 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: "));
581 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: "));
582 fInfo.push(SkObjectParser::PaintToString(paint));
585 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) {
586 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint);
589 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) {
592 fDrawType = DRAW_RECT;
594 fInfo.push(SkObjectParser::RectToString(rect));
595 fInfo.push(SkObjectParser::PaintToString(paint));
598 void SkDrawRectCommand::execute(SkCanvas* canvas) {
599 canvas->drawRect(fRect, fPaint);
602 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint) {
605 fDrawType = DRAW_RRECT;
607 fInfo.push(SkObjectParser::RRectToString(rrect));
608 fInfo.push(SkObjectParser::PaintToString(paint));
611 void SkDrawRRectCommand::execute(SkCanvas* canvas) {
612 canvas->drawRRect(fRRect, fPaint);
615 bool SkDrawRRectCommand::render(SkCanvas* canvas) const {
616 render_rrect(canvas, fRRect);
620 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top,
621 const SkPaint* paint) {
631 fDrawType = DRAW_SPRITE;
633 fInfo.push(SkObjectParser::BitmapToString(bitmap));
634 fInfo.push(SkObjectParser::IntToString(left, "Left: "));
635 fInfo.push(SkObjectParser::IntToString(top, "Top: "));
637 fInfo.push(SkObjectParser::PaintToString(*paint));
641 void SkDrawSpriteCommand::execute(SkCanvas* canvas) {
642 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr);
645 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const {
646 render_bitmap(canvas, fBitmap);
650 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y,
651 const SkPaint& paint) {
652 fText = new char[byteLength];
653 memcpy(fText, text, byteLength);
654 fByteLength = byteLength;
658 fDrawType = DRAW_TEXT;
660 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
661 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: "));
662 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: "));
663 fInfo.push(SkObjectParser::PaintToString(paint));
666 void SkDrawTextCommand::execute(SkCanvas* canvas) {
667 canvas->drawText(fText, fByteLength, fX, fY, fPaint);
670 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength,
671 const SkPath& path, const SkMatrix* matrix,
672 const SkPaint& paint) {
673 fText = new char[byteLength];
674 memcpy(fText, text, byteLength);
675 fByteLength = byteLength;
677 if (NULL != matrix) {
680 fMatrix.setIdentity();
683 fDrawType = DRAW_TEXT_ON_PATH;
685 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding()));
686 fInfo.push(SkObjectParser::PathToString(path));
687 if (NULL != matrix) {
688 fInfo.push(SkObjectParser::MatrixToString(*matrix));
690 fInfo.push(SkObjectParser::PaintToString(paint));
693 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) {
694 canvas->drawTextOnPath(fText, fByteLength, fPath,
695 fMatrix.isIdentity() ? NULL : &fMatrix,
699 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int vertexCount,
700 const SkPoint vertices[], const SkPoint texs[],
701 const SkColor colors[], SkXfermode* xfermode,
702 const uint16_t indices[], int indexCount,
703 const SkPaint& paint) {
706 fVertexCount = vertexCount;
708 fVertices = new SkPoint[vertexCount];
709 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint));
712 fTexs = new SkPoint[vertexCount];
713 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint));
718 if (NULL != colors) {
719 fColors = new SkColor[vertexCount];
720 memcpy(fColors, colors, vertexCount * sizeof(SkColor));
725 fXfermode = xfermode;
726 if (NULL != fXfermode) {
730 if (indexCount > 0) {
731 fIndices = new uint16_t[indexCount];
732 memcpy(fIndices, indices, indexCount * sizeof(uint16_t));
737 fIndexCount = indexCount;
739 fDrawType = DRAW_VERTICES;
742 fInfo.push(SkObjectParser::CustomTextToString("To be implemented."));
743 fInfo.push(SkObjectParser::PaintToString(paint));
746 SkDrawVerticesCommand::~SkDrawVerticesCommand() {
750 SkSafeUnref(fXfermode);
754 void SkDrawVerticesCommand::execute(SkCanvas* canvas) {
755 canvas->drawVertices(fVmode, fVertexCount, fVertices,
756 fTexs, fColors, fXfermode, fIndices,
757 fIndexCount, fPaint);
760 SkRestoreCommand::SkRestoreCommand() {
762 fInfo.push(SkObjectParser::CustomTextToString("No Parameters"));
765 void SkRestoreCommand::execute(SkCanvas* canvas) {
769 void SkRestoreCommand::trackSaveState(int* state) {
773 SkRotateCommand::SkRotateCommand(SkScalar degrees) {
777 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: "));
780 void SkRotateCommand::execute(SkCanvas* canvas) {
781 canvas->rotate(fDegrees);
784 SkSaveCommand::SkSaveCommand(SkCanvas::SaveFlags flags) {
787 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
790 void SkSaveCommand::execute(SkCanvas* canvas) {
791 canvas->save(fFlags);
794 void SkSaveCommand::trackSaveState(int* state) {
798 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint,
799 SkCanvas::SaveFlags flags) {
800 if (NULL != bounds) {
813 fDrawType = SAVE_LAYER;
815 if (NULL != bounds) {
816 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: "));
819 fInfo.push(SkObjectParser::PaintToString(*paint));
821 fInfo.push(SkObjectParser::SaveFlagsToString(flags));
824 void SkSaveLayerCommand::execute(SkCanvas* canvas) {
825 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds,
830 void SkSaveLayerCommand::trackSaveState(int* state) {
834 SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) {
839 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
840 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
843 void SkScaleCommand::execute(SkCanvas* canvas) {
844 canvas->scale(fSx, fSy);
847 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) {
849 fDrawType = SET_MATRIX;
851 fInfo.push(SkObjectParser::MatrixToString(matrix));
854 void SkSetMatrixCommand::execute(SkCanvas* canvas) {
855 canvas->setMatrix(fMatrix);
858 SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) {
863 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: "));
864 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: "));
867 void SkSkewCommand::execute(SkCanvas* canvas) {
868 canvas->skew(fSx, fSy);
871 SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) {
874 fDrawType = TRANSLATE;
876 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: "));
877 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: "));
880 void SkTranslateCommand::execute(SkCanvas* canvas) {
881 canvas->translate(fDx, fDy);