| 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 |
| 13 // TODO(chudy): Refactor into non subclass model. | 13 // TODO(chudy): Refactor into non subclass model. |
| 14 | 14 |
| 15 SkDrawCommand::SkDrawCommand(DrawType type) | 15 SkDrawCommand::SkDrawCommand(DrawType type) |
| 16 : fDrawType(type) | 16 : fDrawType(type) |
| 17 , fOffset(0) |
| 17 , fVisible(true) { | 18 , fVisible(true) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 SkDrawCommand::SkDrawCommand() { | 21 SkDrawCommand::SkDrawCommand() { |
| 22 fOffset = 0; |
| 21 fVisible = true; | 23 fVisible = true; |
| 22 } | 24 } |
| 23 | 25 |
| 24 SkDrawCommand::~SkDrawCommand() { | 26 SkDrawCommand::~SkDrawCommand() { |
| 25 fInfo.deleteAll(); | 27 fInfo.deleteAll(); |
| 26 } | 28 } |
| 27 | 29 |
| 28 const char* SkDrawCommand::GetCommandString(DrawType type) { | 30 const char* SkDrawCommand::GetCommandString(DrawType type) { |
| 29 switch (type) { | 31 switch (type) { |
| 30 case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break; | 32 case UNUSED: SkDEBUGFAIL("DrawType UNUSED\n"); break; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 break; | 75 break; |
| 74 } | 76 } |
| 75 SkDEBUGFAIL("DrawType UNUSED\n"); | 77 SkDEBUGFAIL("DrawType UNUSED\n"); |
| 76 return NULL; | 78 return NULL; |
| 77 } | 79 } |
| 78 | 80 |
| 79 SkString SkDrawCommand::toString() { | 81 SkString SkDrawCommand::toString() { |
| 80 return SkString(GetCommandString(fDrawType)); | 82 return SkString(GetCommandString(fDrawType)); |
| 81 } | 83 } |
| 82 | 84 |
| 83 SkClearCommand::SkClearCommand(SkColor color) { | 85 SkClearCommand::SkClearCommand(SkColor color) : INHERITED(DRAW_CLEAR) { |
| 84 fColor = color; | 86 fColor = color; |
| 85 fDrawType = DRAW_CLEAR; | |
| 86 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 87 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void SkClearCommand::execute(SkCanvas* canvas) { | 90 void SkClearCommand::execute(SkCanvas* canvas) { |
| 90 canvas->clear(fColor); | 91 canvas->clear(fColor); |
| 91 } | 92 } |
| 92 | 93 |
| 93 namespace { | 94 namespace { |
| 94 | 95 |
| 95 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { | 96 void xlate_and_scale_to_bounds(SkCanvas* canvas, const SkRect& bounds) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 p.setColor(SK_ColorBLACK); | 186 p.setColor(SK_ColorBLACK); |
| 186 p.setStyle(SkPaint::kStroke_Style); | 187 p.setStyle(SkPaint::kStroke_Style); |
| 187 | 188 |
| 188 canvas->drawDRRect(outer, inner, p); | 189 canvas->drawDRRect(outer, inner, p); |
| 189 canvas->restore(); | 190 canvas->restore(); |
| 190 } | 191 } |
| 191 | 192 |
| 192 }; | 193 }; |
| 193 | 194 |
| 194 | 195 |
| 195 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) { | 196 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) |
| 197 : INHERITED(CLIP_PATH) { |
| 196 fPath = path; | 198 fPath = path; |
| 197 fOp = op; | 199 fOp = op; |
| 198 fDoAA = doAA; | 200 fDoAA = doAA; |
| 199 fDrawType = CLIP_PATH; | |
| 200 | 201 |
| 201 fInfo.push(SkObjectParser::PathToString(path)); | 202 fInfo.push(SkObjectParser::PathToString(path)); |
| 202 fInfo.push(SkObjectParser::RegionOpToString(op)); | 203 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 203 fInfo.push(SkObjectParser::BoolToString(doAA)); | 204 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 204 } | 205 } |
| 205 | 206 |
| 206 void SkClipPathCommand::execute(SkCanvas* canvas) { | 207 void SkClipPathCommand::execute(SkCanvas* canvas) { |
| 207 canvas->clipPath(fPath, fOp, fDoAA); | 208 canvas->clipPath(fPath, fOp, fDoAA); |
| 208 } | 209 } |
| 209 | 210 |
| 210 bool SkClipPathCommand::render(SkCanvas* canvas) const { | 211 bool SkClipPathCommand::render(SkCanvas* canvas) const { |
| 211 render_path(canvas, fPath); | 212 render_path(canvas, fPath); |
| 212 return true; | 213 return true; |
| 213 } | 214 } |
| 214 | 215 |
| 215 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) { | 216 SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkRegion::Op op
) |
| 217 : INHERITED(CLIP_REGION) { |
| 216 fRegion = region; | 218 fRegion = region; |
| 217 fOp = op; | 219 fOp = op; |
| 218 fDrawType = CLIP_REGION; | |
| 219 | 220 |
| 220 fInfo.push(SkObjectParser::RegionToString(region)); | 221 fInfo.push(SkObjectParser::RegionToString(region)); |
| 221 fInfo.push(SkObjectParser::RegionOpToString(op)); | 222 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void SkClipRegionCommand::execute(SkCanvas* canvas) { | 225 void SkClipRegionCommand::execute(SkCanvas* canvas) { |
| 225 canvas->clipRegion(fRegion, fOp); | 226 canvas->clipRegion(fRegion, fOp); |
| 226 } | 227 } |
| 227 | 228 |
| 228 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) { | 229 SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkRegion::Op op, bool d
oAA) |
| 230 : INHERITED(CLIP_RECT) { |
| 229 fRect = rect; | 231 fRect = rect; |
| 230 fOp = op; | 232 fOp = op; |
| 231 fDoAA = doAA; | 233 fDoAA = doAA; |
| 232 fDrawType = CLIP_RECT; | |
| 233 | 234 |
| 234 fInfo.push(SkObjectParser::RectToString(rect)); | 235 fInfo.push(SkObjectParser::RectToString(rect)); |
| 235 fInfo.push(SkObjectParser::RegionOpToString(op)); | 236 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 236 fInfo.push(SkObjectParser::BoolToString(doAA)); | 237 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 237 } | 238 } |
| 238 | 239 |
| 239 void SkClipRectCommand::execute(SkCanvas* canvas) { | 240 void SkClipRectCommand::execute(SkCanvas* canvas) { |
| 240 canvas->clipRect(fRect, fOp, fDoAA); | 241 canvas->clipRect(fRect, fOp, fDoAA); |
| 241 } | 242 } |
| 242 | 243 |
| 243 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) { | 244 SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkRegion::Op op, bo
ol doAA) |
| 245 : INHERITED(CLIP_RRECT) { |
| 244 fRRect = rrect; | 246 fRRect = rrect; |
| 245 fOp = op; | 247 fOp = op; |
| 246 fDoAA = doAA; | 248 fDoAA = doAA; |
| 247 fDrawType = CLIP_RRECT; | |
| 248 | 249 |
| 249 fInfo.push(SkObjectParser::RRectToString(rrect)); | 250 fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 250 fInfo.push(SkObjectParser::RegionOpToString(op)); | 251 fInfo.push(SkObjectParser::RegionOpToString(op)); |
| 251 fInfo.push(SkObjectParser::BoolToString(doAA)); | 252 fInfo.push(SkObjectParser::BoolToString(doAA)); |
| 252 } | 253 } |
| 253 | 254 |
| 254 void SkClipRRectCommand::execute(SkCanvas* canvas) { | 255 void SkClipRRectCommand::execute(SkCanvas* canvas) { |
| 255 canvas->clipRRect(fRRect, fOp, fDoAA); | 256 canvas->clipRRect(fRRect, fOp, fDoAA); |
| 256 } | 257 } |
| 257 | 258 |
| 258 bool SkClipRRectCommand::render(SkCanvas* canvas) const { | 259 bool SkClipRRectCommand::render(SkCanvas* canvas) const { |
| 259 render_rrect(canvas, fRRect); | 260 render_rrect(canvas, fRRect); |
| 260 return true; | 261 return true; |
| 261 } | 262 } |
| 262 | 263 |
| 263 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) { | 264 SkConcatCommand::SkConcatCommand(const SkMatrix& matrix) |
| 265 : INHERITED(CONCAT) { |
| 264 fMatrix = matrix; | 266 fMatrix = matrix; |
| 265 fDrawType = CONCAT; | |
| 266 | 267 |
| 267 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 268 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 268 } | 269 } |
| 269 | 270 |
| 270 void SkConcatCommand::execute(SkCanvas* canvas) { | 271 void SkConcatCommand::execute(SkCanvas* canvas) { |
| 271 canvas->concat(fMatrix); | 272 canvas->concat(fMatrix); |
| 272 } | 273 } |
| 273 | 274 |
| 274 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, | 275 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
| 275 const SkPaint* paint) { | 276 const SkPaint* paint) |
| 277 : INHERITED(DRAW_BITMAP) { |
| 276 fBitmap = bitmap; | 278 fBitmap = bitmap; |
| 277 fLeft = left; | 279 fLeft = left; |
| 278 fTop = top; | 280 fTop = top; |
| 279 if (NULL != paint) { | 281 if (NULL != paint) { |
| 280 fPaint = *paint; | 282 fPaint = *paint; |
| 281 fPaintPtr = &fPaint; | 283 fPaintPtr = &fPaint; |
| 282 } else { | 284 } else { |
| 283 fPaintPtr = NULL; | 285 fPaintPtr = NULL; |
| 284 } | 286 } |
| 285 fDrawType = DRAW_BITMAP; | |
| 286 | 287 |
| 287 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 288 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 288 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); | 289 fInfo.push(SkObjectParser::ScalarToString(left, "SkScalar left: ")); |
| 289 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); | 290 fInfo.push(SkObjectParser::ScalarToString(top, "SkScalar top: ")); |
| 290 if (NULL != paint) { | 291 if (NULL != paint) { |
| 291 fInfo.push(SkObjectParser::PaintToString(*paint)); | 292 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 | 295 |
| 295 void SkDrawBitmapCommand::execute(SkCanvas* canvas) { | 296 void SkDrawBitmapCommand::execute(SkCanvas* canvas) { |
| 296 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); | 297 canvas->drawBitmap(fBitmap, fLeft, fTop, fPaintPtr); |
| 297 } | 298 } |
| 298 | 299 |
| 299 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { | 300 bool SkDrawBitmapCommand::render(SkCanvas* canvas) const { |
| 300 render_bitmap(canvas, fBitmap); | 301 render_bitmap(canvas, fBitmap); |
| 301 return true; | 302 return true; |
| 302 } | 303 } |
| 303 | 304 |
| 304 SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, | 305 SkDrawBitmapMatrixCommand::SkDrawBitmapMatrixCommand(const SkBitmap& bitmap, |
| 305 const SkMatrix& matrix, | 306 const SkMatrix& matrix, |
| 306 const SkPaint* paint) { | 307 const SkPaint* paint) |
| 308 : INHERITED(DRAW_BITMAP_MATRIX) { |
| 307 fBitmap = bitmap; | 309 fBitmap = bitmap; |
| 308 fMatrix = matrix; | 310 fMatrix = matrix; |
| 309 if (NULL != paint) { | 311 if (NULL != paint) { |
| 310 fPaint = *paint; | 312 fPaint = *paint; |
| 311 fPaintPtr = &fPaint; | 313 fPaintPtr = &fPaint; |
| 312 } else { | 314 } else { |
| 313 fPaintPtr = NULL; | 315 fPaintPtr = NULL; |
| 314 } | 316 } |
| 315 fDrawType = DRAW_BITMAP_MATRIX; | |
| 316 | 317 |
| 317 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 318 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 318 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 319 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 319 if (NULL != paint) { | 320 if (NULL != paint) { |
| 320 fInfo.push(SkObjectParser::PaintToString(*paint)); | 321 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 321 } | 322 } |
| 322 } | 323 } |
| 323 | 324 |
| 324 void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) { | 325 void SkDrawBitmapMatrixCommand::execute(SkCanvas* canvas) { |
| 325 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); | 326 canvas->drawBitmapMatrix(fBitmap, fMatrix, fPaintPtr); |
| 326 } | 327 } |
| 327 | 328 |
| 328 bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { | 329 bool SkDrawBitmapMatrixCommand::render(SkCanvas* canvas) const { |
| 329 render_bitmap(canvas, fBitmap); | 330 render_bitmap(canvas, fBitmap); |
| 330 return true; | 331 return true; |
| 331 } | 332 } |
| 332 | 333 |
| 333 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, | 334 SkDrawBitmapNineCommand::SkDrawBitmapNineCommand(const SkBitmap& bitmap, const S
kIRect& center, |
| 334 const SkRect& dst, const SkPain
t* paint) { | 335 const SkRect& dst, const SkPain
t* paint) |
| 336 : INHERITED(DRAW_BITMAP_NINE) { |
| 335 fBitmap = bitmap; | 337 fBitmap = bitmap; |
| 336 fCenter = center; | 338 fCenter = center; |
| 337 fDst = dst; | 339 fDst = dst; |
| 338 if (NULL != paint) { | 340 if (NULL != paint) { |
| 339 fPaint = *paint; | 341 fPaint = *paint; |
| 340 fPaintPtr = &fPaint; | 342 fPaintPtr = &fPaint; |
| 341 } else { | 343 } else { |
| 342 fPaintPtr = NULL; | 344 fPaintPtr = NULL; |
| 343 } | 345 } |
| 344 fDrawType = DRAW_BITMAP_NINE; | |
| 345 | 346 |
| 346 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 347 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 347 fInfo.push(SkObjectParser::IRectToString(center)); | 348 fInfo.push(SkObjectParser::IRectToString(center)); |
| 348 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 349 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 349 if (NULL != paint) { | 350 if (NULL != paint) { |
| 350 fInfo.push(SkObjectParser::PaintToString(*paint)); | 351 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 351 } | 352 } |
| 352 } | 353 } |
| 353 | 354 |
| 354 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) { | 355 void SkDrawBitmapNineCommand::execute(SkCanvas* canvas) { |
| 355 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); | 356 canvas->drawBitmapNine(fBitmap, fCenter, fDst, fPaintPtr); |
| 356 } | 357 } |
| 357 | 358 |
| 358 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { | 359 bool SkDrawBitmapNineCommand::render(SkCanvas* canvas) const { |
| 359 render_bitmap(canvas, fBitmap); | 360 render_bitmap(canvas, fBitmap); |
| 360 return true; | 361 return true; |
| 361 } | 362 } |
| 362 | 363 |
| 363 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, | 364 SkDrawBitmapRectCommand::SkDrawBitmapRectCommand(const SkBitmap& bitmap, const S
kRect* src, |
| 364 const SkRect& dst, const SkPain
t* paint, | 365 const SkRect& dst, const SkPain
t* paint, |
| 365 SkCanvas::DrawBitmapRectFlags f
lags) { | 366 SkCanvas::DrawBitmapRectFlags f
lags) |
| 367 : INHERITED(DRAW_BITMAP_RECT_TO_RECT) { |
| 366 fBitmap = bitmap; | 368 fBitmap = bitmap; |
| 367 if (NULL != src) { | 369 if (NULL != src) { |
| 368 fSrc = *src; | 370 fSrc = *src; |
| 369 } else { | 371 } else { |
| 370 fSrc.setEmpty(); | 372 fSrc.setEmpty(); |
| 371 } | 373 } |
| 372 fDst = dst; | 374 fDst = dst; |
| 373 | 375 |
| 374 if (NULL != paint) { | 376 if (NULL != paint) { |
| 375 fPaint = *paint; | 377 fPaint = *paint; |
| 376 fPaintPtr = &fPaint; | 378 fPaintPtr = &fPaint; |
| 377 } else { | 379 } else { |
| 378 fPaintPtr = NULL; | 380 fPaintPtr = NULL; |
| 379 } | 381 } |
| 380 fFlags = flags; | 382 fFlags = flags; |
| 381 | 383 |
| 382 fDrawType = DRAW_BITMAP_RECT_TO_RECT; | |
| 383 | |
| 384 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 384 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 385 if (NULL != src) { | 385 if (NULL != src) { |
| 386 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); | 386 fInfo.push(SkObjectParser::RectToString(*src, "Src: ")); |
| 387 } | 387 } |
| 388 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); | 388 fInfo.push(SkObjectParser::RectToString(dst, "Dst: ")); |
| 389 if (NULL != paint) { | 389 if (NULL != paint) { |
| 390 fInfo.push(SkObjectParser::PaintToString(*paint)); | 390 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 391 } | 391 } |
| 392 fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: ")); | 392 fInfo.push(SkObjectParser::IntToString(fFlags, "Flags: ")); |
| 393 } | 393 } |
| 394 | 394 |
| 395 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) { | 395 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) { |
| 396 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); | 396 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); |
| 397 } | 397 } |
| 398 | 398 |
| 399 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { | 399 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
| 400 render_bitmap(canvas, fBitmap, this->srcRect()); | 400 render_bitmap(canvas, fBitmap, this->srcRect()); |
| 401 return true; | 401 return true; |
| 402 } | 402 } |
| 403 | 403 |
| 404 SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length) { | 404 SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length) |
| 405 : INHERITED(DRAW_DATA) { |
| 405 fData = new char[length]; | 406 fData = new char[length]; |
| 406 memcpy(fData, data, length); | 407 memcpy(fData, data, length); |
| 407 fLength = length; | 408 fLength = length; |
| 408 fDrawType = DRAW_DATA; | |
| 409 | 409 |
| 410 // TODO: add display of actual data? | 410 // TODO: add display of actual data? |
| 411 SkString* str = new SkString; | 411 SkString* str = new SkString; |
| 412 str->appendf("length: %d", (int) length); | 412 str->appendf("length: %d", (int) length); |
| 413 fInfo.push(str); | 413 fInfo.push(str); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void SkDrawDataCommand::execute(SkCanvas* canvas) { | 416 void SkDrawDataCommand::execute(SkCanvas* canvas) { |
| 417 canvas->drawData(fData, fLength); | 417 canvas->drawData(fData, fLength); |
| 418 } | 418 } |
| 419 | 419 |
| 420 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) | 420 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) |
| 421 : INHERITED(BEGIN_COMMENT_GROUP) | 421 : INHERITED(BEGIN_COMMENT_GROUP) |
| 422 , fDescription(description) { | 422 , fDescription(description) { |
| 423 SkString* temp = new SkString; | 423 SkString* temp = new SkString; |
| 424 temp->appendf("Description: %s", description); | 424 temp->appendf("Description: %s", description); |
| 425 fInfo.push(temp); | 425 fInfo.push(temp); |
| 426 } | 426 } |
| 427 | 427 |
| 428 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) | 428 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) |
| 429 : INHERITED(COMMENT) | 429 : INHERITED(COMMENT) |
| 430 , fKywd(kywd) | 430 , fKywd(kywd) |
| 431 , fValue(value) { | 431 , fValue(value) { |
| 432 SkString* temp = new SkString; | 432 SkString* temp = new SkString; |
| 433 temp->appendf("%s: %s", kywd, value); | 433 temp->appendf("%s: %s", kywd, value); |
| 434 fInfo.push(temp); | 434 fInfo.push(temp); |
| 435 } | 435 } |
| 436 | 436 |
| 437 SkEndCommentGroupCommand::SkEndCommentGroupCommand() : INHERITED(END_COMMENT_GRO
UP) { | 437 SkEndCommentGroupCommand::SkEndCommentGroupCommand() |
| 438 : INHERITED(END_COMMENT_GROUP) { |
| 438 } | 439 } |
| 439 | 440 |
| 440 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) { | 441 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) |
| 442 : INHERITED(DRAW_OVAL) { |
| 441 fOval = oval; | 443 fOval = oval; |
| 442 fPaint = paint; | 444 fPaint = paint; |
| 443 fDrawType = DRAW_OVAL; | |
| 444 | 445 |
| 445 fInfo.push(SkObjectParser::RectToString(oval)); | 446 fInfo.push(SkObjectParser::RectToString(oval)); |
| 446 fInfo.push(SkObjectParser::PaintToString(paint)); | 447 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 447 } | 448 } |
| 448 | 449 |
| 449 void SkDrawOvalCommand::execute(SkCanvas* canvas) { | 450 void SkDrawOvalCommand::execute(SkCanvas* canvas) { |
| 450 canvas->drawOval(fOval, fPaint); | 451 canvas->drawOval(fOval, fPaint); |
| 451 } | 452 } |
| 452 | 453 |
| 453 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { | 454 bool SkDrawOvalCommand::render(SkCanvas* canvas) const { |
| 454 canvas->clear(0xFFFFFFFF); | 455 canvas->clear(0xFFFFFFFF); |
| 455 canvas->save(); | 456 canvas->save(); |
| 456 | 457 |
| 457 xlate_and_scale_to_bounds(canvas, fOval); | 458 xlate_and_scale_to_bounds(canvas, fOval); |
| 458 | 459 |
| 459 SkPaint p; | 460 SkPaint p; |
| 460 p.setColor(SK_ColorBLACK); | 461 p.setColor(SK_ColorBLACK); |
| 461 p.setStyle(SkPaint::kStroke_Style); | 462 p.setStyle(SkPaint::kStroke_Style); |
| 462 | 463 |
| 463 canvas->drawOval(fOval, p); | 464 canvas->drawOval(fOval, p); |
| 464 canvas->restore(); | 465 canvas->restore(); |
| 465 | 466 |
| 466 return true; | 467 return true; |
| 467 } | 468 } |
| 468 | 469 |
| 469 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) { | 470 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
| 471 : INHERITED(DRAW_PAINT) { |
| 470 fPaint = paint; | 472 fPaint = paint; |
| 471 fDrawType = DRAW_PAINT; | |
| 472 | 473 |
| 473 fInfo.push(SkObjectParser::PaintToString(paint)); | 474 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 474 } | 475 } |
| 475 | 476 |
| 476 void SkDrawPaintCommand::execute(SkCanvas* canvas) { | 477 void SkDrawPaintCommand::execute(SkCanvas* canvas) { |
| 477 canvas->drawPaint(fPaint); | 478 canvas->drawPaint(fPaint); |
| 478 } | 479 } |
| 479 | 480 |
| 480 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { | 481 bool SkDrawPaintCommand::render(SkCanvas* canvas) const { |
| 481 canvas->clear(0xFFFFFFFF); | 482 canvas->clear(0xFFFFFFFF); |
| 482 canvas->drawPaint(fPaint); | 483 canvas->drawPaint(fPaint); |
| 483 return true; | 484 return true; |
| 484 } | 485 } |
| 485 | 486 |
| 486 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) { | 487 SkDrawPathCommand::SkDrawPathCommand(const SkPath& path, const SkPaint& paint) |
| 488 : INHERITED(DRAW_PATH) { |
| 487 fPath = path; | 489 fPath = path; |
| 488 fPaint = paint; | 490 fPaint = paint; |
| 489 fDrawType = DRAW_PATH; | |
| 490 | 491 |
| 491 fInfo.push(SkObjectParser::PathToString(path)); | 492 fInfo.push(SkObjectParser::PathToString(path)); |
| 492 fInfo.push(SkObjectParser::PaintToString(paint)); | 493 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 493 } | 494 } |
| 494 | 495 |
| 495 void SkDrawPathCommand::execute(SkCanvas* canvas) { | 496 void SkDrawPathCommand::execute(SkCanvas* canvas) { |
| 496 canvas->drawPath(fPath, fPaint); | 497 canvas->drawPath(fPath, fPaint); |
| 497 } | 498 } |
| 498 | 499 |
| 499 bool SkDrawPathCommand::render(SkCanvas* canvas) const { | 500 bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
| 500 render_path(canvas, fPath); | 501 render_path(canvas, fPath); |
| 501 return true; | 502 return true; |
| 502 } | 503 } |
| 503 | 504 |
| 504 SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture) : | 505 SkDrawPictureCommand::SkDrawPictureCommand(SkPicture& picture) |
| 505 fPicture(picture) { | 506 : INHERITED(DRAW_PICTURE) |
| 506 fDrawType = DRAW_PICTURE; | 507 , fPicture(picture) { |
| 507 SkString* temp = new SkString; | 508 SkString* temp = new SkString; |
| 508 temp->appendf("SkPicture: W: %d H: %d", picture.width(), picture.height()); | 509 temp->appendf("SkPicture: W: %d H: %d", picture.width(), picture.height()); |
| 509 fInfo.push(temp); | 510 fInfo.push(temp); |
| 510 } | 511 } |
| 511 | 512 |
| 512 void SkDrawPictureCommand::execute(SkCanvas* canvas) { | 513 void SkDrawPictureCommand::execute(SkCanvas* canvas) { |
| 513 canvas->drawPicture(fPicture); | 514 canvas->drawPicture(fPicture); |
| 514 } | 515 } |
| 515 | 516 |
| 516 bool SkDrawPictureCommand::render(SkCanvas* canvas) const { | 517 bool SkDrawPictureCommand::render(SkCanvas* canvas) const { |
| 517 canvas->clear(0xFFFFFFFF); | 518 canvas->clear(0xFFFFFFFF); |
| 518 canvas->save(); | 519 canvas->save(); |
| 519 | 520 |
| 520 SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture.width()), | 521 SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture.width()), |
| 521 SkIntToScalar(fPicture.height())); | 522 SkIntToScalar(fPicture.height())); |
| 522 xlate_and_scale_to_bounds(canvas, bounds); | 523 xlate_and_scale_to_bounds(canvas, bounds); |
| 523 | 524 |
| 524 canvas->drawPicture(const_cast<SkPicture&>(fPicture)); | 525 canvas->drawPicture(const_cast<SkPicture&>(fPicture)); |
| 525 | 526 |
| 526 canvas->restore(); | 527 canvas->restore(); |
| 527 | 528 |
| 528 return true; | 529 return true; |
| 529 } | 530 } |
| 530 | 531 |
| 531 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, | 532 SkDrawPointsCommand::SkDrawPointsCommand(SkCanvas::PointMode mode, size_t count, |
| 532 const SkPoint pts[], const SkPaint& pai
nt) { | 533 const SkPoint pts[], const SkPaint& pai
nt) |
| 534 : INHERITED(DRAW_POINTS) { |
| 533 fMode = mode; | 535 fMode = mode; |
| 534 fCount = count; | 536 fCount = count; |
| 535 fPts = new SkPoint[count]; | 537 fPts = new SkPoint[count]; |
| 536 memcpy(fPts, pts, count * sizeof(SkPoint)); | 538 memcpy(fPts, pts, count * sizeof(SkPoint)); |
| 537 fPaint = paint; | 539 fPaint = paint; |
| 538 fDrawType = DRAW_POINTS; | |
| 539 | 540 |
| 540 fInfo.push(SkObjectParser::PointsToString(pts, count)); | 541 fInfo.push(SkObjectParser::PointsToString(pts, count)); |
| 541 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, | 542 fInfo.push(SkObjectParser::ScalarToString(SkIntToScalar((unsigned int)count)
, |
| 542 "Points: ")); | 543 "Points: ")); |
| 543 fInfo.push(SkObjectParser::PointModeToString(mode)); | 544 fInfo.push(SkObjectParser::PointModeToString(mode)); |
| 544 fInfo.push(SkObjectParser::PaintToString(paint)); | 545 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 545 } | 546 } |
| 546 | 547 |
| 547 void SkDrawPointsCommand::execute(SkCanvas* canvas) { | 548 void SkDrawPointsCommand::execute(SkCanvas* canvas) { |
| 548 canvas->drawPoints(fMode, fCount, fPts, fPaint); | 549 canvas->drawPoints(fMode, fCount, fPts, fPaint); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 565 p.setColor(SK_ColorBLACK); | 566 p.setColor(SK_ColorBLACK); |
| 566 p.setStyle(SkPaint::kStroke_Style); | 567 p.setStyle(SkPaint::kStroke_Style); |
| 567 | 568 |
| 568 canvas->drawPoints(fMode, fCount, fPts, p); | 569 canvas->drawPoints(fMode, fCount, fPts, p); |
| 569 canvas->restore(); | 570 canvas->restore(); |
| 570 | 571 |
| 571 return true; | 572 return true; |
| 572 } | 573 } |
| 573 | 574 |
| 574 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, | 575 SkDrawPosTextCommand::SkDrawPosTextCommand(const void* text, size_t byteLength, |
| 575 const SkPoint pos[], const SkPaint& p
aint) { | 576 const SkPoint pos[], const SkPaint& p
aint) |
| 577 : INHERITED(DRAW_POS_TEXT) { |
| 576 size_t numPts = paint.countText(text, byteLength); | 578 size_t numPts = paint.countText(text, byteLength); |
| 577 | 579 |
| 578 fText = new char[byteLength]; | 580 fText = new char[byteLength]; |
| 579 memcpy(fText, text, byteLength); | 581 memcpy(fText, text, byteLength); |
| 580 fByteLength = byteLength; | 582 fByteLength = byteLength; |
| 581 | 583 |
| 582 fPos = new SkPoint[numPts]; | 584 fPos = new SkPoint[numPts]; |
| 583 memcpy(fPos, pos, numPts * sizeof(SkPoint)); | 585 memcpy(fPos, pos, numPts * sizeof(SkPoint)); |
| 584 | 586 |
| 585 fPaint = paint; | 587 fPaint = paint; |
| 586 fDrawType = DRAW_POS_TEXT; | |
| 587 | 588 |
| 588 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 589 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 589 // TODO(chudy): Test that this works. | 590 // TODO(chudy): Test that this works. |
| 590 fInfo.push(SkObjectParser::PointsToString(pos, 1)); | 591 fInfo.push(SkObjectParser::PointsToString(pos, 1)); |
| 591 fInfo.push(SkObjectParser::PaintToString(paint)); | 592 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 592 } | 593 } |
| 593 | 594 |
| 594 void SkDrawPosTextCommand::execute(SkCanvas* canvas) { | 595 void SkDrawPosTextCommand::execute(SkCanvas* canvas) { |
| 595 canvas->drawPosText(fText, fByteLength, fPos, fPaint); | 596 canvas->drawPosText(fText, fByteLength, fPos, fPaint); |
| 596 } | 597 } |
| 597 | 598 |
| 598 | 599 |
| 599 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, | 600 SkDrawPosTextHCommand::SkDrawPosTextHCommand(const void* text, size_t byteLength
, |
| 600 const SkScalar xpos[], SkScalar con
stY, | 601 const SkScalar xpos[], SkScalar con
stY, |
| 601 const SkPaint& paint) { | 602 const SkPaint& paint) |
| 603 : INHERITED(DRAW_POS_TEXT_H) { |
| 602 size_t numPts = paint.countText(text, byteLength); | 604 size_t numPts = paint.countText(text, byteLength); |
| 603 | 605 |
| 604 fText = new char[byteLength]; | 606 fText = new char[byteLength]; |
| 605 memcpy(fText, text, byteLength); | 607 memcpy(fText, text, byteLength); |
| 606 fByteLength = byteLength; | 608 fByteLength = byteLength; |
| 607 | 609 |
| 608 fXpos = new SkScalar[numPts]; | 610 fXpos = new SkScalar[numPts]; |
| 609 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); | 611 memcpy(fXpos, xpos, numPts * sizeof(SkScalar)); |
| 610 | 612 |
| 611 fConstY = constY; | 613 fConstY = constY; |
| 612 fPaint = paint; | 614 fPaint = paint; |
| 613 fDrawType = DRAW_POS_TEXT_H; | |
| 614 | 615 |
| 615 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 616 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 616 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); | 617 fInfo.push(SkObjectParser::ScalarToString(xpos[0], "XPOS: ")); |
| 617 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); | 618 fInfo.push(SkObjectParser::ScalarToString(constY, "SkScalar constY: ")); |
| 618 fInfo.push(SkObjectParser::PaintToString(paint)); | 619 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 619 } | 620 } |
| 620 | 621 |
| 621 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) { | 622 void SkDrawPosTextHCommand::execute(SkCanvas* canvas) { |
| 622 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); | 623 canvas->drawPosTextH(fText, fByteLength, fXpos, fConstY, fPaint); |
| 623 } | 624 } |
| 624 | 625 |
| 625 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) { | 626 SkDrawRectCommand::SkDrawRectCommand(const SkRect& rect, const SkPaint& paint) |
| 627 : INHERITED(DRAW_RECT) { |
| 626 fRect = rect; | 628 fRect = rect; |
| 627 fPaint = paint; | 629 fPaint = paint; |
| 628 fDrawType = DRAW_RECT; | |
| 629 | 630 |
| 630 fInfo.push(SkObjectParser::RectToString(rect)); | 631 fInfo.push(SkObjectParser::RectToString(rect)); |
| 631 fInfo.push(SkObjectParser::PaintToString(paint)); | 632 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 632 } | 633 } |
| 633 | 634 |
| 634 void SkDrawRectCommand::execute(SkCanvas* canvas) { | 635 void SkDrawRectCommand::execute(SkCanvas* canvas) { |
| 635 canvas->drawRect(fRect, fPaint); | 636 canvas->drawRect(fRect, fPaint); |
| 636 } | 637 } |
| 637 | 638 |
| 638 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) { | 639 SkDrawRRectCommand::SkDrawRRectCommand(const SkRRect& rrect, const SkPaint& pain
t) |
| 640 : INHERITED(DRAW_RRECT) { |
| 639 fRRect = rrect; | 641 fRRect = rrect; |
| 640 fPaint = paint; | 642 fPaint = paint; |
| 641 fDrawType = DRAW_RRECT; | |
| 642 | 643 |
| 643 fInfo.push(SkObjectParser::RRectToString(rrect)); | 644 fInfo.push(SkObjectParser::RRectToString(rrect)); |
| 644 fInfo.push(SkObjectParser::PaintToString(paint)); | 645 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 645 } | 646 } |
| 646 | 647 |
| 647 void SkDrawRRectCommand::execute(SkCanvas* canvas) { | 648 void SkDrawRRectCommand::execute(SkCanvas* canvas) { |
| 648 canvas->drawRRect(fRRect, fPaint); | 649 canvas->drawRRect(fRRect, fPaint); |
| 649 } | 650 } |
| 650 | 651 |
| 651 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { | 652 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
| 652 render_rrect(canvas, fRRect); | 653 render_rrect(canvas, fRRect); |
| 653 return true; | 654 return true; |
| 654 } | 655 } |
| 655 | 656 |
| 656 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, | 657 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
| 657 const SkRRect& inner, | 658 const SkRRect& inner, |
| 658 const SkPaint& paint) { | 659 const SkPaint& paint) |
| 660 : INHERITED(DRAW_DRRECT) { |
| 659 fOuter = outer; | 661 fOuter = outer; |
| 660 fInner = inner; | 662 fInner = inner; |
| 661 fPaint = paint; | 663 fPaint = paint; |
| 662 fDrawType = DRAW_DRRECT; | |
| 663 | 664 |
| 664 fInfo.push(SkObjectParser::RRectToString(outer)); | 665 fInfo.push(SkObjectParser::RRectToString(outer)); |
| 665 fInfo.push(SkObjectParser::RRectToString(inner)); | 666 fInfo.push(SkObjectParser::RRectToString(inner)); |
| 666 fInfo.push(SkObjectParser::PaintToString(paint)); | 667 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 667 } | 668 } |
| 668 | 669 |
| 669 void SkDrawDRRectCommand::execute(SkCanvas* canvas) { | 670 void SkDrawDRRectCommand::execute(SkCanvas* canvas) { |
| 670 canvas->drawDRRect(fOuter, fInner, fPaint); | 671 canvas->drawDRRect(fOuter, fInner, fPaint); |
| 671 } | 672 } |
| 672 | 673 |
| 673 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { | 674 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
| 674 render_drrect(canvas, fOuter, fInner); | 675 render_drrect(canvas, fOuter, fInner); |
| 675 return true; | 676 return true; |
| 676 } | 677 } |
| 677 | 678 |
| 678 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, | 679 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
| 679 const SkPaint* paint) { | 680 const SkPaint* paint) |
| 681 : INHERITED(DRAW_SPRITE) { |
| 680 fBitmap = bitmap; | 682 fBitmap = bitmap; |
| 681 fLeft = left; | 683 fLeft = left; |
| 682 fTop = top; | 684 fTop = top; |
| 683 if (NULL != paint) { | 685 if (NULL != paint) { |
| 684 fPaint = *paint; | 686 fPaint = *paint; |
| 685 fPaintPtr = &fPaint; | 687 fPaintPtr = &fPaint; |
| 686 } else { | 688 } else { |
| 687 fPaintPtr = NULL; | 689 fPaintPtr = NULL; |
| 688 } | 690 } |
| 689 fDrawType = DRAW_SPRITE; | |
| 690 | 691 |
| 691 fInfo.push(SkObjectParser::BitmapToString(bitmap)); | 692 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 692 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); | 693 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 693 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); | 694 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
| 694 if (NULL != paint) { | 695 if (NULL != paint) { |
| 695 fInfo.push(SkObjectParser::PaintToString(*paint)); | 696 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 696 } | 697 } |
| 697 } | 698 } |
| 698 | 699 |
| 699 void SkDrawSpriteCommand::execute(SkCanvas* canvas) { | 700 void SkDrawSpriteCommand::execute(SkCanvas* canvas) { |
| 700 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); | 701 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
| 701 } | 702 } |
| 702 | 703 |
| 703 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { | 704 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
| 704 render_bitmap(canvas, fBitmap); | 705 render_bitmap(canvas, fBitmap); |
| 705 return true; | 706 return true; |
| 706 } | 707 } |
| 707 | 708 |
| 708 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, | 709 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, |
| 709 const SkPaint& paint) { | 710 const SkPaint& paint) |
| 711 : INHERITED(DRAW_TEXT) { |
| 710 fText = new char[byteLength]; | 712 fText = new char[byteLength]; |
| 711 memcpy(fText, text, byteLength); | 713 memcpy(fText, text, byteLength); |
| 712 fByteLength = byteLength; | 714 fByteLength = byteLength; |
| 713 fX = x; | 715 fX = x; |
| 714 fY = y; | 716 fY = y; |
| 715 fPaint = paint; | 717 fPaint = paint; |
| 716 fDrawType = DRAW_TEXT; | |
| 717 | 718 |
| 718 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 719 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 719 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); | 720 fInfo.push(SkObjectParser::ScalarToString(x, "SkScalar x: ")); |
| 720 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); | 721 fInfo.push(SkObjectParser::ScalarToString(y, "SkScalar y: ")); |
| 721 fInfo.push(SkObjectParser::PaintToString(paint)); | 722 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 722 } | 723 } |
| 723 | 724 |
| 724 void SkDrawTextCommand::execute(SkCanvas* canvas) { | 725 void SkDrawTextCommand::execute(SkCanvas* canvas) { |
| 725 canvas->drawText(fText, fByteLength, fX, fY, fPaint); | 726 canvas->drawText(fText, fByteLength, fX, fY, fPaint); |
| 726 } | 727 } |
| 727 | 728 |
| 728 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, | 729 SkDrawTextOnPathCommand::SkDrawTextOnPathCommand(const void* text, size_t byteLe
ngth, |
| 729 const SkPath& path, const SkMat
rix* matrix, | 730 const SkPath& path, const SkMat
rix* matrix, |
| 730 const SkPaint& paint) { | 731 const SkPaint& paint) |
| 732 : INHERITED(DRAW_TEXT_ON_PATH) { |
| 731 fText = new char[byteLength]; | 733 fText = new char[byteLength]; |
| 732 memcpy(fText, text, byteLength); | 734 memcpy(fText, text, byteLength); |
| 733 fByteLength = byteLength; | 735 fByteLength = byteLength; |
| 734 fPath = path; | 736 fPath = path; |
| 735 if (NULL != matrix) { | 737 if (NULL != matrix) { |
| 736 fMatrix = *matrix; | 738 fMatrix = *matrix; |
| 737 } else { | 739 } else { |
| 738 fMatrix.setIdentity(); | 740 fMatrix.setIdentity(); |
| 739 } | 741 } |
| 740 fPaint = paint; | 742 fPaint = paint; |
| 741 fDrawType = DRAW_TEXT_ON_PATH; | |
| 742 | 743 |
| 743 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); | 744 fInfo.push(SkObjectParser::TextToString(text, byteLength, paint.getTextEncod
ing())); |
| 744 fInfo.push(SkObjectParser::PathToString(path)); | 745 fInfo.push(SkObjectParser::PathToString(path)); |
| 745 if (NULL != matrix) { | 746 if (NULL != matrix) { |
| 746 fInfo.push(SkObjectParser::MatrixToString(*matrix)); | 747 fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 747 } | 748 } |
| 748 fInfo.push(SkObjectParser::PaintToString(paint)); | 749 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 749 } | 750 } |
| 750 | 751 |
| 751 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) { | 752 void SkDrawTextOnPathCommand::execute(SkCanvas* canvas) { |
| 752 canvas->drawTextOnPath(fText, fByteLength, fPath, | 753 canvas->drawTextOnPath(fText, fByteLength, fPath, |
| 753 fMatrix.isIdentity() ? NULL : &fMatrix, | 754 fMatrix.isIdentity() ? NULL : &fMatrix, |
| 754 fPaint); | 755 fPaint); |
| 755 } | 756 } |
| 756 | 757 |
| 757 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, | 758 SkDrawVerticesCommand::SkDrawVerticesCommand(SkCanvas::VertexMode vmode, int ver
texCount, |
| 758 const SkPoint vertices[], const SkP
oint texs[], | 759 const SkPoint vertices[], const SkP
oint texs[], |
| 759 const SkColor colors[], SkXfermode*
xfermode, | 760 const SkColor colors[], SkXfermode*
xfermode, |
| 760 const uint16_t indices[], int index
Count, | 761 const uint16_t indices[], int index
Count, |
| 761 const SkPaint& paint) { | 762 const SkPaint& paint) |
| 763 : INHERITED(DRAW_VERTICES) { |
| 762 fVmode = vmode; | 764 fVmode = vmode; |
| 763 | 765 |
| 764 fVertexCount = vertexCount; | 766 fVertexCount = vertexCount; |
| 765 | 767 |
| 766 fVertices = new SkPoint[vertexCount]; | 768 fVertices = new SkPoint[vertexCount]; |
| 767 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); | 769 memcpy(fVertices, vertices, vertexCount * sizeof(SkPoint)); |
| 768 | 770 |
| 769 if (NULL != texs) { | 771 if (NULL != texs) { |
| 770 fTexs = new SkPoint[vertexCount]; | 772 fTexs = new SkPoint[vertexCount]; |
| 771 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); | 773 memcpy(fTexs, texs, vertexCount * sizeof(SkPoint)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 787 | 789 |
| 788 if (indexCount > 0) { | 790 if (indexCount > 0) { |
| 789 fIndices = new uint16_t[indexCount]; | 791 fIndices = new uint16_t[indexCount]; |
| 790 memcpy(fIndices, indices, indexCount * sizeof(uint16_t)); | 792 memcpy(fIndices, indices, indexCount * sizeof(uint16_t)); |
| 791 } else { | 793 } else { |
| 792 fIndices = NULL; | 794 fIndices = NULL; |
| 793 } | 795 } |
| 794 | 796 |
| 795 fIndexCount = indexCount; | 797 fIndexCount = indexCount; |
| 796 fPaint = paint; | 798 fPaint = paint; |
| 797 fDrawType = DRAW_VERTICES; | |
| 798 | 799 |
| 799 // TODO(chudy) | 800 // TODO(chudy) |
| 800 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); | 801 fInfo.push(SkObjectParser::CustomTextToString("To be implemented.")); |
| 801 fInfo.push(SkObjectParser::PaintToString(paint)); | 802 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 802 } | 803 } |
| 803 | 804 |
| 804 SkDrawVerticesCommand::~SkDrawVerticesCommand() { | 805 SkDrawVerticesCommand::~SkDrawVerticesCommand() { |
| 805 delete [] fVertices; | 806 delete [] fVertices; |
| 806 delete [] fTexs; | 807 delete [] fTexs; |
| 807 delete [] fColors; | 808 delete [] fColors; |
| 808 SkSafeUnref(fXfermode); | 809 SkSafeUnref(fXfermode); |
| 809 delete [] fIndices; | 810 delete [] fIndices; |
| 810 } | 811 } |
| 811 | 812 |
| 812 void SkDrawVerticesCommand::execute(SkCanvas* canvas) { | 813 void SkDrawVerticesCommand::execute(SkCanvas* canvas) { |
| 813 canvas->drawVertices(fVmode, fVertexCount, fVertices, | 814 canvas->drawVertices(fVmode, fVertexCount, fVertices, |
| 814 fTexs, fColors, fXfermode, fIndices, | 815 fTexs, fColors, fXfermode, fIndices, |
| 815 fIndexCount, fPaint); | 816 fIndexCount, fPaint); |
| 816 } | 817 } |
| 817 | 818 |
| 818 SkRestoreCommand::SkRestoreCommand() { | 819 SkRestoreCommand::SkRestoreCommand() |
| 819 fDrawType = RESTORE; | 820 : INHERITED(RESTORE) { |
| 820 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); | 821 fInfo.push(SkObjectParser::CustomTextToString("No Parameters")); |
| 821 } | 822 } |
| 822 | 823 |
| 823 void SkRestoreCommand::execute(SkCanvas* canvas) { | 824 void SkRestoreCommand::execute(SkCanvas* canvas) { |
| 824 canvas->restore(); | 825 canvas->restore(); |
| 825 } | 826 } |
| 826 | 827 |
| 827 void SkRestoreCommand::trackSaveState(int* state) { | 828 void SkRestoreCommand::trackSaveState(int* state) { |
| 828 (*state)--; | 829 (*state)--; |
| 829 } | 830 } |
| 830 | 831 |
| 831 SkRotateCommand::SkRotateCommand(SkScalar degrees) { | 832 SkRotateCommand::SkRotateCommand(SkScalar degrees) |
| 833 : INHERITED(ROTATE) { |
| 832 fDegrees = degrees; | 834 fDegrees = degrees; |
| 833 fDrawType = ROTATE; | |
| 834 | 835 |
| 835 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); | 836 fInfo.push(SkObjectParser::ScalarToString(degrees, "SkScalar degrees: ")); |
| 836 } | 837 } |
| 837 | 838 |
| 838 void SkRotateCommand::execute(SkCanvas* canvas) { | 839 void SkRotateCommand::execute(SkCanvas* canvas) { |
| 839 canvas->rotate(fDegrees); | 840 canvas->rotate(fDegrees); |
| 840 } | 841 } |
| 841 | 842 |
| 842 SkSaveCommand::SkSaveCommand(SkCanvas::SaveFlags flags) { | 843 SkSaveCommand::SkSaveCommand(SkCanvas::SaveFlags flags) |
| 844 : INHERITED(SAVE) { |
| 843 fFlags = flags; | 845 fFlags = flags; |
| 844 fDrawType = SAVE; | |
| 845 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); | 846 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
| 846 } | 847 } |
| 847 | 848 |
| 848 void SkSaveCommand::execute(SkCanvas* canvas) { | 849 void SkSaveCommand::execute(SkCanvas* canvas) { |
| 849 canvas->save(fFlags); | 850 canvas->save(fFlags); |
| 850 } | 851 } |
| 851 | 852 |
| 852 void SkSaveCommand::trackSaveState(int* state) { | 853 void SkSaveCommand::trackSaveState(int* state) { |
| 853 (*state)++; | 854 (*state)++; |
| 854 } | 855 } |
| 855 | 856 |
| 856 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, | 857 SkSaveLayerCommand::SkSaveLayerCommand(const SkRect* bounds, const SkPaint* pain
t, |
| 857 SkCanvas::SaveFlags flags) { | 858 SkCanvas::SaveFlags flags) |
| 859 : INHERITED(SAVE_LAYER) { |
| 858 if (NULL != bounds) { | 860 if (NULL != bounds) { |
| 859 fBounds = *bounds; | 861 fBounds = *bounds; |
| 860 } else { | 862 } else { |
| 861 fBounds.setEmpty(); | 863 fBounds.setEmpty(); |
| 862 } | 864 } |
| 863 | 865 |
| 864 if (NULL != paint) { | 866 if (NULL != paint) { |
| 865 fPaint = *paint; | 867 fPaint = *paint; |
| 866 fPaintPtr = &fPaint; | 868 fPaintPtr = &fPaint; |
| 867 } else { | 869 } else { |
| 868 fPaintPtr = NULL; | 870 fPaintPtr = NULL; |
| 869 } | 871 } |
| 870 fFlags = flags; | 872 fFlags = flags; |
| 871 fDrawType = SAVE_LAYER; | |
| 872 | 873 |
| 873 if (NULL != bounds) { | 874 if (NULL != bounds) { |
| 874 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); | 875 fInfo.push(SkObjectParser::RectToString(*bounds, "Bounds: ")); |
| 875 } | 876 } |
| 876 if (NULL != paint) { | 877 if (NULL != paint) { |
| 877 fInfo.push(SkObjectParser::PaintToString(*paint)); | 878 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 878 } | 879 } |
| 879 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); | 880 fInfo.push(SkObjectParser::SaveFlagsToString(flags)); |
| 880 } | 881 } |
| 881 | 882 |
| 882 void SkSaveLayerCommand::execute(SkCanvas* canvas) { | 883 void SkSaveLayerCommand::execute(SkCanvas* canvas) { |
| 883 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, | 884 canvas->saveLayer(fBounds.isEmpty() ? NULL : &fBounds, |
| 884 fPaintPtr, | 885 fPaintPtr, |
| 885 fFlags); | 886 fFlags); |
| 886 } | 887 } |
| 887 | 888 |
| 888 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) { | 889 void SkSaveLayerCommand::vizExecute(SkCanvas* canvas) { |
| 889 canvas->save(); | 890 canvas->save(); |
| 890 } | 891 } |
| 891 | 892 |
| 892 void SkSaveLayerCommand::trackSaveState(int* state) { | 893 void SkSaveLayerCommand::trackSaveState(int* state) { |
| 893 (*state)++; | 894 (*state)++; |
| 894 } | 895 } |
| 895 | 896 |
| 896 SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) { | 897 SkScaleCommand::SkScaleCommand(SkScalar sx, SkScalar sy) |
| 898 : INHERITED(SCALE) { |
| 897 fSx = sx; | 899 fSx = sx; |
| 898 fSy = sy; | 900 fSy = sy; |
| 899 fDrawType = SCALE; | |
| 900 | 901 |
| 901 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); | 902 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 902 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); | 903 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
| 903 } | 904 } |
| 904 | 905 |
| 905 void SkScaleCommand::execute(SkCanvas* canvas) { | 906 void SkScaleCommand::execute(SkCanvas* canvas) { |
| 906 canvas->scale(fSx, fSy); | 907 canvas->scale(fSx, fSy); |
| 907 } | 908 } |
| 908 | 909 |
| 909 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) { | 910 SkSetMatrixCommand::SkSetMatrixCommand(const SkMatrix& matrix) |
| 911 : INHERITED(SET_MATRIX) { |
| 910 fMatrix = matrix; | 912 fMatrix = matrix; |
| 911 fDrawType = SET_MATRIX; | |
| 912 | 913 |
| 913 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 914 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
| 914 } | 915 } |
| 915 | 916 |
| 916 void SkSetMatrixCommand::execute(SkCanvas* canvas) { | 917 void SkSetMatrixCommand::execute(SkCanvas* canvas) { |
| 917 canvas->setMatrix(fMatrix); | 918 canvas->setMatrix(fMatrix); |
| 918 } | 919 } |
| 919 | 920 |
| 920 SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) { | 921 SkSkewCommand::SkSkewCommand(SkScalar sx, SkScalar sy) |
| 922 : INHERITED(SKEW) { |
| 921 fSx = sx; | 923 fSx = sx; |
| 922 fSy = sy; | 924 fSy = sy; |
| 923 fDrawType = SKEW; | |
| 924 | 925 |
| 925 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); | 926 fInfo.push(SkObjectParser::ScalarToString(sx, "SkScalar sx: ")); |
| 926 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); | 927 fInfo.push(SkObjectParser::ScalarToString(sy, "SkScalar sy: ")); |
| 927 } | 928 } |
| 928 | 929 |
| 929 void SkSkewCommand::execute(SkCanvas* canvas) { | 930 void SkSkewCommand::execute(SkCanvas* canvas) { |
| 930 canvas->skew(fSx, fSy); | 931 canvas->skew(fSx, fSy); |
| 931 } | 932 } |
| 932 | 933 |
| 933 SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) { | 934 SkTranslateCommand::SkTranslateCommand(SkScalar dx, SkScalar dy) |
| 935 : INHERITED(TRANSLATE) { |
| 934 fDx = dx; | 936 fDx = dx; |
| 935 fDy = dy; | 937 fDy = dy; |
| 936 fDrawType = TRANSLATE; | |
| 937 | 938 |
| 938 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); | 939 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
| 939 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); | 940 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
| 940 } | 941 } |
| 941 | 942 |
| 942 void SkTranslateCommand::execute(SkCanvas* canvas) { | 943 void SkTranslateCommand::execute(SkCanvas* canvas) { |
| 943 canvas->translate(fDx, fDy); | 944 canvas->translate(fDx, fDy); |
| 944 } | 945 } |
| 945 | 946 |
| 946 SkPushCullCommand::SkPushCullCommand(const SkRect& cullRect) | 947 SkPushCullCommand::SkPushCullCommand(const SkRect& cullRect) |
| 947 : fCullRect(cullRect) { | 948 : INHERITED(PUSH_CULL) |
| 948 fDrawType = PUSH_CULL; | 949 , fCullRect(cullRect) { |
| 949 fInfo.push(SkObjectParser::RectToString(cullRect)); | 950 fInfo.push(SkObjectParser::RectToString(cullRect)); |
| 950 } | 951 } |
| 951 | 952 |
| 952 void SkPushCullCommand::execute(SkCanvas* canvas) { | 953 void SkPushCullCommand::execute(SkCanvas* canvas) { |
| 953 canvas->pushCull(fCullRect); | 954 canvas->pushCull(fCullRect); |
| 954 } | 955 } |
| 955 | 956 |
| 956 void SkPushCullCommand::vizExecute(SkCanvas* canvas) { | 957 void SkPushCullCommand::vizExecute(SkCanvas* canvas) { |
| 957 canvas->pushCull(fCullRect); | 958 canvas->pushCull(fCullRect); |
| 958 | 959 |
| 959 SkPaint p; | 960 SkPaint p; |
| 960 p.setColor(SK_ColorCYAN); | 961 p.setColor(SK_ColorCYAN); |
| 961 p.setStyle(SkPaint::kStroke_Style); | 962 p.setStyle(SkPaint::kStroke_Style); |
| 962 canvas->drawRect(fCullRect, p); | 963 canvas->drawRect(fCullRect, p); |
| 963 } | 964 } |
| 964 | 965 |
| 965 SkPopCullCommand::SkPopCullCommand() { | 966 SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { } |
| 966 fDrawType = POP_CULL; | |
| 967 } | |
| 968 | 967 |
| 969 void SkPopCullCommand::execute(SkCanvas* canvas) { | 968 void SkPopCullCommand::execute(SkCanvas* canvas) { |
| 970 canvas->popCull(); | 969 canvas->popCull(); |
| 971 } | 970 } |
| OLD | NEW |