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"; |
| 30 | case CONCAT: return "Concat"; |
| 31 | case DRAW_BITMAP: return "Draw Bitmap"; |
| 32 | case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix"; |
| 33 | case DRAW_BITMAP_NINE: return "Draw Bitmap Nine"; |
robertphillips@google.com | 84d320e | 2012-09-20 19:09:17 +0000 | [diff] [blame] | 34 | case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect"; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 35 | case DRAW_DATA: return "Draw Data"; |
| 36 | case DRAW_PAINT: return "Draw Paint"; |
| 37 | case DRAW_PATH: return "Draw Path"; |
| 38 | case DRAW_PICTURE: return "Draw Picture"; |
| 39 | case DRAW_POINTS: return "Draw Points"; |
| 40 | case DRAW_POS_TEXT: return "Draw Pos Text"; |
| 41 | case DRAW_POS_TEXT_H: return "Draw Pos Text H"; |
| 42 | case DRAW_RECT: return "Draw Rect"; |
| 43 | case DRAW_SPRITE: return "Draw Sprite"; |
| 44 | case DRAW_TEXT: return "Draw Text"; |
| 45 | case DRAW_TEXT_ON_PATH: return "Draw Text On Path"; |
| 46 | case DRAW_VERTICES: return "Draw Vertices"; |
| 47 | case RESTORE: return "Restore"; |
| 48 | case ROTATE: return "Rotate"; |
| 49 | case SAVE: return "Save"; |
| 50 | case SAVE_LAYER: return "Save Layer"; |
| 51 | case SCALE: return "Scale"; |
| 52 | case SET_MATRIX: return "Set Matrix"; |
| 53 | case SKEW: return "Skew"; |
| 54 | case TRANSLATE: return "Translate"; |
| 55 | default: |
| 56 | SkDebugf("DrawType error 0x%08x\n", type); |
| 57 | SkASSERT(0); |
| 58 | break; |
| 59 | } |
| 60 | SkDEBUGFAIL("DrawType UNUSED\n"); |
| 61 | return NULL; |
| 62 | } |
| 63 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 64 | SkString SkDrawCommand::toString() { |
| 65 | return SkString(GetCommandString(fDrawType)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | Clear::Clear(SkColor color) { |
| 69 | this->fColor = color; |
| 70 | this->fDrawType = DRAW_CLEAR; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 71 | this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void Clear::execute(SkCanvas* canvas) { |
| 75 | canvas->clear(this->fColor); |
| 76 | } |
| 77 | |
| 78 | ClipPath::ClipPath(const SkPath& path, SkRegion::Op op, bool doAA) { |
| 79 | this->fPath = &path; |
| 80 | this->fOp = op; |
| 81 | this->fDoAA = doAA; |
| 82 | this->fDrawType = CLIP_PATH; |
| 83 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 84 | this->fInfo.push(SkObjectParser::PathToString(path)); |
| 85 | this->fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 86 | this->fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | void ClipPath::execute(SkCanvas* canvas) { |
| 90 | canvas->clipPath(*this->fPath, this->fOp, this->fDoAA); |
| 91 | } |
| 92 | |
| 93 | ClipRegion::ClipRegion(const SkRegion& region, SkRegion::Op op) { |
| 94 | this->fRegion = ®ion; |
| 95 | this->fOp = op; |
| 96 | this->fDrawType = CLIP_REGION; |
| 97 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 98 | this->fInfo.push(SkObjectParser::RegionToString(region)); |
| 99 | this->fInfo.push(SkObjectParser::RegionOpToString(op)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void ClipRegion::execute(SkCanvas* canvas) { |
| 103 | canvas->clipRegion(*this->fRegion, this->fOp); |
| 104 | } |
| 105 | |
| 106 | ClipRect::ClipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { |
| 107 | this->fRect = ▭ |
| 108 | this->fOp = op; |
| 109 | this->fDoAA = doAA; |
| 110 | this->fDrawType = CLIP_RECT; |
| 111 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 112 | this->fInfo.push(SkObjectParser::RectToString(rect)); |
| 113 | this->fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 114 | this->fInfo.push(SkObjectParser::BoolToString(doAA)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | void ClipRect::execute(SkCanvas* canvas) { |
| 118 | canvas->clipRect(*this->fRect, this->fOp, this->fDoAA); |
| 119 | } |
| 120 | |
| 121 | Concat::Concat(const SkMatrix& matrix) { |
| 122 | this->fMatrix = &matrix; |
| 123 | this->fDrawType = CONCAT; |
| 124 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 125 | this->fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | void Concat::execute(SkCanvas* canvas) { |
| 129 | canvas->concat(*this->fMatrix); |
| 130 | } |
| 131 | |
| 132 | DrawBitmap::DrawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top, |
| 133 | const SkPaint* paint) { |
| 134 | this->fBitmap = &bitmap; |
| 135 | this->fLeft = left; |
| 136 | this->fTop = top; |
| 137 | this->fPaint = paint; |
| 138 | this->fDrawType = DRAW_BITMAP; |
| 139 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 140 | this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 141 | this->fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 142 | this->fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | void DrawBitmap::execute(SkCanvas* canvas) { |
| 146 | canvas->drawBitmap(*this->fBitmap, this->fLeft, this->fTop, this->fPaint); |
| 147 | } |
| 148 | |
| 149 | DrawBitmapMatrix::DrawBitmapMatrix(const SkBitmap& bitmap, |
| 150 | const SkMatrix& matrix, const SkPaint* paint) { |
| 151 | this->fBitmap = &bitmap; |
| 152 | this->fMatrix = &matrix; |
| 153 | this->fPaint = paint; |
| 154 | this->fDrawType = DRAW_BITMAP_MATRIX; |
| 155 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 156 | this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 157 | this->fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 158 | if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | void DrawBitmapMatrix::execute(SkCanvas* canvas) { |
| 162 | canvas->drawBitmapMatrix(*this->fBitmap, *this->fMatrix, this->fPaint); |
| 163 | } |
| 164 | |
| 165 | DrawBitmapNine::DrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, |
| 166 | const SkRect& dst, const SkPaint* paint) { |
| 167 | this->fBitmap = &bitmap; |
| 168 | this->fCenter = ¢er; |
| 169 | this->fDst = &dst; |
| 170 | this->fPaint = paint; |
| 171 | this->fDrawType = DRAW_BITMAP_NINE; |
| 172 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 173 | this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 174 | this->fInfo.push(SkObjectParser::IRectToString(center)); |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame^] | 175 | this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 176 | if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | void DrawBitmapNine::execute(SkCanvas* canvas) { |
| 180 | canvas->drawBitmapNine(*this->fBitmap, *this->fCenter, *this->fDst, this->fPaint); |
| 181 | } |
| 182 | |
reed@google.com | 7112173 | 2012-09-18 15:14:33 +0000 | [diff] [blame] | 183 | DrawBitmapRect::DrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 184 | const SkRect& dst, const SkPaint* paint) { |
| 185 | this->fBitmap = &bitmap; |
| 186 | this->fSrc = src; |
| 187 | this->fDst = &dst; |
| 188 | this->fPaint = paint; |
robertphillips@google.com | 84d320e | 2012-09-20 19:09:17 +0000 | [diff] [blame] | 189 | this->fDrawType = DRAW_BITMAP_RECT_TO_RECT; |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 190 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 191 | this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame^] | 192 | if (src) this->fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 193 | this->fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 194 | if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | void DrawBitmapRect::execute(SkCanvas* canvas) { |
robertphillips@google.com | 84d320e | 2012-09-20 19:09:17 +0000 | [diff] [blame] | 198 | canvas->drawBitmapRectToRect(*this->fBitmap, this->fSrc, *this->fDst, this->fPaint); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | DrawData::DrawData(const void* data, size_t length) { |
| 202 | this->fData = data; |
| 203 | this->fLength = length; |
| 204 | this->fDrawType = DRAW_DATA; |
| 205 | // TODO(chudy): See if we can't display data and length. |
| 206 | } |
| 207 | |
| 208 | void DrawData::execute(SkCanvas* canvas) { |
| 209 | canvas->drawData(this->fData, this->fLength); |
| 210 | } |
| 211 | |
| 212 | DrawPaint::DrawPaint(const SkPaint& paint) { |
| 213 | this->fPaint = &paint; |
| 214 | this->fDrawType = DRAW_PAINT; |
| 215 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 216 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | void DrawPaint::execute(SkCanvas* canvas) { |
| 220 | canvas->drawPaint(*this->fPaint); |
| 221 | } |
| 222 | |
| 223 | DrawPath::DrawPath(const SkPath& path, const SkPaint& paint) { |
| 224 | this->fPath = &path; |
| 225 | this->fPaint = &paint; |
| 226 | this->fDrawType = DRAW_PATH; |
| 227 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 228 | this->fInfo.push(SkObjectParser::PathToString(path)); |
| 229 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | void DrawPath::execute(SkCanvas* canvas) { |
| 233 | canvas->drawPath(*this->fPath, *this->fPaint); |
| 234 | } |
| 235 | |
| 236 | DrawPicture::DrawPicture(SkPicture& picture) { |
| 237 | this->fPicture = &picture; |
| 238 | this->fDrawType = DRAW_PICTURE; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 239 | this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | void DrawPicture::execute(SkCanvas* canvas) { |
| 243 | canvas->drawPicture(*this->fPicture); |
| 244 | } |
| 245 | |
| 246 | DrawPoints::DrawPoints(SkCanvas::PointMode mode, size_t count, |
| 247 | const SkPoint pts[], const SkPaint& paint) { |
| 248 | this->fMode = mode; |
| 249 | this->fCount = count; |
| 250 | this->fPts = pts; |
| 251 | this->fPaint = &paint; |
| 252 | this->fDrawType = DRAW_POINTS; |
| 253 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 254 | this->fInfo.push(SkObjectParser::PointsToString(pts, count)); |
skia.committer@gmail.com | 04ba448 | 2012-09-07 02:01:30 +0000 | [diff] [blame] | 255 | this->fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar(count), |
robertphillips@google.com | 94acc70 | 2012-09-06 18:43:21 +0000 | [diff] [blame] | 256 | "Points: ")); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 257 | this->fInfo.push(SkObjectParser::PointModeToString(mode)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void DrawPoints::execute(SkCanvas* canvas) { |
| 261 | canvas->drawPoints(this->fMode, this->fCount, this->fPts, *this->fPaint); |
| 262 | } |
| 263 | |
| 264 | DrawPosText::DrawPosText(const void* text, size_t byteLength, const SkPoint pos[], |
| 265 | const SkPaint& paint) { |
| 266 | this->fText = text; |
| 267 | this->fByteLength = byteLength; |
| 268 | this->fPos = pos; |
| 269 | this->fPaint = &paint; |
| 270 | this->fDrawType = DRAW_POS_TEXT; |
| 271 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 272 | this->fInfo.push(SkObjectParser::TextToString(text, byteLength)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 273 | // TODO(chudy): Test that this works. |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 274 | this->fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 275 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | void DrawPosText::execute(SkCanvas* canvas) { |
| 279 | canvas->drawPosText(this->fText, this->fByteLength, this->fPos, *this->fPaint); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | DrawPosTextH::DrawPosTextH(const void* text, size_t byteLength, |
| 284 | const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { |
| 285 | this->fText = text; |
| 286 | this->fByteLength = byteLength; |
| 287 | this->fXpos = xpos; |
| 288 | this->fConstY = constY; |
| 289 | this->fPaint = &paint; |
| 290 | this->fDrawType = DRAW_POS_TEXT_H; |
| 291 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 292 | this->fInfo.push(SkObjectParser::TextToString(text, byteLength)); |
| 293 | this->fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 294 | this->fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 295 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void DrawPosTextH::execute(SkCanvas* canvas) { |
| 299 | canvas->drawPosTextH(this->fText, this->fByteLength, this->fXpos, this->fConstY, |
| 300 | *this->fPaint); |
| 301 | } |
| 302 | |
| 303 | DrawRectC::DrawRectC(const SkRect& rect, const SkPaint& paint) { |
| 304 | this->fRect = ▭ |
| 305 | this->fPaint = &paint; |
| 306 | this->fDrawType = DRAW_RECT; |
| 307 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 308 | this->fInfo.push(SkObjectParser::RectToString(rect)); |
| 309 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | void DrawRectC::execute(SkCanvas* canvas) { |
| 313 | canvas->drawRect(*this->fRect, *this->fPaint); |
| 314 | } |
| 315 | |
| 316 | DrawSprite::DrawSprite(const SkBitmap& bitmap, int left, int top, |
| 317 | const SkPaint* paint) { |
| 318 | this->fBitmap = &bitmap; |
| 319 | this->fLeft = left; |
| 320 | this->fTop = top; |
| 321 | this->fPaint = paint; |
| 322 | this->fDrawType = DRAW_SPRITE; |
| 323 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 324 | this->fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 325 | this->fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 326 | this->fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | void DrawSprite::execute(SkCanvas* canvas) { |
| 330 | canvas->drawSprite(*this->fBitmap, this->fLeft, this->fTop, this->fPaint); |
| 331 | } |
| 332 | |
| 333 | DrawTextC::DrawTextC(const void* text, size_t byteLength, SkScalar x, SkScalar y, |
| 334 | const SkPaint& paint) { |
| 335 | this->fText = text; |
| 336 | this->fByteLength = byteLength; |
| 337 | this->fX = x; |
| 338 | this->fY = y; |
| 339 | this->fPaint = &paint; |
| 340 | this->fDrawType = DRAW_TEXT; |
| 341 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 342 | this->fInfo.push(SkObjectParser::TextToString(text, byteLength)); |
| 343 | this->fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
| 344 | this->fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
| 345 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | void DrawTextC::execute(SkCanvas* canvas) { |
| 349 | canvas->drawText(this->fText, this->fByteLength, this->fX, this->fY, *this->fPaint); |
| 350 | } |
| 351 | |
| 352 | DrawTextOnPath::DrawTextOnPath(const void* text, size_t byteLength, |
| 353 | const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { |
| 354 | this->fText = text; |
| 355 | this->fByteLength = byteLength; |
| 356 | this->fPath = &path; |
| 357 | this->fMatrix = matrix; |
| 358 | this->fPaint = &paint; |
| 359 | this->fDrawType = DRAW_TEXT_ON_PATH; |
| 360 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 361 | this->fInfo.push(SkObjectParser::TextToString(text, byteLength)); |
| 362 | this->fInfo.push(SkObjectParser::PathToString(path)); |
| 363 | if (matrix) this->fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 364 | this->fInfo.push(SkObjectParser::PaintToString(paint)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | void DrawTextOnPath::execute(SkCanvas* canvas) { |
| 368 | canvas->drawTextOnPath(this->fText, this->fByteLength, *this->fPath, |
| 369 | this->fMatrix, *this->fPaint); |
| 370 | } |
| 371 | |
| 372 | DrawVertices::DrawVertices(SkCanvas::VertexMode vmode, int vertexCount, |
| 373 | const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], |
| 374 | SkXfermode* xfermode, const uint16_t indices[], int indexCount, |
| 375 | const SkPaint& paint) { |
| 376 | this->fVmode = vmode; |
| 377 | this->fVertexCount = vertexCount; |
| 378 | this->fTexs = texs; |
| 379 | this->fColors = colors; |
| 380 | this->fXfermode = xfermode; |
| 381 | this->fIndices = indices; |
| 382 | this->fIndexCount = indexCount; |
| 383 | this->fPaint = &paint; |
| 384 | this->fDrawType = DRAW_VERTICES; |
| 385 | // TODO(chudy) |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 386 | this->fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | void DrawVertices::execute(SkCanvas* canvas) { |
| 390 | canvas->drawVertices(this->fVmode, this->fVertexCount, this->fVertices, |
| 391 | this->fTexs, this->fColors, this->fXfermode, this->fIndices, |
| 392 | this->fIndexCount, *this->fPaint); |
| 393 | } |
| 394 | |
| 395 | Restore::Restore() { |
| 396 | this->fDrawType = RESTORE; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 397 | this->fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | void Restore::execute(SkCanvas* canvas) { |
| 401 | canvas->restore(); |
| 402 | } |
| 403 | |
| 404 | Rotate::Rotate(SkScalar degrees) { |
| 405 | this->fDegrees = degrees; |
| 406 | this->fDrawType = ROTATE; |
| 407 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 408 | this->fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 409 | } |
| 410 | |
| 411 | void Rotate::execute(SkCanvas* canvas) { |
| 412 | canvas->rotate(this->fDegrees); |
| 413 | } |
| 414 | |
| 415 | Save::Save(SkCanvas::SaveFlags flags) { |
| 416 | this->fFlags = flags; |
| 417 | this->fDrawType = SAVE; |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 418 | this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | void Save::execute(SkCanvas* canvas) { |
| 422 | canvas->save(this->fFlags); |
| 423 | } |
| 424 | |
| 425 | SaveLayer::SaveLayer(const SkRect* bounds, const SkPaint* paint, |
| 426 | SkCanvas::SaveFlags flags) { |
| 427 | this->fBounds = bounds; |
| 428 | this->fPaint = paint; |
| 429 | this->fFlags = flags; |
| 430 | this->fDrawType = SAVE_LAYER; |
| 431 | |
robertphillips@google.com | 30d35f2 | 2012-11-06 16:45:36 +0000 | [diff] [blame^] | 432 | if (bounds) this->fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 433 | if (paint) this->fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 434 | this->fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | void SaveLayer::execute(SkCanvas* canvas) { |
| 438 | canvas->saveLayer(this->fBounds, this->fPaint, this->fFlags); |
| 439 | } |
| 440 | |
| 441 | Scale::Scale(SkScalar sx, SkScalar sy) { |
| 442 | this->fSx = sx; |
| 443 | this->fSy = sy; |
| 444 | this->fDrawType = SCALE; |
| 445 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 446 | this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 447 | this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | void Scale::execute(SkCanvas* canvas) { |
| 451 | canvas->scale(this->fSx, this->fSy); |
| 452 | } |
| 453 | |
| 454 | SetMatrix::SetMatrix(const SkMatrix& matrix) { |
| 455 | this->fMatrix = &matrix; |
| 456 | this->fDrawType = SET_MATRIX; |
| 457 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 458 | this->fInfo.push(SkObjectParser::MatrixToString(matrix)); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | void SetMatrix::execute(SkCanvas* canvas) { |
| 462 | canvas->setMatrix(*this->fMatrix); |
| 463 | } |
| 464 | |
| 465 | Skew::Skew(SkScalar sx, SkScalar sy) { |
| 466 | this->fSx = sx; |
| 467 | this->fSy = sy; |
| 468 | this->fDrawType = SKEW; |
| 469 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 470 | this->fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 471 | this->fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | void Skew::execute(SkCanvas* canvas) { |
| 475 | canvas->skew(this->fSx, this->fSy); |
| 476 | } |
| 477 | |
| 478 | Translate::Translate(SkScalar dx, SkScalar dy) { |
| 479 | this->fDx = dx; |
| 480 | this->fDy = dy; |
| 481 | this->fDrawType = TRANSLATE; |
| 482 | |
chudy@google.com | 97cee97 | 2012-08-07 20:41:37 +0000 | [diff] [blame] | 483 | this->fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 484 | this->fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
chudy@google.com | 902ebe5 | 2012-06-29 14:21:22 +0000 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | void Translate::execute(SkCanvas* canvas) { |
| 488 | canvas->translate(this->fDx, this->fDy); |
| 489 | } |