| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "SkDrawCommand.h" | 10 #include "SkDrawCommand.h" |
| 11 #include "SkObjectParser.h" | 11 #include "SkObjectParser.h" |
| 12 | 12 #include "SkPicture.h" |
| 13 #include "SkTextBlob.h" | 13 #include "SkTextBlob.h" |
| 14 | 14 |
| 15 // TODO(chudy): Refactor into non subclass model. | 15 // TODO(chudy): Refactor into non subclass model. |
| 16 | 16 |
| 17 const char* SkDrawCommand::kDrawRectString = "Draw Rect"; | 17 const char* SkDrawCommand::kDrawRectString = "DrawRect"; |
| 18 const char* SkDrawCommand::kClipRectString = "Clip Rect"; | 18 const char* SkDrawCommand::kClipRectString = "ClipRect"; |
| 19 | 19 |
| 20 const SkDrawCommand::OpType SkDrawCommand::kSave_OpType = SAVE; | 20 SkDrawCommand::SkDrawCommand(OpType type) |
| 21 const SkDrawCommand::OpType SkDrawCommand::kClipRect_OpType = CLIP_RECT; | 21 : fOpType(type) |
| 22 const SkDrawCommand::OpType SkDrawCommand::kDrawRect_OpType = DRAW_RECT; | |
| 23 const SkDrawCommand::OpType SkDrawCommand::kRestore_OpType = RESTORE; | |
| 24 const SkDrawCommand::OpType SkDrawCommand::kSetMatrix_OpType = SET_MATRIX; | |
| 25 | |
| 26 SkDrawCommand::SkDrawCommand(DrawType type) | |
| 27 : fDrawType(type) | |
| 28 , fOffset(0) | 22 , fOffset(0) |
| 29 , fVisible(true) { | 23 , fVisible(true) { |
| 30 } | 24 } |
| 31 | 25 |
| 32 SkDrawCommand::~SkDrawCommand() { | 26 SkDrawCommand::~SkDrawCommand() { |
| 33 fInfo.deleteAll(); | 27 fInfo.deleteAll(); |
| 34 } | 28 } |
| 35 | 29 |
| 36 const char* SkDrawCommand::GetCommandString(DrawType type) { | 30 const char* SkDrawCommand::GetCommandString(OpType type) { |
| 37 switch (type) { | 31 switch (type) { |
| 38 case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break; | 32 case kBeginCommentGroup_OpType: return "BeginCommentGroup"; |
| 39 case DRAW_CLEAR: return "Clear"; | 33 case kClipPath_OpType: return "ClipPath"; |
| 40 case CLIP_PATH: return "Clip Path"; | 34 case kClipRegion_OpType: return "ClipRegion"; |
| 41 case CLIP_REGION: return "Clip Region"; | 35 case kClipRect_OpType: return "ClipRect"; |
| 42 case CLIP_RECT: return "Clip Rect"; | 36 case kClipRRect_OpType: return "ClipRRect"; |
| 43 case CLIP_RRECT: return "Clip RRect"; | 37 case kComment_OpType: return "Comment"; |
| 44 case CONCAT: return "Concat"; | 38 case kConcat_OpType: return "Concat"; |
| 45 case DRAW_BITMAP: return "Draw Bitmap"; | 39 case kDrawBitmap_OpType: return "DrawBitmap"; |
| 46 case DRAW_BITMAP_MATRIX: return "Draw Bitmap Matrix"; | 40 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; |
| 47 case DRAW_BITMAP_NINE: return "Draw Bitmap Nine"; | 41 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; |
| 48 case DRAW_BITMAP_RECT_TO_RECT: return "Draw Bitmap Rect"; | 42 case kDrawClear_OpType: return "DrawClear"; |
| 49 case DRAW_DATA: return "Draw Data"; | 43 case kDrawDRRect_OpType: return "DrawDRRect"; |
| 50 case DRAW_OVAL: return "Draw Oval"; | 44 case kDrawOval_OpType: return "DrawOval"; |
| 51 case DRAW_PAINT: return "Draw Paint"; | 45 case kDrawPaint_OpType: return "DrawPaint"; |
| 52 case DRAW_PATH: return "Draw Path"; | 46 case kDrawPatch_OpType: return "DrawPatch"; |
| 53 case DRAW_PICTURE: return "Draw Picture"; | 47 case kDrawPath_OpType: return "DrawPath"; |
| 54 case DRAW_POINTS: return "Draw Points"; | 48 case kDrawPicture_OpType: return "DrawPicture"; |
| 55 case DRAW_POS_TEXT: return "Draw Pos Text"; | 49 case kDrawPoints_OpType: return "DrawPoints"; |
| 56 case DRAW_POS_TEXT_H: return "Draw Pos Text H"; | 50 case kDrawPosText_OpType: return "DrawPosText"; |
| 57 case DRAW_RECT: return "Draw Rect"; | 51 case kDrawPosTextH_OpType: return "DrawPosTextH"; |
| 58 case DRAW_RRECT: return "Draw RRect"; | 52 case kDrawRect_OpType: return "DrawRect"; |
| 59 case DRAW_SPRITE: return "Draw Sprite"; | 53 case kDrawRRect_OpType: return "DrawRRect"; |
| 60 case DRAW_TEXT: return "Draw Text"; | 54 case kDrawSprite_OpType: return "DrawSprite"; |
| 61 case DRAW_TEXT_BLOB: return "Draw Text Blob"; | 55 case kDrawText_OpType: return "DrawText"; |
| 62 case DRAW_TEXT_ON_PATH: return "Draw Text On Path"; | 56 case kDrawTextBlob_OpType: return "DrawTextBlob"; |
| 63 case DRAW_VERTICES: return "Draw Vertices"; | 57 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; |
| 64 case RESTORE: return "Restore"; | 58 case kDrawVertices_OpType: return "DrawVertices"; |
| 65 case ROTATE: return "Rotate"; | 59 case kEndCommentGroup_OpType: return "EndCommentGroup"; |
| 66 case SAVE: return "Save"; | 60 case kRestore_OpType: return "Restore"; |
| 67 case SAVE_LAYER: return "Save Layer"; | 61 case kSave_OpType: return "Save"; |
| 68 case SCALE: return "Scale"; | 62 case kSaveLayer_OpType: return "SaveLayer"; |
| 69 case SET_MATRIX: return "SetMatrix"; | 63 case kSetMatrix_OpType: return "SetMatrix"; |
| 70 case SKEW: return "Skew"; | |
| 71 case TRANSLATE: return "Translate"; | |
| 72 case NOOP: return "NoOp"; | |
| 73 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; | |
| 74 case COMMENT: return "Comment"; | |
| 75 case END_COMMENT_GROUP: return "EndCommentGroup"; | |
| 76 case DRAW_DRRECT: return "Draw DRRect"; | |
| 77 default: | 64 default: |
| 78 SkDebugf("DrawType error 0x%08x\n", type); | 65 SkDebugf("OpType error 0x%08x\n", type); |
| 79 SkASSERT(0); | 66 SkASSERT(0); |
| 80 break; | 67 break; |
| 81 } | 68 } |
| 82 SkDEBUGFAIL("DrawType UNUSED\n"); | 69 SkDEBUGFAIL("DrawType UNUSED\n"); |
| 83 return NULL; | 70 return NULL; |
| 84 } | 71 } |
| 85 | 72 |
| 86 SkString SkDrawCommand::toString() const { | 73 SkString SkDrawCommand::toString() const { |
| 87 return SkString(GetCommandString(fDrawType)); | 74 return SkString(GetCommandString(fOpType)); |
| 88 } | 75 } |
| 89 | 76 |
| 90 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) { | 77 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) { |
| 91 fColor = color; | 78 fColor = color; |
| 92 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 79 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
| 93 } | 80 } |
| 94 | 81 |
| 95 void SkClearCommand::execute(SkCanvas* canvas) const { | 82 void SkClearCommand::execute(SkCanvas* canvas) const { |
| 96 canvas->clear(fColor); | 83 canvas->clear(fColor); |
| 97 } | 84 } |
| 98 | 85 |
| 99 namespace { | 86 namespace { |
| 100 | 87 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 p.setStyle(SkPaint::kStroke_Style); | 179 p.setStyle(SkPaint::kStroke_Style); |
| 193 | 180 |
| 194 canvas->drawDRRect(outer, inner, p); | 181 canvas->drawDRRect(outer, inner, p); |
| 195 canvas->restore(); | 182 canvas->restore(); |
| 196 } | 183 } |
| 197 | 184 |
| 198 }; | 185 }; |
| 199 | 186 |
| 200 | 187 |
| 201 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) | 188 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) |
| 202 : INHERITED(CLIP_PATH) { | 189 : INHERITED(kClipPath_OpType) { |
| 203 fPath = path; | 190 fPath = path; |
| 204 fOp = op; | 191 fOp = op; |
| 205 fDoAA = doAA; | 192 fDoAA = doAA; |
| 206 | 193 |
| 207 fInfo.push(SkObjectParser::PathToString(path)); | 194 fInfo.push(SkObjectParser::PathToString(path)); |
| 208 fInfo.push(SkObjectParser::RegionOpToString(op)); | 195 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 209 fInfo.push(SkObjectParser::BoolToString(doAA)); | 196 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 210 } | 197 } |
| 211 | 198 |
| 212 void SkClipPathCommand::execute(SkCanvas* canvas) const { | 199 void SkClipPathCommand::execute(SkCanvas* canvas) const { |
| 213 canvas->clipPath(fPath, fOp, fDoAA); | 200 canvas->clipPath(fPath, fOp, fDoAA); |
| 214 } | 201 } |
| 215 | 202 |
| 216 bool SkClipPathCommand::render(SkCanvas* canvas) const { | 203 bool SkClipPathCommand::render(SkCanvas* canvas) const { |
| 217 render_path(canvas, fPath); | 204 render_path(canvas, fPath); |
| 218 return true; | 205 return true; |
| 219 } | 206 } |
| 220 | 207 |
| 221 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) | 208 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) |
| 222 : INHERITED(CLIP_REGION) { | 209 : INHERITED(kClipRegion_OpType) { |
| 223 fRegion = region; | 210 fRegion = region; |
| 224 fOp = op; | 211 fOp = op; |
| 225 | 212 |
| 226 fInfo.push(SkObjectParser::RegionToString(region)); | 213 fInfo.push(SkObjectParser::RegionToString(region)); |
| 227 fInfo.push(SkObjectParser::RegionOpToString(op)); | 214 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 228 } | 215 } |
| 229 | 216 |
| 230 void SkClipRegionCommand::execute(SkCanvas* canvas) const { | 217 void SkClipRegionCommand::execute(SkCanvas* canvas) const { |
| 231 canvas->clipRegion(fRegion, fOp); | 218 canvas->clipRegion(fRegion, fOp); |
| 232 } | 219 } |
| 233 | 220 |
| 234 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) | 221 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) |
| 235 : INHERITED(CLIP_RECT) { | 222 : INHERITED(kClipRect_OpType) { |
| 236 fRect = rect; | 223 fRect = rect; |
| 237 fOp = op; | 224 fOp = op; |
| 238 fDoAA = doAA; | 225 fDoAA = doAA; |
| 239 | 226 |
| 240 fInfo.push(SkObjectParser::RectToString(rect)); | 227 fInfo.push(SkObjectParser::RectToString(rect)); |
| 241 fInfo.push(SkObjectParser::RegionOpToString(op)); | 228 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 242 fInfo.push(SkObjectParser::BoolToString(doAA)); | 229 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 243 } | 230 } |
| 244 | 231 |
| 245 void SkClipRectCommand::execute(SkCanvas* canvas) const { | 232 void SkClipRectCommand::execute(SkCanvas* canvas) const { |
| 246 canvas->clipRect(fRect, fOp, fDoAA); | 233 canvas->clipRect(fRect, fOp, fDoAA); |
| 247 } | 234 } |
| 248 | 235 |
| 249 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) | 236 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) |
| 250 : INHERITED(CLIP_RRECT) { | 237 : INHERITED(kClipRRect_OpType) { |
| 251 fRRect = rrect; | 238 fRRect = rrect; |
| 252 fOp = op; | 239 fOp = op; |
| 253 fDoAA = doAA; | 240 fDoAA = doAA; |
| 254 | 241 |
| 255 fInfo.push(SkObjectParser::RRectToString(rrect)); | 242 fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 256 fInfo.push(SkObjectParser::RegionOpToString(op)); | 243 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 257 fInfo.push(SkObjectParser::BoolToString(doAA)); | 244 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 258 } | 245 } |
| 259 | 246 |
| 260 void SkClipRRectCommand::execute(SkCanvas* canvas) const { | 247 void SkClipRRectCommand::execute(SkCanvas* canvas) const { |
| 261 canvas->clipRRect(fRRect, fOp, fDoAA); | 248 canvas->clipRRect(fRRect, fOp, fDoAA); |
| 262 } | 249 } |
| 263 | 250 |
| 264 bool SkClipRRectCommand::render(SkCanvas* canvas) const { | 251 bool SkClipRRectCommand::render(SkCanvas* canvas) const { |
| 265 render_rrect(canvas, fRRect); | 252 render_rrect(canvas, fRRect); |
| 266 return true; | 253 return true; |
| 267 } | 254 } |
| 268 | 255 |
| 269 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) | 256 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) |
| 270 : INHERITED(CONCAT) { | 257 : INHERITED(kConcat_OpType) { |
| 271 fMatrix = matrix; | 258 fMatrix = matrix; |
| 272 | 259 |
| 273 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 260 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 274 } | 261 } |
| 275 | 262 |
| 276 void SkConcatCommand::execute(SkCanvas* canvas) const { | 263 void SkConcatCommand::execute(SkCanvas* canvas) const { |
| 277 canvas->concat(fMatrix); | 264 canvas->concat(fMatrix); |
| 278 } | 265 } |
| 279 | 266 |
| 280 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, | 267 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
| 281 const SkPaint* paint) | 268 const SkPaint* paint) |
| 282 : INHERITED(DRAW_BITMAP) { | 269 : INHERITED(kDrawBitmap_OpType) { |
| 283 fBitmap = bitmap; | 270 fBitmap = bitmap; |
| 284 fLeft = left; | 271 fLeft = left; |
| 285 fTop = top; | 272 fTop = top; |
| 286 if (paint) { | 273 if (paint) { |
| 287 fPaint = *paint; | 274 fPaint = *paint; |
| 288 fPaintPtr = &fPaint; | 275 fPaintPtr = &fPaint; |
| 289 } else { | 276 } else { |
| 290 fPaintPtr = NULL; | 277 fPaintPtr = NULL; |
| 291 } | 278 } |
| 292 | 279 |
| 293 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 280 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 294 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); | 281 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 295 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); | 282 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
| 296 if (paint) { | 283 if (paint) { |
| 297 fInfo.push(SkObjectParser::PaintToString(*paint)); | 284 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 298 } | 285 } |
| 299 } | 286 } |
| 300 | 287 |
| 301 void SkDrawBitmapCommand::execute(SkCanvas* canvas) const { | 288 void SkDrawBitmapCommand::execute(SkCanvas* canvas) const { |
| 302 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); | 289 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
| 303 } | 290 } |
| 304 | 291 |
| 305 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { | 292 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
| 306 render_bitmap(canvas, fBitmap); | 293 render_bitmap(canvas, fBitmap); |
| 307 return true; | 294 return true; |
| 308 } | 295 } |
| 309 | 296 |
| 310 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, | 297 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, |
| 311 const SkRect& dst, const SkPain
t* paint) | 298 const SkRect& dst, const SkPain
t* paint) |
| 312 : INHERITED(DRAW_BITMAP_NINE) { | 299 : INHERITED(kDrawBitmapNine_OpType) { |
| 313 fBitmap = bitmap; | 300 fBitmap = bitmap; |
| 314 fCenter = center; | 301 fCenter = center; |
| 315 fDst = dst; | 302 fDst = dst; |
| 316 if (paint) { | 303 if (paint) { |
| 317 fPaint = *paint; | 304 fPaint = *paint; |
| 318 fPaintPtr = &fPaint; | 305 fPaintPtr = &fPaint; |
| 319 } else { | 306 } else { |
| 320 fPaintPtr = NULL; | 307 fPaintPtr = NULL; |
| 321 } | 308 } |
| 322 | 309 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 333 } | 320 } |
| 334 | 321 |
| 335 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { | 322 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
| 336 render_bitmap(canvas, fBitmap); | 323 render_bitmap(canvas, fBitmap); |
| 337 return true; | 324 return true; |
| 338 } | 325 } |
| 339 | 326 |
| 340 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, | 327 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, |
| 341 const SkRect& dst, const SkPain
t* paint, | 328 const SkRect& dst, const SkPain
t* paint, |
| 342 SkCanvas::DrawBitmapRectFlags f
lags) | 329 SkCanvas::DrawBitmapRectFlags f
lags) |
| 343 : INHERITED(DRAW_BITMAP_RECT_TO_RECT) { | 330 : INHERITED(kDrawBitmapRect_OpType) { |
| 344 fBitmap = bitmap; | 331 fBitmap = bitmap; |
| 345 if (src) { | 332 if (src) { |
| 346 fSrc = *src; | 333 fSrc = *src; |
| 347 } else { | 334 } else { |
| 348 fSrc.setEmpty(); | 335 fSrc.setEmpty(); |
| 349 } | 336 } |
| 350 fDst = dst; | 337 fDst = dst; |
| 351 | 338 |
| 352 if (paint) { | 339 if (paint) { |
| 353 fPaint = *paint; | 340 fPaint = *paint; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 371 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { | 358 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { |
| 372 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); | 359 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); |
| 373 } | 360 } |
| 374 | 361 |
| 375 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { | 362 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
| 376 render_bitmap(canvas, fBitmap, this->srcRect()); | 363 render_bitmap(canvas, fBitmap, this->srcRect()); |
| 377 return true; | 364 return true; |
| 378 } | 365 } |
| 379 | 366 |
| 380 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) | 367 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
| 381 : INHERITED(BEGIN_COMMENT_GROUP) | 368 : INHERITED(kBeginCommentGroup_OpType) |
| 382 , fDescription(description) { | 369 , fDescription(description) { |
| 383 SkString* temp = new SkString; | 370 SkString* temp = new SkString; |
| 384 temp->appendf("Description: %s", description); | 371 temp->appendf("Description: %s", description); |
| 385 fInfo.push(temp); | 372 fInfo.push(temp); |
| 386 } | 373 } |
| 387 | 374 |
| 388 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) | 375 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
| 389 : INHERITED(COMMENT) | 376 : INHERITED(kComment_OpType) |
| 390 , fKywd(kywd) | 377 , fKywd(kywd) |
| 391 , fValue(value) { | 378 , fValue(value) { |
| 392 SkString* temp = new SkString; | 379 SkString* temp = new SkString; |
| 393 temp->appendf("%s: %s", kywd, value); | 380 temp->appendf("%s: %s", kywd, value); |
| 394 fInfo.push(temp); | 381 fInfo.push(temp); |
| 395 } | 382 } |
| 396 | 383 |
| 397 SkEndCommentGroupCommand::SkEndCommentGroupCommand() | 384 SkEndCommentGroupCommand::SkEndCommentGroupCommand() |
| 398 : INHERITED(END_COMMENT_GROUP) { | 385 : INHERITED(kEndCommentGroup_OpType) { |
| 399 } | 386 } |
| 400 | 387 |
| 401 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) | 388 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) |
| 402 : INHERITED(DRAW_OVAL) { | 389 : INHERITED(kDrawOval_OpType) { |
| 403 fOval = oval; | 390 fOval = oval; |
| 404 fPaint = paint; | 391 fPaint = paint; |
| 405 | 392 |
| 406 fInfo.push(SkObjectParser::RectToString(oval)); | 393 fInfo.push(SkObjectParser::RectToString(oval)); |
| 407 fInfo.push(SkObjectParser::PaintToString(paint)); | 394 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 408 } | 395 } |
| 409 | 396 |
| 410 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { | 397 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { |
| 411 canvas->drawOval(fOval, fPaint); | 398 canvas->drawOval(fOval, fPaint); |
| 412 } | 399 } |
| 413 | 400 |
| 414 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { | 401 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { |
| 415 canvas->clear(0xFFFFFFFF); | 402 canvas->clear(0xFFFFFFFF); |
| 416 canvas->save(); | 403 canvas->save(); |
| 417 | 404 |
| 418 xlate_and_scale_to_bounds(canvas, fOval); | 405 xlate_and_scale_to_bounds(canvas, fOval); |
| 419 | 406 |
| 420 SkPaint p; | 407 SkPaint p; |
| 421 p.setColor(SK_ColorBLACK); | 408 p.setColor(SK_ColorBLACK); |
| 422 p.setStyle(SkPaint::kStroke_Style); | 409 p.setStyle(SkPaint::kStroke_Style); |
| 423 | 410 |
| 424 canvas->drawOval(fOval, p); | 411 canvas->drawOval(fOval, p); |
| 425 canvas->restore(); | 412 canvas->restore(); |
| 426 | 413 |
| 427 return true; | 414 return true; |
| 428 } | 415 } |
| 429 | 416 |
| 430 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) | 417 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
| 431 : INHERITED(DRAW_PAINT) { | 418 : INHERITED(kDrawPaint_OpType) { |
| 432 fPaint = paint; | 419 fPaint = paint; |
| 433 | 420 |
| 434 fInfo.push(SkObjectParser::PaintToString(paint)); | 421 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 435 } | 422 } |
| 436 | 423 |
| 437 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { | 424 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { |
| 438 canvas->drawPaint(fPaint); | 425 canvas->drawPaint(fPaint); |
| 439 } | 426 } |
| 440 | 427 |
| 441 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { | 428 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
| 442 canvas->clear(0xFFFFFFFF); | 429 canvas->clear(0xFFFFFFFF); |
| 443 canvas->drawPaint(fPaint); | 430 canvas->drawPaint(fPaint); |
| 444 return true; | 431 return true; |
| 445 } | 432 } |
| 446 | 433 |
| 447 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) | 434 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) |
| 448 : INHERITED(DRAW_PATH) { | 435 : INHERITED(kDrawPath_OpType) { |
| 449 fPath = path; | 436 fPath = path; |
| 450 fPaint = paint; | 437 fPaint = paint; |
| 451 | 438 |
| 452 fInfo.push(SkObjectParser::PathToString(path)); | 439 fInfo.push(SkObjectParser::PathToString(path)); |
| 453 fInfo.push(SkObjectParser::PaintToString(paint)); | 440 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 454 } | 441 } |
| 455 | 442 |
| 456 void SkDrawPathCommand::execute(SkCanvas* canvas) const { | 443 void SkDrawPathCommand::execute(SkCanvas* canvas) const { |
| 457 canvas->drawPath(fPath, fPaint); | 444 canvas->drawPath(fPath, fPaint); |
| 458 } | 445 } |
| 459 | 446 |
| 460 bool SkDrawPathCommand::render(SkCanvas* canvas) const { | 447 bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
| 461 render_path(canvas, fPath); | 448 render_path(canvas, fPath); |
| 462 return true; | 449 return true; |
| 463 } | 450 } |
| 464 | 451 |
| 465 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, | 452 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, |
| 466 const SkMatrix* matrix, | 453 const SkMatrix* matrix, |
| 467 const SkPaint* paint) | 454 const SkPaint* paint) |
| 468 : INHERITED(DRAW_PICTURE) | 455 : INHERITED(kDrawPicture_OpType) |
| 469 , fPicture(SkRef(picture)) | 456 , fPicture(SkRef(picture)) |
| 470 , fMatrixPtr(NULL) | 457 , fMatrixPtr(NULL) |
| 471 , fPaintPtr(NULL) { | 458 , fPaintPtr(NULL) { |
| 472 | 459 |
| 473 if (matrix) { | 460 if (matrix) { |
| 474 fMatrix = *matrix; | 461 fMatrix = *matrix; |
| 475 fMatrixPtr = &fMatrix; | 462 fMatrixPtr = &fMatrix; |
| 476 } | 463 } |
| 477 if (paint) { | 464 if (paint) { |
| 478 fPaint = *paint; | 465 fPaint = *paint; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 504 | 491 |
| 505 canvas->drawPicture(fPicture.get()); | 492 canvas->drawPicture(fPicture.get()); |
| 506 | 493 |
| 507 canvas->restore(); | 494 canvas->restore(); |
| 508 | 495 |
| 509 return true; | 496 return true; |
| 510 } | 497 } |
| 511 | 498 |
| 512 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, | 499 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, |
| 513 const SkPoint pts[], const SkPaint& pai
nt) | 500 const SkPoint pts[], const SkPaint& pai
nt) |
| 514 : INHERITED(DRAW_POINTS) { | 501 : INHERITED(kDrawPoints_OpType) { |
| 515 fMode = mode; | 502 fMode = mode; |
| 516 fCount = count; | 503 fCount = count; |
| 517 fPts = new SkPoint[count]; | 504 fPts = new SkPoint[count]; |
| 518 memcpy(fPts, pts, count * sizeof(SkPoint)); | 505 memcpy(fPts, pts, count * sizeof(SkPoint)); |
| 519 fPaint = paint; | 506 fPaint = paint; |
| 520 | 507 |
| 521 fInfo.push(SkObjectParser::PointsToString(pts, count)); | 508 fInfo.push(SkObjectParser::PointsToString(pts, count)); |
| 522 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, | 509 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, |
| 523 "Points: ")); | 510 "Points: ")); |
| 524 fInfo.push(SkObjectParser::PointModeToString(mode)); | 511 fInfo.push(SkObjectParser::PointModeToString(mode)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 547 p.setStyle(SkPaint::kStroke_Style); | 534 p.setStyle(SkPaint::kStroke_Style); |
| 548 | 535 |
| 549 canvas->drawPoints(fMode, fCount, fPts, p); | 536 canvas->drawPoints(fMode, fCount, fPts, p); |
| 550 canvas->restore(); | 537 canvas->restore(); |
| 551 | 538 |
| 552 return true; | 539 return true; |
| 553 } | 540 } |
| 554 | 541 |
| 555 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, | 542 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, |
| 556 const SkPoint pos[], const SkPaint& p
aint) | 543 const SkPoint pos[], const SkPaint& p
aint) |
| 557 : INHERITED(DRAW_POS_TEXT) { | 544 : INHERITED(kDrawPosText_OpType) { |
| 558 size_t numPts = paint.countText(text, byteLength); | 545 size_t numPts = paint.countText(text, byteLength); |
| 559 | 546 |
| 560 fText = new char[byteLength]; | 547 fText = new char[byteLength]; |
| 561 memcpy(fText, text, byteLength); | 548 memcpy(fText, text, byteLength); |
| 562 fByteLength = byteLength; | 549 fByteLength = byteLength; |
| 563 | 550 |
| 564 fPos = new SkPoint[numPts]; | 551 fPos = new SkPoint[numPts]; |
| 565 memcpy(fPos, pos, numPts * sizeof(SkPoint)); | 552 memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
| 566 | 553 |
| 567 fPaint = paint; | 554 fPaint = paint; |
| 568 | 555 |
| 569 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 556 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 570 // TODO(chudy): Test that this works. | 557 // TODO(chudy): Test that this works. |
| 571 fInfo.push(SkObjectParser::PointsToString(pos, 1)); | 558 fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 572 fInfo.push(SkObjectParser::PaintToString(paint)); | 559 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 573 } | 560 } |
| 574 | 561 |
| 575 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { | 562 void SkDrawPosTextCommand::execute(SkCanvas* canvas) const { |
| 576 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 563 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
| 577 } | 564 } |
| 578 | 565 |
| 579 | 566 |
| 580 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, | 567 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, |
| 581 const SkScalar xpos[], SkScalar con
stY, | 568 const SkScalar xpos[], SkScalar con
stY, |
| 582 const SkPaint& paint) | 569 const SkPaint& paint) |
| 583 : INHERITED(DRAW_POS_TEXT_H) { | 570 : INHERITED(kDrawPosTextH_OpType) { |
| 584 size_t numPts = paint.countText(text, byteLength); | 571 size_t numPts = paint.countText(text, byteLength); |
| 585 | 572 |
| 586 fText = new char[byteLength]; | 573 fText = new char[byteLength]; |
| 587 memcpy(fText, text, byteLength); | 574 memcpy(fText, text, byteLength); |
| 588 fByteLength = byteLength; | 575 fByteLength = byteLength; |
| 589 | 576 |
| 590 fXpos = new SkScalar[numPts]; | 577 fXpos = new SkScalar[numPts]; |
| 591 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); | 578 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
| 592 | 579 |
| 593 fConstY = constY; | 580 fConstY = constY; |
| 594 fPaint = paint; | 581 fPaint = paint; |
| 595 | 582 |
| 596 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 583 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 597 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); | 584 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 598 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); | 585 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 599 fInfo.push(SkObjectParser::PaintToString(paint)); | 586 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 600 } | 587 } |
| 601 | 588 |
| 602 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { | 589 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) const { |
| 603 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); | 590 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
| 604 } | 591 } |
| 605 | 592 |
| 606 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, | 593 SkDrawTextBlobCommand::SkDrawTextBlobCommand(const SkTextBlob* blob, SkScalar x,
SkScalar y, |
| 607 const SkPaint& paint) | 594 const SkPaint& paint) |
| 608 : INHERITED(DRAW_TEXT_BLOB) | 595 : INHERITED(kDrawTextBlob_OpType) |
| 609 , fBlob(blob) | 596 , fBlob(blob) |
| 610 , fXPos(x) | 597 , fXPos(x) |
| 611 , fYPos(y) | 598 , fYPos(y) |
| 612 , fPaint(paint) { | 599 , fPaint(paint) { |
| 613 | 600 |
| 614 blob->ref(); | 601 blob->ref(); |
| 615 | 602 |
| 616 // FIXME: push blob info | 603 // FIXME: push blob info |
| 617 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); | 604 fInfo.push(SkObjectParser::ScalarToString(x, "XPOS: ")); |
| 618 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); | 605 fInfo.push(SkObjectParser::ScalarToString(y, "YPOS: ")); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 631 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); | 618 SkRect bounds = fBlob->bounds().makeOffset(fXPos, fYPos); |
| 632 xlate_and_scale_to_bounds(canvas, bounds); | 619 xlate_and_scale_to_bounds(canvas, bounds); |
| 633 | 620 |
| 634 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); | 621 canvas->drawTextBlob(fBlob.get(), fXPos, fYPos, fPaint); |
| 635 | 622 |
| 636 canvas->restore(); | 623 canvas->restore(); |
| 637 | 624 |
| 638 return true; | 625 return true; |
| 639 } | 626 } |
| 640 | 627 |
| 628 SkDrawPatchCommand::SkDrawPatchCommand(const SkPoint cubics[12], const SkColor c
olors[4], |
| 629 const SkPoint texCoords[4], SkXfermode* x
fermode, |
| 630 const SkPaint& paint) |
| 631 : INHERITED(kDrawPatch_OpType) { |
| 632 memcpy(fCubics, cubics, sizeof(fCubics)); |
| 633 memcpy(fColors, colors, sizeof(fColors)); |
| 634 memcpy(fTexCoords, texCoords, sizeof(fTexCoords)); |
| 635 fXfermode.reset(xfermode); |
| 636 fPaint = paint; |
| 637 |
| 638 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 639 } |
| 640 |
| 641 void SkDrawPatchCommand::execute(SkCanvas* canvas) const { |
| 642 canvas->drawPatch(fCubics, fColors, fTexCoords, fXfermode, fPaint); |
| 643 } |
| 644 |
| 641 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) | 645 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) |
| 642 : INHERITED(DRAW_RECT) { | 646 : INHERITED(kDrawRect_OpType) { |
| 643 fRect = rect; | 647 fRect = rect; |
| 644 fPaint = paint; | 648 fPaint = paint; |
| 645 | 649 |
| 646 fInfo.push(SkObjectParser::RectToString(rect)); | 650 fInfo.push(SkObjectParser::RectToString(rect)); |
| 647 fInfo.push(SkObjectParser::PaintToString(paint)); | 651 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 648 } | 652 } |
| 649 | 653 |
| 650 void SkDrawRectCommand::execute(SkCanvas* canvas) const { | 654 void SkDrawRectCommand::execute(SkCanvas* canvas) const { |
| 651 canvas->drawRect(fRect, fPaint); | 655 canvas->drawRect(fRect, fPaint); |
| 652 } | 656 } |
| 653 | 657 |
| 654 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) | 658 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) |
| 655 : INHERITED(DRAW_RRECT) { | 659 : INHERITED(kDrawRRect_OpType) { |
| 656 fRRect = rrect; | 660 fRRect = rrect; |
| 657 fPaint = paint; | 661 fPaint = paint; |
| 658 | 662 |
| 659 fInfo.push(SkObjectParser::RRectToString(rrect)); | 663 fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 660 fInfo.push(SkObjectParser::PaintToString(paint)); | 664 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 661 } | 665 } |
| 662 | 666 |
| 663 void SkDrawRRectCommand::execute(SkCanvas* canvas) const { | 667 void SkDrawRRectCommand::execute(SkCanvas* canvas) const { |
| 664 canvas->drawRRect(fRRect, fPaint); | 668 canvas->drawRRect(fRRect, fPaint); |
| 665 } | 669 } |
| 666 | 670 |
| 667 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { | 671 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
| 668 render_rrect(canvas, fRRect); | 672 render_rrect(canvas, fRRect); |
| 669 return true; | 673 return true; |
| 670 } | 674 } |
| 671 | 675 |
| 672 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, | 676 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
| 673 const SkRRect& inner, | 677 const SkRRect& inner, |
| 674 const SkPaint& paint) | 678 const SkPaint& paint) |
| 675 : INHERITED(DRAW_DRRECT) { | 679 : INHERITED(kDrawDRRect_OpType) { |
| 676 fOuter = outer; | 680 fOuter = outer; |
| 677 fInner = inner; | 681 fInner = inner; |
| 678 fPaint = paint; | 682 fPaint = paint; |
| 679 | 683 |
| 680 fInfo.push(SkObjectParser::RRectToString(outer)); | 684 fInfo.push(SkObjectParser::RRectToString(outer)); |
| 681 fInfo.push(SkObjectParser::RRectToString(inner)); | 685 fInfo.push(SkObjectParser::RRectToString(inner)); |
| 682 fInfo.push(SkObjectParser::PaintToString(paint)); | 686 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 683 } | 687 } |
| 684 | 688 |
| 685 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { | 689 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { |
| 686 canvas->drawDRRect(fOuter, fInner, fPaint); | 690 canvas->drawDRRect(fOuter, fInner, fPaint); |
| 687 } | 691 } |
| 688 | 692 |
| 689 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { | 693 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
| 690 render_drrect(canvas, fOuter, fInner); | 694 render_drrect(canvas, fOuter, fInner); |
| 691 return true; | 695 return true; |
| 692 } | 696 } |
| 693 | 697 |
| 694 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, | 698 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
| 695 const SkPaint* paint) | 699 const SkPaint* paint) |
| 696 : INHERITED(DRAW_SPRITE) { | 700 : INHERITED(kDrawSprite_OpType) { |
| 697 fBitmap = bitmap; | 701 fBitmap = bitmap; |
| 698 fLeft = left; | 702 fLeft = left; |
| 699 fTop = top; | 703 fTop = top; |
| 700 if (paint) { | 704 if (paint) { |
| 701 fPaint = *paint; | 705 fPaint = *paint; |
| 702 fPaintPtr = &fPaint; | 706 fPaintPtr = &fPaint; |
| 703 } else { | 707 } else { |
| 704 fPaintPtr = NULL; | 708 fPaintPtr = NULL; |
| 705 } | 709 } |
| 706 | 710 |
| 707 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 711 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 708 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); | 712 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 709 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); | 713 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
| 710 if (paint) { | 714 if (paint) { |
| 711 fInfo.push(SkObjectParser::PaintToString(*paint)); | 715 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 712 } | 716 } |
| 713 } | 717 } |
| 714 | 718 |
| 715 void SkDrawSpriteCommand::execute(SkCanvas* canvas) const { | 719 void SkDrawSpriteCommand::execute(SkCanvas* canvas) const { |
| 716 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); | 720 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
| 717 } | 721 } |
| 718 | 722 |
| 719 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { | 723 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
| 720 render_bitmap(canvas, fBitmap); | 724 render_bitmap(canvas, fBitmap); |
| 721 return true; | 725 return true; |
| 722 } | 726 } |
| 723 | 727 |
| 724 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, | 728 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, |
| 725 const SkPaint& paint) | 729 const SkPaint& paint) |
| 726 : INHERITED(DRAW_TEXT) { | 730 : INHERITED(kDrawText_OpType) { |
| 727 fText = new char[byteLength]; | 731 fText = new char[byteLength]; |
| 728 memcpy(fText, text, byteLength); | 732 memcpy(fText, text, byteLength); |
| 729 fByteLength = byteLength; | 733 fByteLength = byteLength; |
| 730 fX = x; | 734 fX = x; |
| 731 fY = y; | 735 fY = y; |
| 732 fPaint = paint; | 736 fPaint = paint; |
| 733 | 737 |
| 734 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 738 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 735 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); | 739 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
| 736 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); | 740 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
| 737 fInfo.push(SkObjectParser::PaintToString(paint)); | 741 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 738 } | 742 } |
| 739 | 743 |
| 740 void SkDrawTextCommand::execute(SkCanvas* canvas) const { | 744 void SkDrawTextCommand::execute(SkCanvas* canvas) const { |
| 741 canvas->drawText(fText, fByteLength, fX, fY, fPaint); | 745 canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
| 742 } | 746 } |
| 743 | 747 |
| 744 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, | 748 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, |
| 745 const SkPath& path, const SkMat
rix* matrix, | 749 const SkPath& path, const SkMat
rix* matrix, |
| 746 const SkPaint& paint) | 750 const SkPaint& paint) |
| 747 : INHERITED(DRAW_TEXT_ON_PATH) { | 751 : INHERITED(kDrawTextOnPath_OpType) { |
| 748 fText = new char[byteLength]; | 752 fText = new char[byteLength]; |
| 749 memcpy(fText, text, byteLength); | 753 memcpy(fText, text, byteLength); |
| 750 fByteLength = byteLength; | 754 fByteLength = byteLength; |
| 751 fPath = path; | 755 fPath = path; |
| 752 if (matrix) { | 756 if (matrix) { |
| 753 fMatrix = *matrix; | 757 fMatrix = *matrix; |
| 754 } else { | 758 } else { |
| 755 fMatrix.setIdentity(); | 759 fMatrix.setIdentity(); |
| 756 } | 760 } |
| 757 fPaint = paint; | 761 fPaint = paint; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 768 canvas->drawTextOnPath(fText, fByteLength, fPath, | 772 canvas->drawTextOnPath(fText, fByteLength, fPath, |
| 769 fMatrix.isIdentity() ? NULL : &fMatrix, | 773 fMatrix.isIdentity() ? NULL : &fMatrix, |
| 770 fPaint); | 774 fPaint); |
| 771 } | 775 } |
| 772 | 776 |
| 773 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, | 777 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, |
| 774 const SkPoint vertices[], const SkP
oint texs[], | 778 const SkPoint vertices[], const SkP
oint texs[], |
| 775 const SkColor colors[], SkXfermode*
xfermode, | 779 const SkColor colors[], SkXfermode*
xfermode, |
| 776 const uint16_t indices[], int index
Count, | 780 const uint16_t indices[], int index
Count, |
| 777 const SkPaint& paint) | 781 const SkPaint& paint) |
| 778 : INHERITED(DRAW_VERTICES) { | 782 : INHERITED(kDrawVertices_OpType) { |
| 779 fVmode = vmode; | 783 fVmode = vmode; |
| 780 | 784 |
| 781 fVertexCount = vertexCount; | 785 fVertexCount = vertexCount; |
| 782 | 786 |
| 783 fVertices = new SkPoint[vertexCount]; | 787 fVertices = new SkPoint[vertexCount]; |
| 784 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); | 788 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
| 785 | 789 |
| 786 if (texs) { | 790 if (texs) { |
| 787 fTexs = new SkPoint[vertexCount]; | 791 fTexs = new SkPoint[vertexCount]; |
| 788 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); | 792 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 delete [] fIndices; | 829 delete [] fIndices; |
| 826 } | 830 } |
| 827 | 831 |
| 828 void SkDrawVerticesCommand::execute(SkCanvas* canvas) const { | 832 void SkDrawVerticesCommand::execute(SkCanvas* canvas) const { |
| 829 canvas->drawVertices(fVmode, fVertexCount, fVertices, | 833 canvas->drawVertices(fVmode, fVertexCount, fVertices, |
| 830 fTexs, fColors, fXfermode, fIndices, | 834 fTexs, fColors, fXfermode, fIndices, |
| 831 fIndexCount, fPaint); | 835 fIndexCount, fPaint); |
| 832 } | 836 } |
| 833 | 837 |
| 834 SkRestoreCommand::SkRestoreCommand() | 838 SkRestoreCommand::SkRestoreCommand() |
| 835 : INHERITED(RESTORE) { | 839 : INHERITED(kRestore_OpType) { |
| 836 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 840 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
| 837 } | 841 } |
| 838 | 842 |
| 839 void SkRestoreCommand::execute(SkCanvas* canvas) const { | 843 void SkRestoreCommand::execute(SkCanvas* canvas) const { |
| 840 canvas->restore(); | 844 canvas->restore(); |
| 841 } | 845 } |
| 842 | 846 |
| 843 SkRotateCommand::SkRotateCommand(SkScalar degrees) | |
| 844 : INHERITED(ROTATE) { | |
| 845 fDegrees = degrees; | |
| 846 | |
| 847 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); | |
| 848 } | |
| 849 | |
| 850 void SkRotateCommand::execute(SkCanvas* canvas) const { | |
| 851 canvas->rotate(fDegrees); | |
| 852 } | |
| 853 | |
| 854 SkSaveCommand::SkSaveCommand() | 847 SkSaveCommand::SkSaveCommand() |
| 855 : INHERITED(SAVE) { | 848 : INHERITED(kSave_OpType) { |
| 856 } | 849 } |
| 857 | 850 |
| 858 void SkSaveCommand::execute(SkCanvas* canvas) const { | 851 void SkSaveCommand::execute(SkCanvas* canvas) const { |
| 859 canvas->save(); | 852 canvas->save(); |
| 860 } | 853 } |
| 861 | 854 |
| 862 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, | 855 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, |
| 863 SkCanvas::SaveFlags flags) | 856 SkCanvas::SaveFlags flags) |
| 864 : INHERITED(SAVE_LAYER) { | 857 : INHERITED(kSaveLayer_OpType) { |
| 865 if (bounds) { | 858 if (bounds) { |
| 866 fBounds = *bounds; | 859 fBounds = *bounds; |
| 867 } else { | 860 } else { |
| 868 fBounds.setEmpty(); | 861 fBounds.setEmpty(); |
| 869 } | 862 } |
| 870 | 863 |
| 871 if (paint) { | 864 if (paint) { |
| 872 fPaint = *paint; | 865 fPaint = *paint; |
| 873 fPaintPtr = &fPaint; | 866 fPaintPtr = &fPaint; |
| 874 } else { | 867 } else { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 888 void SkSaveLayerCommand::execute(SkCanvas* canvas) const { | 881 void SkSaveLayerCommand::execute(SkCanvas* canvas) const { |
| 889 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, | 882 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
| 890 fPaintPtr, | 883 fPaintPtr, |
| 891 fFlags); | 884 fFlags); |
| 892 } | 885 } |
| 893 | 886 |
| 894 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { | 887 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) const { |
| 895 canvas->save(); | 888 canvas->save(); |
| 896 } | 889 } |
| 897 | 890 |
| 898 SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) | |
| 899 : INHERITED(SCALE) { | |
| 900 fSx = sx; | |
| 901 fSy = sy; | |
| 902 | |
| 903 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); | |
| 904 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); | |
| 905 } | |
| 906 | |
| 907 void SkScaleCommand::execute(SkCanvas* canvas) const { | |
| 908 canvas->scale(fSx, fSy); | |
| 909 } | |
| 910 | |
| 911 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) | 891 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) |
| 912 : INHERITED(SET_MATRIX) { | 892 : INHERITED(kSetMatrix_OpType) { |
| 913 fUserMatrix.reset(); | 893 fUserMatrix.reset(); |
| 914 fMatrix = matrix; | 894 fMatrix = matrix; |
| 915 | 895 |
| 916 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 896 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 917 } | 897 } |
| 918 | 898 |
| 919 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 899 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
| 920 fUserMatrix = userMatrix; | 900 fUserMatrix = userMatrix; |
| 921 } | 901 } |
| 922 | 902 |
| 923 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 903 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
| 924 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 904 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
| 925 canvas->setMatrix(temp); | 905 canvas->setMatrix(temp); |
| 926 } | 906 } |
| 927 | 907 |
| 928 SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) | |
| 929 : INHERITED(SKEW) { | |
| 930 fSx = sx; | |
| 931 fSy = sy; | |
| 932 | |
| 933 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); | |
| 934 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); | |
| 935 } | |
| 936 | |
| 937 void SkSkewCommand::execute(SkCanvas* canvas) const { | |
| 938 canvas->skew(fSx, fSy); | |
| 939 } | |
| 940 | |
| 941 SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) | |
| 942 : INHERITED(TRANSLATE) { | |
| 943 fDx = dx; | |
| 944 fDy = dy; | |
| 945 | |
| 946 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); | |
| 947 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); | |
| 948 } | |
| 949 | |
| 950 void SkTranslateCommand::execute(SkCanvas* canvas) const { | |
| 951 canvas->translate(fDx, fDy); | |
| 952 } | |
| 953 | |
| OLD | NEW |