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 | |
| 15 | SkDrawCommand::SkDrawCommand() { |
| 16 | fVisible = true; |
| 17 | } |
| 18 | |
| 19 | SkDrawCommand::~SkDrawCommand() { |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 20 | fInfo.deleteAll(); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | const 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"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 30 | case CLIP_RRECT: return "Clip RRect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 31 | case CONCAT: return "Concat"; |
| 32 | case DRAW_BITMAP: return "Draw Bitmap"; |
| 33 | case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix"; |
| 34 | case DRAW_BITMAP_NINE: return "Draw Bitmap Nine"; |
robertphillips@google.com | 84d320e | 2012-09-20 19:09:17 +0000 | [diff] [blame] | 35 | case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 36 | case DRAW_DATA: return "Draw Data"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 37 | case DRAW_OVAL: return "Draw Oval"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 38 | case DRAW_PAINT: return "Draw Paint"; |
| 39 | case DRAW_PATH: return "Draw Path"; |
| 40 | case DRAW_PICTURE: return "Draw Picture"; |
| 41 | case DRAW_POINTS: return "Draw Points"; |
| 42 | case DRAW_POS_TEXT: return "Draw Pos Text"; |
| 43 | case DRAW_POS_TEXT_H: return "Draw Pos Text H"; |
| 44 | case DRAW_RECT: return "Draw Rect"; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 45 | case DRAW_RRECT: return "Draw RRect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 46 | case DRAW_SPRITE: return "Draw Sprite"; |
| 47 | case DRAW_TEXT: return "Draw Text"; |
| 48 | case DRAW_TEXT_ON_PATH: return "Draw Text On Path"; |
| 49 | case DRAW_VERTICES: return "Draw Vertices"; |
| 50 | case RESTORE: return "Restore"; |
| 51 | case ROTATE: return "Rotate"; |
| 52 | case SAVE: return "Save"; |
| 53 | case SAVE_LAYER: return "Save Layer"; |
| 54 | case SCALE: return "Scale"; |
| 55 | case SET_MATRIX: return "Set Matrix"; |
| 56 | case SKEW: return "Skew"; |
| 57 | case TRANSLATE: return "Translate"; |
robertphillips@google.com | e4ce5b8 | 2013-02-15 17:19:15 +0000 | [diff] [blame] | 58 | case NOOP: return "NoOp"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 59 | default: |
| 60 | SkDebugf("DrawType error 0x%08x\n", type); |
| 61 | SkASSERT(0); |
| 62 | break; |
| 63 | } |
| 64 | SkDEBUGFAIL("DrawType UNUSED\n"); |
| 65 | return NULL; |
| 66 | } |
| 67 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 68 | SkString SkDrawCommand::toString() { |
| 69 | return SkString(GetCommandString(fDrawType)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | Clear::Clear(SkColor color) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 73 | fColor = color; |
| 74 | fDrawType = DRAW_CLEAR; |
| 75 | fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void Clear::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 79 | canvas->clear(fColor); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 80 | } |
| 81 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 82 | ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA, SkBitmap& bitmap) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 83 | fPath = path; |
| 84 | fOp = op; |
| 85 | fDoAA = doAA; |
| 86 | fDrawType = CLIP_PATH; |
| 87 | fBitmap = bitmap; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 88 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 89 | fInfo.push(SkObjectParser::PathToString(path)); |
| 90 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 91 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | void ClipPath::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 95 | canvas->clipPath(fPath, fOp, fDoAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 96 | } |
| 97 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 98 | const SkBitmap* ClipPath::getBitmap() const { |
| 99 | return &fBitmap; |
| 100 | } |
| 101 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 102 | ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 103 | fRegion = region; |
| 104 | fOp = op; |
| 105 | fDrawType = CLIP_REGION; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 106 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 107 | fInfo.push(SkObjectParser::RegionToString(region)); |
| 108 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | void ClipRegion::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 112 | canvas->clipRegion(fRegion, fOp); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 116 | fRect = rect; |
| 117 | fOp = op; |
| 118 | fDoAA = doAA; |
| 119 | fDrawType = CLIP_RECT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 120 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 121 | fInfo.push(SkObjectParser::RectToString(rect)); |
| 122 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 123 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | void ClipRect::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 127 | canvas->clipRect(fRect, fOp, fDoAA); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 128 | } |
| 129 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 130 | ClipRRect::ClipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 131 | fRRect = rrect; |
| 132 | fOp = op; |
| 133 | fDoAA = doAA; |
| 134 | fDrawType = CLIP_RRECT; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 135 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 136 | fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 137 | fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 138 | fInfo.push(SkObjectParser::BoolToString(doAA)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void ClipRRect::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 142 | canvas->clipRRect(fRRect, fOp, fDoAA); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 143 | } |
| 144 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 145 | Concat::Concat(const SkMatrix& matrix) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 146 | fMatrix = matrix; |
| 147 | fDrawType = CONCAT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 148 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 149 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | void Concat::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 153 | canvas->concat(fMatrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 157 | const SkPaint* paint, SkBitmap& resizedBitmap) { |
| 158 | fBitmap = bitmap; |
| 159 | fLeft = left; |
| 160 | fTop = top; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 161 | if (NULL != paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 162 | fPaint = *paint; |
| 163 | fPaintPtr = &fPaint; |
| 164 | } else { |
| 165 | fPaintPtr = NULL; |
| 166 | } |
| 167 | fDrawType = DRAW_BITMAP; |
| 168 | fResizedBitmap = resizedBitmap; |
| 169 | |
| 170 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 171 | fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 172 | fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
| 173 | if (NULL != paint) { |
| 174 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 175 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void DrawBitmap::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 179 | canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 180 | } |
| 181 | |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 182 | const SkBitmap* DrawBitmap::getBitmap() const { |
| 183 | return &fResizedBitmap; |
| 184 | } |
| 185 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 186 | DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 187 | const SkMatrix& matrix, |
| 188 | const SkPaint* paint, |
| 189 | SkBitmap& resizedBitmap) { |
| 190 | fBitmap = bitmap; |
| 191 | fMatrix = matrix; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 192 | if (NULL != paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 193 | fPaint = *paint; |
| 194 | fPaintPtr = &fPaint; |
| 195 | } else { |
| 196 | fPaintPtr = NULL; |
| 197 | } |
| 198 | fDrawType = DRAW_BITMAP_MATRIX; |
| 199 | fResizedBitmap = resizedBitmap; |
| 200 | |
| 201 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 202 | fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 203 | if (NULL != paint) { |
| 204 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 205 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | void DrawBitmapMatrix::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 209 | canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 210 | } |
| 211 | |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 212 | const SkBitmap* DrawBitmapMatrix::getBitmap() const { |
| 213 | return &fResizedBitmap; |
| 214 | } |
| 215 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 216 | DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 217 | const SkRect& dst, const SkPaint* paint, |
| 218 | SkBitmap& resizedBitmap) { |
| 219 | fBitmap = bitmap; |
| 220 | fCenter = center; |
| 221 | fDst = dst; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 222 | if (NULL != paint) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 223 | fPaint = *paint; |
| 224 | fPaintPtr = &fPaint; |
| 225 | } else { |
| 226 | fPaintPtr = NULL; |
| 227 | } |
| 228 | fDrawType = DRAW_BITMAP_NINE; |
| 229 | fResizedBitmap = resizedBitmap; |
| 230 | |
| 231 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 232 | fInfo.push(SkObjectParser::IRectToString(center)); |
| 233 | fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 234 | if (NULL != paint) { |
| 235 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 236 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | void DrawBitmapNine::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 240 | canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 241 | } |
| 242 | |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 243 | const SkBitmap* DrawBitmapNine::getBitmap() const { |
| 244 | return &fResizedBitmap; |
| 245 | } |
| 246 | |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 247 | DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
skia.committer@gmail.com | c76bb23 | 2013-03-18 07:01:03 +0000 | [diff] [blame] | 248 | const SkRect& dst, const SkPaint* paint, |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 249 | SkBitmap& resizedBitmap) { |
| 250 | fBitmap = bitmap; |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 251 | if (NULL != src) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 252 | fSrc = *src; |
| 253 | } else { |
| 254 | fSrc.setEmpty(); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 255 | } |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 256 | fDst = dst; |
| 257 | |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 258 | if (NULL != paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 259 | fPaint = *paint; |
| 260 | fPaintPtr = &fPaint; |
| 261 | } else { |
| 262 | fPaintPtr = NULL; |
| 263 | } |
| 264 | fDrawType = DRAW_BITMAP_RECT_TO_RECT; |
| 265 | fResizedBitmap = resizedBitmap; |
| 266 | |
| 267 | fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 268 | if (NULL != src) { |
| 269 | fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 270 | } |
| 271 | fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 272 | if (NULL != paint) { |
| 273 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
robertphillips@google.com | b83b6b4 | 2013-01-22 14:32:09 +0000 | [diff] [blame] | 274 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | void DrawBitmapRect::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 278 | canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 279 | } |
| 280 | |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 281 | const SkBitmap* DrawBitmapRect::getBitmap() const { |
| 282 | return &fResizedBitmap; |
| 283 | } |
| 284 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 285 | DrawData::DrawData(const void* data, size_t length) { |
| 286 | this->fData = data; |
| 287 | this->fLength = length; |
| 288 | this->fDrawType = DRAW_DATA; |
| 289 | // TODO(chudy): See if we can't display data and length. |
| 290 | } |
| 291 | |
| 292 | void DrawData::execute(SkCanvas* canvas) { |
| 293 | canvas->drawData(this->fData, this->fLength); |
| 294 | } |
| 295 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 296 | DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 297 | fOval = oval; |
| 298 | fPaint = paint; |
| 299 | fDrawType = DRAW_OVAL; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 300 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 301 | fInfo.push(SkObjectParser::RectToString(oval)); |
| 302 | fInfo.push(SkObjectParser::PaintToString(paint)); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | void DrawOval::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 306 | canvas->drawOval(fOval, fPaint); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 307 | } |
| 308 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 309 | DrawPaint::DrawPaint(const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 310 | fPaint = paint; |
| 311 | fDrawType = DRAW_PAINT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 312 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 313 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | void DrawPaint::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 317 | canvas->drawPaint(fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 318 | } |
| 319 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 320 | DrawPath::DrawPath(const SkPath& path, const SkPaint& paint, SkBitmap& bitmap) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 321 | fPath = path; |
| 322 | fPaint = paint; |
| 323 | fBitmap = bitmap; |
| 324 | fDrawType = DRAW_PATH; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 325 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 326 | fInfo.push(SkObjectParser::PathToString(path)); |
| 327 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | void DrawPath::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 331 | canvas->drawPath(fPath, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 332 | } |
| 333 | |
robertphillips@google.com | 6dec8fc | 2012-11-21 17:11:02 +0000 | [diff] [blame] | 334 | const SkBitmap* DrawPath::getBitmap() const { |
| 335 | return &fBitmap; |
| 336 | } |
| 337 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 338 | DrawPicture::DrawPicture(SkPicture& picture) { |
| 339 | this->fPicture = &picture; |
| 340 | this->fDrawType = DRAW_PICTURE; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 341 | this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | void DrawPicture::execute(SkCanvas* canvas) { |
| 345 | canvas->drawPicture(*this->fPicture); |
| 346 | } |
| 347 | |
| 348 | DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count, |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 349 | const SkPoint pts[], const SkPaint& paint) { |
| 350 | fMode = mode; |
| 351 | fCount = count; |
| 352 | fPts = new SkPoint[count]; |
| 353 | memcpy(fPts, pts, count * sizeof(SkPoint)); |
| 354 | fPaint = paint; |
| 355 | fDrawType = DRAW_POINTS; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 356 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 357 | fInfo.push(SkObjectParser::PointsToString(pts, count)); |
| 358 | fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count), |
| 359 | "Points: ")); |
| 360 | fInfo.push(SkObjectParser::PointModeToString(mode)); |
| 361 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | void DrawPoints::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 365 | canvas->drawPoints(fMode, fCount, fPts, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 369 | const SkPaint& paint) { |
| 370 | size_t numPts = paint.countText(text, byteLength); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 371 | |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 372 | fText = new char[byteLength]; |
| 373 | memcpy(fText, text, byteLength); |
| 374 | fByteLength = byteLength; |
| 375 | |
| 376 | fPos = new SkPoint[numPts]; |
| 377 | memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
| 378 | |
| 379 | fPaint = paint; |
| 380 | fDrawType = DRAW_POS_TEXT; |
| 381 | |
| 382 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 383 | // TODO(chudy): Test that this works. |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 384 | fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 385 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | void DrawPosText::execute(SkCanvas* canvas) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 389 | canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | |
| 393 | DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength, |
skia.committer@gmail.com | c76bb23 | 2013-03-18 07:01:03 +0000 | [diff] [blame] | 394 | const SkScalar xpos[], SkScalar constY, |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 395 | const SkPaint& paint) { |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 396 | size_t numPts = paint.countText(text, byteLength); |
| 397 | |
| 398 | fText = new char[byteLength]; |
| 399 | memcpy(fText, text, byteLength); |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 400 | fByteLength = byteLength; |
robertphillips@google.com | a3a09ab | 2013-03-22 12:25:30 +0000 | [diff] [blame] | 401 | |
| 402 | fXpos = new SkScalar[numPts]; |
| 403 | memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
| 404 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 405 | fConstY = constY; |
| 406 | fPaint = paint; |
| 407 | fDrawType = DRAW_POS_TEXT_H; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 408 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 409 | fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
| 410 | fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 411 | fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 412 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | void DrawPosTextH::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 416 | canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 420 | fRect = rect; |
| 421 | fPaint = paint; |
| 422 | fDrawType = DRAW_RECT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 423 | |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 424 | fInfo.push(SkObjectParser::RectToString(rect)); |
| 425 | fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | void DrawRectC::execute(SkCanvas* canvas) { |
robertphillips@google.com | 91217d0 | 2013-03-17 18:33:46 +0000 | [diff] [blame] | 429 | canvas->drawRect(fRect, fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 430 | } |
| 431 | |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 432 | DrawRRect::DrawRRect(const SkRRect& rrect, const SkPaint& paint) { |
| 433 | this->fRRect = rrect; |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 434 | this->fPaint = paint; |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 435 | this->fDrawType = DRAW_RRECT; |
| 436 | |
| 437 | this->fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 438 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
| 439 | } |
| 440 | |
| 441 | void DrawRRect::execute(SkCanvas* canvas) { |
robertphillips@google.com | febc0ec | 2013-03-11 22:53:11 +0000 | [diff] [blame] | 442 | canvas->drawRRect(fRRect, fPaint); |
robertphillips@google.com | 67baba4 | 2013-01-02 20:20:31 +0000 | [diff] [blame] | 443 | } |
| 444 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 445 | DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top, |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 446 | const SkPaint* paint, SkBitmap& resizedBitmap) { |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 447 | this->fBitmap = &bitmap; |
| 448 | this->fLeft = left; |
| 449 | this->fTop = top; |
| 450 | this->fPaint = paint; |
| 451 | this->fDrawType = DRAW_SPRITE; |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 452 | this->fResizedBitmap = resizedBitmap; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 453 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 454 | this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 455 | this->fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 456 | this->fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | void DrawSprite::execute(SkCanvas* canvas) { |
| 460 | canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint); |
| 461 | } |
| 462 | |
robertphillips@google.com | 53ec73d | 2012-11-26 13:09:17 +0000 | [diff] [blame] | 463 | const SkBitmap* DrawSprite::getBitmap() const { |
| 464 | return &fResizedBitmap; |
| 465 | } |
| 466 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 467 | DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 468 | const SkPaint& paint) { |
| 469 | this->fText = text; |
| 470 | this->fByteLength = byteLength; |
| 471 | this->fX = x; |
| 472 | this->fY = y; |
| 473 | this->fPaint = &paint; |
| 474 | this->fDrawType = DRAW_TEXT; |
| 475 | |
bungeman@google.com | 428fc4a | 2013-03-07 20:30:32 +0000 | [diff] [blame] | 476 | this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 477 | this->fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
| 478 | this->fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
| 479 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | void DrawTextC::execute(SkCanvas* canvas) { |
| 483 | canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this->fPaint); |
| 484 | } |
| 485 | |
| 486 | DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength, |
| 487 | const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { |
| 488 | this->fText = text; |
| 489 | this->fByteLength = byteLength; |
| 490 | this->fPath = &path; |
| 491 | this->fMatrix = matrix; |
| 492 | this->fPaint = &paint; |
| 493 | this->fDrawType = DRAW_TEXT_ON_PATH; |
| 494 | |
bungeman@google.com | 428fc4a | 2013-03-07 20:30:32 +0000 | [diff] [blame] | 495 | this->fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncoding())); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 496 | this->fInfo.push(SkObjectParser::PathToString(path)); |
| 497 | if (matrix) this->fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 498 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | void DrawTextOnPath::execute(SkCanvas* canvas) { |
| 502 | canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath, |
| 503 | this->fMatrix, *this->fPaint); |
| 504 | } |
| 505 | |
| 506 | DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, |
| 507 | const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], |
| 508 | SkXfermode* xfermode, const uint16_t indices[], int indexCount, |
| 509 | const SkPaint& paint) { |
| 510 | this->fVmode = vmode; |
| 511 | this->fVertexCount = vertexCount; |
| 512 | this->fTexs = texs; |
| 513 | this->fColors = colors; |
| 514 | this->fXfermode = xfermode; |
| 515 | this->fIndices = indices; |
| 516 | this->fIndexCount = indexCount; |
| 517 | this->fPaint = &paint; |
| 518 | this->fDrawType = DRAW_VERTICES; |
| 519 | // TODO(chudy) |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 520 | this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | void DrawVertices::execute(SkCanvas* canvas) { |
| 524 | canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices, |
| 525 | this->fTexs, this->fColors, this->fXfermode, this->fIndices, |
| 526 | this->fIndexCount, *this->fPaint); |
| 527 | } |
| 528 | |
| 529 | Restore::Restore() { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 530 | fDrawType = RESTORE; |
| 531 | fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | void Restore::execute(SkCanvas* canvas) { |
| 535 | canvas->restore(); |
| 536 | } |
| 537 | |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 538 | void Restore::trackSaveState(int* state) { |
| 539 | (*state)--; |
| 540 | } |
| 541 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 542 | Rotate::Rotate(SkScalar degrees) { |
| 543 | this->fDegrees = degrees; |
| 544 | this->fDrawType = ROTATE; |
| 545 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 546 | this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | void Rotate::execute(SkCanvas* canvas) { |
| 550 | canvas->rotate(this->fDegrees); |
| 551 | } |
| 552 | |
| 553 | Save::Save(SkCanvas::SaveFlags flags) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 554 | fFlags = flags; |
| 555 | fDrawType = SAVE; |
| 556 | fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | void Save::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 560 | canvas->save(fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 561 | } |
| 562 | |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 563 | void Save::trackSaveState(int* state) { |
| 564 | (*state)++; |
| 565 | } |
| 566 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 567 | SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint, |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 568 | SkCanvas::SaveFlags flags) { |
| 569 | if (NULL != bounds) { |
| 570 | fBounds = *bounds; |
| 571 | } else { |
| 572 | fBounds.setEmpty(); |
| 573 | } |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 574 | |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 575 | if (NULL != paint) { |
| 576 | fPaint = *paint; |
| 577 | fPaintPtr = &fPaint; |
| 578 | } else { |
| 579 | fPaintPtr = NULL; |
| 580 | } |
| 581 | fFlags = flags; |
| 582 | fDrawType = SAVE_LAYER; |
| 583 | |
| 584 | if (NULL != bounds) { |
| 585 | fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
| 586 | } |
| 587 | if (NULL != paint) { |
| 588 | fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 589 | } |
| 590 | fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | void SaveLayer::execute(SkCanvas* canvas) { |
robertphillips@google.com | 24bfdac | 2013-03-22 16:33:31 +0000 | [diff] [blame^] | 594 | canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
| 595 | fPaintPtr, |
| 596 | fFlags); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 597 | } |
| 598 | |
tomhudson@google.com | 0699e02 | 2012-11-27 16:09:42 +0000 | [diff] [blame] | 599 | void SaveLayer::trackSaveState(int* state) { |
| 600 | (*state)++; |
| 601 | } |
| 602 | |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 603 | Scale::Scale(SkScalar sx, SkScalar sy) { |
| 604 | this->fSx = sx; |
| 605 | this->fSy = sy; |
| 606 | this->fDrawType = SCALE; |
| 607 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 608 | this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 609 | this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | void Scale::execute(SkCanvas* canvas) { |
| 613 | canvas->scale(this->fSx, this->fSy); |
| 614 | } |
| 615 | |
| 616 | SetMatrix::SetMatrix(const SkMatrix& matrix) { |
robertphillips@google.com | b94b1e7 | 2013-02-19 21:00:26 +0000 | [diff] [blame] | 617 | this->fMatrix = matrix; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 618 | this->fDrawType = SET_MATRIX; |
| 619 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 620 | this->fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | void SetMatrix::execute(SkCanvas* canvas) { |
robertphillips@google.com | b94b1e7 | 2013-02-19 21:00:26 +0000 | [diff] [blame] | 624 | canvas->setMatrix(this->fMatrix); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | Skew::Skew(SkScalar sx, SkScalar sy) { |
| 628 | this->fSx = sx; |
| 629 | this->fSy = sy; |
| 630 | this->fDrawType = SKEW; |
| 631 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 632 | this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 633 | this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 634 | } |
| 635 | |
| 636 | void Skew::execute(SkCanvas* canvas) { |
| 637 | canvas->skew(this->fSx, this->fSy); |
| 638 | } |
| 639 | |
| 640 | Translate::Translate(SkScalar dx, SkScalar dy) { |
| 641 | this->fDx = dx; |
| 642 | this->fDy = dy; |
| 643 | this->fDrawType = TRANSLATE; |
| 644 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 645 | this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 646 | this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | void Translate::execute(SkCanvas* canvas) { |
| 650 | canvas->translate(this->fDx, this->fDy); |
| 651 | } |