chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 1 | |
| 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.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 10 | #include "SkDrawCommand.h" |
| 11 | #include "SkObjectParser.h" |
| 12 | |
| 13 | // TODO(chudy): Refactor into non subclass model. |
| 14 | |
skia.committer@gmail.com | a5d3e77 | 2013-05-30 07:01:29 +0000 | [diff] [blame] | 15 | SkDrawCommand::SkDrawCommand(DrawType type) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 16 | : fDrawType(type) |
| 17 | , fVisible(true) { |
| 18 | } |
| 19 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 20 | SkDrawCommand::SkDrawCommand() { |
| 21 | fVisible = true; |
| 22 | } |
| 23 | |
| 24 | SkDrawCommand::~SkDrawCommand() { |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 25 | fInfo.deleteAll(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | const 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.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 35 | case CLIP_RRECT: return "Clip RRect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 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"; |
robertphillips@google.com | 84d320e | 2012-09-20 19:09:17 +0000 | [diff] [blame] | 40 | case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 41 | case DRAW_DATA: return "Draw Data"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 42 | case DRAW_OVAL: return "Draw Oval"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 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"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 50 | case DRAW_RRECT: return "Draw RRect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 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"; |
robertphillips@google.com | e4ce5b8 | 2013-02-15 17:19:15 +0000 | [diff] [blame] | 63 | case NOOP: return "NoOp"; |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 64 | case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; |
| 65 | case COMMENT: return "Comment"; |
| 66 | case END_COMMENT_GROUP: return "EndCommentGroup"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 67 | 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.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 76 | SkString SkDrawCommand::toString() { |
| 77 | return SkString(GetCommandString(fDrawType)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 78 | } |
| 79 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 80 | SkClearCommand::SkClearCommand(SkColor color) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 81 | fColor = color; |
| 82 | fDrawType = DRAW_CLEAR; |
| 83 | fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 84 | } |
| 85 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 86 | void SkClearCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 87 | canvas->clear(fColor); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 88 | } |
| 89 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 90 | namespace { |
| 91 | |
| 92 | void 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 | } |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 107 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 108 | |
| 109 | void 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 | |
| 125 | void 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()); |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 140 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 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 | |
| 157 | void 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 | } |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 172 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 173 | }; |
| 174 | |
| 175 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 176 | SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool doAA) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 177 | fPath = path; |
| 178 | fOp = op; |
| 179 | fDoAA = doAA; |
| 180 | fDrawType = CLIP_PATH; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 181 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 182 | fInfo.push(SkObjectParser::PathToString(path)); |
| 183 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 184 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 185 | } |
| 186 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 187 | void SkClipPathCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 188 | canvas->clipPath(fPath, fOp, fDoAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 189 | } |
| 190 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 191 | bool SkClipPathCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 192 | render_path(canvas, fPath); |
| 193 | return true; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 194 | } |
| 195 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 196 | SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 197 | fRegion = region; |
| 198 | fOp = op; |
| 199 | fDrawType = CLIP_REGION; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 200 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 201 | fInfo.push(SkObjectParser::RegionToString(region)); |
| 202 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 203 | } |
| 204 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 205 | void SkClipRegionCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 206 | canvas->clipRegion(fRegion, fOp); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 207 | } |
| 208 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 209 | SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool doAA) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 210 | fRect = rect; |
| 211 | fOp = op; |
| 212 | fDoAA = doAA; |
| 213 | fDrawType = CLIP_RECT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 214 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 215 | fInfo.push(SkObjectParser::RectToString(rect)); |
| 216 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 217 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 218 | } |
| 219 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 220 | void SkClipRectCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 221 | canvas->clipRect(fRect, fOp, fDoAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 222 | } |
| 223 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 224 | SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 225 | fRRect = rrect; |
| 226 | fOp = op; |
| 227 | fDoAA = doAA; |
| 228 | fDrawType = CLIP_RRECT; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 229 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 230 | fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 231 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 232 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 233 | } |
| 234 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 235 | void SkClipRRectCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 236 | canvas->clipRRect(fRRect, fOp, fDoAA); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 237 | } |
| 238 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 239 | bool SkClipRRectCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 240 | render_rrect(canvas, fRRect); |
| 241 | return true; |
| 242 | } |
| 243 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 244 | SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 245 | fMatrix = matrix; |
| 246 | fDrawType = CONCAT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 247 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 248 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 249 | } |
| 250 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 251 | void SkConcatCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 252 | canvas->concat(fMatrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 253 | } |
| 254 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 255 | SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 256 | const SkPaint* paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 257 | fBitmap = bitmap; |
| 258 | fLeft = left; |
| 259 | fTop = top; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 260 | if (NULL != paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 261 | fPaint = *paint; |
| 262 | fPaintPtr = &fPaint; |
| 263 | } else { |
| 264 | fPaintPtr = NULL; |
| 265 | } |
| 266 | fDrawType = DRAW_BITMAP; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 267 | |
| 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.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 273 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 274 | } |
| 275 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 276 | void SkDrawBitmapCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 277 | canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 278 | } |
| 279 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 280 | bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 281 | render_bitmap(canvas, fBitmap); |
| 282 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 283 | } |
| 284 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 285 | SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, |
| 286 | const SkMatrix& matrix, |
| 287 | const SkPaint* paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 288 | fBitmap = bitmap; |
| 289 | fMatrix = matrix; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 290 | if (NULL != paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 291 | fPaint = *paint; |
| 292 | fPaintPtr = &fPaint; |
| 293 | } else { |
| 294 | fPaintPtr = NULL; |
| 295 | } |
| 296 | fDrawType = DRAW_BITMAP_MATRIX; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 297 | |
| 298 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 299 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 300 | if (NULL != paint) { |
| 301 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 302 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 303 | } |
| 304 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 305 | void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 306 | canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 307 | } |
| 308 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 309 | bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 310 | render_bitmap(canvas, fBitmap); |
| 311 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 312 | } |
| 313 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 314 | SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const SkIRect& center, |
| 315 | const SkRect& dst, const SkPaint* paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 316 | fBitmap = bitmap; |
| 317 | fCenter = center; |
| 318 | fDst = dst; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 319 | if (NULL != paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 320 | fPaint = *paint; |
| 321 | fPaintPtr = &fPaint; |
| 322 | } else { |
| 323 | fPaintPtr = NULL; |
| 324 | } |
| 325 | fDrawType = DRAW_BITMAP_NINE; |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 326 | |
| 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.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 332 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 333 | } |
| 334 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 335 | void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 336 | canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 337 | } |
| 338 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 339 | bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 340 | render_bitmap(canvas, fBitmap); |
| 341 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 342 | } |
| 343 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 344 | SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const SkRect* src, |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame^] | 345 | const SkRect& dst, const SkPaint* paint, |
| 346 | SkCanvas::DrawBitmapRectFlags flags) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 347 | fBitmap = bitmap; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 348 | if (NULL != src) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 349 | fSrc = *src; |
| 350 | } else { |
| 351 | fSrc.setEmpty(); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 352 | } |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 353 | fDst = dst; |
| 354 | |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 355 | if (NULL != paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 356 | fPaint = *paint; |
| 357 | fPaintPtr = &fPaint; |
| 358 | } else { |
| 359 | fPaintPtr = NULL; |
| 360 | } |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame^] | 361 | fFlags = flags; |
| 362 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 363 | fDrawType = DRAW_BITMAP_RECT_TO_RECT; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 364 | |
| 365 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 366 | if (NULL != src) { |
| 367 | fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 368 | } |
| 369 | fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 370 | if (NULL != paint) { |
| 371 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 372 | } |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame^] | 373 | fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 374 | } |
| 375 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 376 | void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) { |
commit-bot@chromium.org | eed779d | 2013-08-16 10:24:37 +0000 | [diff] [blame^] | 377 | canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 378 | } |
| 379 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 380 | bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 381 | render_bitmap(canvas, fBitmap, this->srcRect()); |
| 382 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 383 | } |
| 384 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 385 | SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 386 | fData = new char[length]; |
| 387 | memcpy(fData, data, length); |
| 388 | fLength = length; |
| 389 | fDrawType = DRAW_DATA; |
| 390 | |
| 391 | // TODO: add display of actual data? |
| 392 | SkString* str = new SkString; |
robertphillips@google.com | 77279cb | 2013-03-25 12:01:45 +0000 | [diff] [blame] | 393 | str->appendf("length: %d", (int) length); |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 394 | fInfo.push(str); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 395 | } |
| 396 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 397 | void SkDrawDataCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 398 | canvas->drawData(fData, fLength); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 399 | } |
| 400 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 401 | SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 402 | : INHERITED(BEGIN_COMMENT_GROUP) |
| 403 | , fDescription(description) { |
| 404 | SkString* temp = new SkString; |
| 405 | temp->appendf("Description: %s", description); |
| 406 | fInfo.push(temp); |
| 407 | } |
| 408 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 409 | SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 410 | : INHERITED(COMMENT) |
| 411 | , fKywd(kywd) |
| 412 | , fValue(value) { |
| 413 | SkString* temp = new SkString; |
| 414 | temp->appendf("%s: %s", kywd, value); |
| 415 | fInfo.push(temp); |
| 416 | } |
| 417 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 418 | SkEndCommentGroupCommand::SkEndCommentGroupCommand() : INHERITED(END_COMMENT_GROUP) { |
robertphillips@google.com | 0a4805e | 2013-05-29 13:24:23 +0000 | [diff] [blame] | 419 | } |
| 420 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 421 | SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 422 | fOval = oval; |
| 423 | fPaint = paint; |
| 424 | fDrawType = DRAW_OVAL; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 425 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 426 | fInfo.push(SkObjectParser::RectToString(oval)); |
| 427 | fInfo.push(SkObjectParser::PaintToString(paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 428 | } |
| 429 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 430 | void SkDrawOvalCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 431 | canvas->drawOval(fOval, fPaint); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 432 | } |
| 433 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 434 | bool SkDrawOvalCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 435 | canvas->clear(0xFFFFFFFF); |
| 436 | canvas->save(); |
| 437 | |
| 438 | xlate_and_scale_to_bounds(canvas, fOval); |
| 439 | |
| 440 | SkPaint p; |
| 441 | p.setColor(SK_ColorBLACK); |
| 442 | p.setStyle(SkPaint::kStroke_Style); |
| 443 | |
| 444 | canvas->drawOval(fOval, p); |
| 445 | canvas->restore(); |
| 446 | |
| 447 | return true; |
| 448 | } |
| 449 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 450 | SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 451 | fPaint = paint; |
| 452 | fDrawType = DRAW_PAINT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 453 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 454 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 455 | } |
| 456 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 457 | void SkDrawPaintCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 458 | canvas->drawPaint(fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 459 | } |
| 460 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 461 | bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 462 | canvas->clear(0xFFFFFFFF); |
| 463 | canvas->drawPaint(fPaint); |
| 464 | return true; |
| 465 | } |
| 466 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 467 | SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 468 | fPath = path; |
| 469 | fPaint = paint; |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 470 | fDrawType = DRAW_PATH; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 471 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 472 | fInfo.push(SkObjectParser::PathToString(path)); |
| 473 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 474 | } |
| 475 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 476 | void SkDrawPathCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 477 | canvas->drawPath(fPath, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 478 | } |
| 479 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 480 | bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 481 | render_path(canvas, fPath); |
| 482 | return true; |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 483 | } |
| 484 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 485 | SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture) : |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 486 | fPicture(picture) { |
| 487 | fDrawType = DRAW_PICTURE; |
| 488 | fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 489 | } |
| 490 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 491 | void SkDrawPictureCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 492 | canvas->drawPicture(fPicture); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 493 | } |
| 494 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 495 | SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, |
| 496 | const SkPoint pts[], const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 497 | fMode = mode; |
| 498 | fCount = count; |
| 499 | fPts = new SkPoint[count]; |
| 500 | memcpy(fPts, pts, count * sizeof(SkPoint)); |
| 501 | fPaint = paint; |
| 502 | fDrawType = DRAW_POINTS; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 503 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 504 | fInfo.push(SkObjectParser::PointsToString(pts, count)); |
| 505 | fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count), |
| 506 | "Points: ")); |
| 507 | fInfo.push(SkObjectParser::PointModeToString(mode)); |
| 508 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 509 | } |
| 510 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 511 | void SkDrawPointsCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 512 | canvas->drawPoints(fMode, fCount, fPts, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 513 | } |
| 514 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 515 | bool SkDrawPointsCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 516 | canvas->clear(0xFFFFFFFF); |
| 517 | canvas->save(); |
| 518 | |
| 519 | SkRect bounds; |
| 520 | |
| 521 | bounds.setEmpty(); |
| 522 | for (unsigned int i = 0; i < fCount; ++i) { |
| 523 | bounds.growToInclude(fPts[i].fX, fPts[i].fY); |
| 524 | } |
skia.committer@gmail.com | a009083 | 2013-06-07 07:01:06 +0000 | [diff] [blame] | 525 | |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 526 | xlate_and_scale_to_bounds(canvas, bounds); |
| 527 | |
| 528 | SkPaint p; |
| 529 | p.setColor(SK_ColorBLACK); |
| 530 | p.setStyle(SkPaint::kStroke_Style); |
| 531 | |
| 532 | canvas->drawPoints(fMode, fCount, fPts, p); |
| 533 | canvas->restore(); |
| 534 | |
| 535 | return true; |
| 536 | } |
| 537 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 538 | SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, |
| 539 | const SkPoint pos[], const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 540 | size_t numPts = paint.countText(text, byteLength); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 541 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 542 | fText = new char[byteLength]; |
| 543 | memcpy(fText, text, byteLength); |
| 544 | fByteLength = byteLength; |
| 545 | |
| 546 | fPos = new SkPoint[numPts]; |
| 547 | memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
| 548 | |
| 549 | fPaint = paint; |
| 550 | fDrawType = DRAW_POS_TEXT; |
| 551 | |
| 552 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 553 | // TODO(chudy): Test that this works. |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 554 | fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 555 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 556 | } |
| 557 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 558 | void SkDrawPosTextCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 559 | canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 563 | SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength, |
| 564 | const SkScalar xpos[], SkScalar constY, |
| 565 | const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 566 | size_t numPts = paint.countText(text, byteLength); |
| 567 | |
| 568 | fText = new char[byteLength]; |
| 569 | memcpy(fText, text, byteLength); |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 570 | fByteLength = byteLength; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 571 | |
| 572 | fXpos = new SkScalar[numPts]; |
| 573 | memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
| 574 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 575 | fConstY = constY; |
| 576 | fPaint = paint; |
| 577 | fDrawType = DRAW_POS_TEXT_H; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 578 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 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)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 583 | } |
| 584 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 585 | void SkDrawPosTextHCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 586 | canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 587 | } |
| 588 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 589 | SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 590 | fRect = rect; |
| 591 | fPaint = paint; |
| 592 | fDrawType = DRAW_RECT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 593 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 594 | fInfo.push(SkObjectParser::RectToString(rect)); |
| 595 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 596 | } |
| 597 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 598 | void SkDrawRectCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 599 | canvas->drawRect(fRect, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 600 | } |
| 601 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 602 | SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& paint) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 603 | fRRect = rrect; |
| 604 | fPaint = paint; |
| 605 | fDrawType = DRAW_RRECT; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 606 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 607 | fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 608 | fInfo.push(SkObjectParser::PaintToString(paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 609 | } |
| 610 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 611 | void SkDrawRRectCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 612 | canvas->drawRRect(fRRect, fPaint); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 613 | } |
| 614 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 615 | bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 616 | render_rrect(canvas, fRRect); |
| 617 | return true; |
| 618 | } |
| 619 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 620 | SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int top, |
| 621 | const SkPaint* paint) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 622 | fBitmap = bitmap; |
| 623 | fLeft = left; |
| 624 | fTop = top; |
| 625 | if (NULL != paint) { |
| 626 | fPaint = *paint; |
| 627 | fPaintPtr = &fPaint; |
| 628 | } else { |
| 629 | fPaintPtr = NULL; |
| 630 | } |
| 631 | fDrawType = DRAW_SPRITE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 632 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 633 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 634 | fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 635 | fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
| 636 | if (NULL != paint) { |
| 637 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 638 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 639 | } |
| 640 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 641 | void SkDrawSpriteCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 642 | canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 643 | } |
| 644 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 645 | bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
robertphillips@google.com | 6ede1fe | 2013-06-06 23:59:28 +0000 | [diff] [blame] | 646 | render_bitmap(canvas, fBitmap); |
| 647 | return true; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 648 | } |
| 649 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 650 | SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 651 | const SkPaint& paint) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 652 | fText = new char[byteLength]; |
| 653 | memcpy(fText, text, byteLength); |
| 654 | fByteLength = byteLength; |
| 655 | fX = x; |
| 656 | fY = y; |
| 657 | fPaint = paint; |
| 658 | fDrawType = DRAW_TEXT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 659 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 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)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 664 | } |
| 665 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 666 | void SkDrawTextCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 667 | canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 668 | } |
| 669 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 670 | SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLength, |
| 671 | const SkPath& path, const SkMatrix* matrix, |
| 672 | const SkPaint& paint) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 673 | fText = new char[byteLength]; |
| 674 | memcpy(fText, text, byteLength); |
| 675 | fByteLength = byteLength; |
| 676 | fPath = path; |
| 677 | if (NULL != matrix) { |
| 678 | fMatrix = *matrix; |
| 679 | } else { |
| 680 | fMatrix.setIdentity(); |
| 681 | } |
| 682 | fPaint = paint; |
| 683 | fDrawType = DRAW_TEXT_ON_PATH; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 684 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 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)); |
| 689 | } |
| 690 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 691 | } |
| 692 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 693 | void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 694 | canvas->drawTextOnPath(fText, fByteLength, fPath, |
| 695 | fMatrix.isIdentity() ? NULL : &fMatrix, |
| 696 | fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 697 | } |
| 698 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 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) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 704 | fVmode = vmode; |
| 705 | |
| 706 | fVertexCount = vertexCount; |
| 707 | |
| 708 | fVertices = new SkPoint[vertexCount]; |
| 709 | memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
| 710 | |
| 711 | if (NULL != texs) { |
| 712 | fTexs = new SkPoint[vertexCount]; |
| 713 | memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
| 714 | } else { |
| 715 | fTexs = NULL; |
| 716 | } |
| 717 | |
| 718 | if (NULL != colors) { |
| 719 | fColors = new SkColor[vertexCount]; |
| 720 | memcpy(fColors, colors, vertexCount * sizeof(SkColor)); |
| 721 | } else { |
| 722 | fColors = NULL; |
| 723 | } |
| 724 | |
| 725 | fXfermode = xfermode; |
| 726 | if (NULL != fXfermode) { |
| 727 | fXfermode->ref(); |
| 728 | } |
| 729 | |
| 730 | if (indexCount > 0) { |
| 731 | fIndices = new uint16_t[indexCount]; |
| 732 | memcpy(fIndices, indices, indexCount * sizeof(uint16_t)); |
| 733 | } else { |
| 734 | fIndices = NULL; |
| 735 | } |
| 736 | |
| 737 | fIndexCount = indexCount; |
| 738 | fPaint = paint; |
| 739 | fDrawType = DRAW_VERTICES; |
| 740 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 741 | // TODO(chudy) |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 742 | fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
| 743 | fInfo.push(SkObjectParser::PaintToString(paint)); |
| 744 | } |
| 745 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 746 | SkDrawVerticesCommand::~SkDrawVerticesCommand() { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 747 | delete [] fVertices; |
| 748 | delete [] fTexs; |
| 749 | delete [] fColors; |
| 750 | SkSafeUnref(fXfermode); |
| 751 | delete [] fIndices; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 752 | } |
| 753 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 754 | void SkDrawVerticesCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 755 | canvas->drawVertices(fVmode, fVertexCount, fVertices, |
| 756 | fTexs, fColors, fXfermode, fIndices, |
| 757 | fIndexCount, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 758 | } |
| 759 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 760 | SkRestoreCommand::SkRestoreCommand() { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 761 | fDrawType = RESTORE; |
| 762 | fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 763 | } |
| 764 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 765 | void SkRestoreCommand::execute(SkCanvas* canvas) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 766 | canvas->restore(); |
| 767 | } |
| 768 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 769 | void SkRestoreCommand::trackSaveState(int* state) { |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 770 | (*state)--; |
| 771 | } |
| 772 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 773 | SkRotateCommand::SkRotateCommand(SkScalar degrees) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 774 | fDegrees = degrees; |
| 775 | fDrawType = ROTATE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 776 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 777 | fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 778 | } |
| 779 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 780 | void SkRotateCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 781 | canvas->rotate(fDegrees); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 782 | } |
| 783 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 784 | SkSaveCommand::SkSaveCommand(SkCanvas::SaveFlags flags) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 785 | fFlags = flags; |
| 786 | fDrawType = SAVE; |
| 787 | fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 788 | } |
| 789 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 790 | void SkSaveCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 791 | canvas->save(fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 792 | } |
| 793 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 794 | void SkSaveCommand::trackSaveState(int* state) { |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 795 | (*state)++; |
| 796 | } |
| 797 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 798 | SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* paint, |
| 799 | SkCanvas::SaveFlags flags) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 800 | if (NULL != bounds) { |
| 801 | fBounds = *bounds; |
| 802 | } else { |
| 803 | fBounds.setEmpty(); |
| 804 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 805 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 806 | if (NULL != paint) { |
| 807 | fPaint = *paint; |
| 808 | fPaintPtr = &fPaint; |
| 809 | } else { |
| 810 | fPaintPtr = NULL; |
| 811 | } |
| 812 | fFlags = flags; |
| 813 | fDrawType = SAVE_LAYER; |
| 814 | |
| 815 | if (NULL != bounds) { |
| 816 | fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
| 817 | } |
| 818 | if (NULL != paint) { |
| 819 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 820 | } |
| 821 | fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 822 | } |
| 823 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 824 | void SkSaveLayerCommand::execute(SkCanvas* canvas) { |
skia.committer@gmail.com | 7e32851 | 2013-03-23 07:01:28 +0000 | [diff] [blame] | 825 | canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame] | 826 | fPaintPtr, |
| 827 | fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 828 | } |
| 829 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 830 | void SkSaveLayerCommand::trackSaveState(int* state) { |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 831 | (*state)++; |
| 832 | } |
| 833 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 834 | SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 835 | fSx = sx; |
| 836 | fSy = sy; |
| 837 | fDrawType = SCALE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 838 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 839 | fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 840 | fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 841 | } |
| 842 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 843 | void SkScaleCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 844 | canvas->scale(fSx, fSy); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 845 | } |
| 846 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 847 | SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 848 | fMatrix = matrix; |
| 849 | fDrawType = SET_MATRIX; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 850 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 851 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 852 | } |
| 853 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 854 | void SkSetMatrixCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 855 | canvas->setMatrix(fMatrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 856 | } |
| 857 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 858 | SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 859 | fSx = sx; |
| 860 | fSy = sy; |
| 861 | fDrawType = SKEW; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 862 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 863 | fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 864 | fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 865 | } |
| 866 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 867 | void SkSkewCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 868 | canvas->skew(fSx, fSy); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 869 | } |
| 870 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 871 | SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 872 | fDx = dx; |
| 873 | fDy = dy; |
| 874 | fDrawType = TRANSLATE; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 875 | |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 876 | fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 877 | fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 878 | } |
| 879 | |
commit-bot@chromium.org | 7a11591 | 2013-06-18 20:20:55 +0000 | [diff] [blame] | 880 | void SkTranslateCommand::execute(SkCanvas* canvas) { |
robertphillips@google.com | 0df2a9a | 2013-03-25 11:50:42 +0000 | [diff] [blame] | 881 | canvas->translate(fDx, fDy); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 882 | } |