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" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 fMatrix = matrix; | 266 fMatrix = matrix; |
267 | 267 |
268 fInfo.push(SkObjectParser::MatrixToString(matrix)); | 268 fInfo.push(SkObjectParser::MatrixToString(matrix)); |
269 } | 269 } |
270 | 270 |
271 void SkConcatCommand::execute(SkCanvas* canvas) { | 271 void SkConcatCommand::execute(SkCanvas* canvas) { |
272 canvas->concat(fMatrix); | 272 canvas->concat(fMatrix); |
273 } | 273 } |
274 | 274 |
275 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, | 275 SkDrawBitmapCommand::SkDrawBitmapCommand(const SkBitmap& bitmap, SkScalar left,
SkScalar top, |
276 const SkPaint* paint) | 276 const SkPaint* paint) |
277 : INHERITED(DRAW_BITMAP) { | 277 : INHERITED(DRAW_BITMAP) { |
278 fBitmap = bitmap; | 278 fBitmap = bitmap; |
279 fLeft = left; | 279 fLeft = left; |
280 fTop = top; | 280 fTop = top; |
281 if (NULL != paint) { | 281 if (NULL != paint) { |
282 fPaint = *paint; | 282 fPaint = *paint; |
283 fPaintPtr = &fPaint; | 283 fPaintPtr = &fPaint; |
284 } else { | 284 } else { |
285 fPaintPtr = NULL; | 285 fPaintPtr = NULL; |
286 } | 286 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 495 |
496 void SkDrawPathCommand::execute(SkCanvas* canvas) { | 496 void SkDrawPathCommand::execute(SkCanvas* canvas) { |
497 canvas->drawPath(fPath, fPaint); | 497 canvas->drawPath(fPath, fPaint); |
498 } | 498 } |
499 | 499 |
500 bool SkDrawPathCommand::render(SkCanvas* canvas) const { | 500 bool SkDrawPathCommand::render(SkCanvas* canvas) const { |
501 render_path(canvas, fPath); | 501 render_path(canvas, fPath); |
502 return true; | 502 return true; |
503 } | 503 } |
504 | 504 |
505 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture) | 505 SkDrawPictureCommand::SkDrawPictureCommand(const SkPicture* picture, |
| 506 const SkMatrix* matrix, |
| 507 const SkPaint* paint) |
506 : INHERITED(DRAW_PICTURE) | 508 : INHERITED(DRAW_PICTURE) |
507 , fPicture(SkRef(picture)) { | 509 , fPicture(SkRef(picture)) |
| 510 , fMatrixPtr(NULL) |
| 511 , fPaintPtr(NULL) { |
| 512 |
| 513 if (NULL != matrix) { |
| 514 fMatrix = *matrix; |
| 515 fMatrixPtr = &fMatrix; |
| 516 } |
| 517 if (NULL != paint) { |
| 518 fPaint = *paint; |
| 519 fPaintPtr = &fPaint; |
| 520 } |
| 521 |
508 SkString* temp = new SkString; | 522 SkString* temp = new SkString; |
509 temp->appendf("SkPicture: W: %d H: %d", picture->width(), picture->height())
; | 523 temp->appendf("SkPicture: W: %d H: %d", picture->width(), picture->height())
; |
510 fInfo.push(temp); | 524 fInfo.push(temp); |
| 525 if (NULL != matrix) { |
| 526 fInfo.push(SkObjectParser::MatrixToString(*matrix)); |
| 527 } |
| 528 if (NULL != paint) { |
| 529 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 530 } |
511 } | 531 } |
512 | 532 |
513 void SkDrawPictureCommand::execute(SkCanvas* canvas) { | 533 void SkDrawPictureCommand::execute(SkCanvas* canvas) { |
514 canvas->drawPicture(fPicture); | 534 canvas->drawPicture(fPicture, fMatrixPtr, fPaintPtr); |
515 } | 535 } |
516 | 536 |
517 bool SkDrawPictureCommand::render(SkCanvas* canvas) const { | 537 bool SkDrawPictureCommand::render(SkCanvas* canvas) const { |
518 canvas->clear(0xFFFFFFFF); | 538 canvas->clear(0xFFFFFFFF); |
519 canvas->save(); | 539 canvas->save(); |
520 | 540 |
521 SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->width()), | 541 SkRect bounds = SkRect::MakeWH(SkIntToScalar(fPicture->width()), |
522 SkIntToScalar(fPicture->height())); | 542 SkIntToScalar(fPicture->height())); |
523 xlate_and_scale_to_bounds(canvas, bounds); | 543 xlate_and_scale_to_bounds(canvas, bounds); |
524 | 544 |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 p.setColor(SK_ColorCYAN); | 979 p.setColor(SK_ColorCYAN); |
960 p.setStyle(SkPaint::kStroke_Style); | 980 p.setStyle(SkPaint::kStroke_Style); |
961 canvas->drawRect(fCullRect, p); | 981 canvas->drawRect(fCullRect, p); |
962 } | 982 } |
963 | 983 |
964 SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { } | 984 SkPopCullCommand::SkPopCullCommand() : INHERITED(POP_CULL) { } |
965 | 985 |
966 void SkPopCullCommand::execute(SkCanvas* canvas) { | 986 void SkPopCullCommand::execute(SkCanvas* canvas) { |
967 canvas->popCull(); | 987 canvas->popCull(); |
968 } | 988 } |
OLD | NEW |