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 18 matching lines...) Expand all Loading... |
29 case kClipPath_OpType: return "ClipPath"; | 29 case kClipPath_OpType: return "ClipPath"; |
30 case kClipRegion_OpType: return "ClipRegion"; | 30 case kClipRegion_OpType: return "ClipRegion"; |
31 case kClipRect_OpType: return "ClipRect"; | 31 case kClipRect_OpType: return "ClipRect"; |
32 case kClipRRect_OpType: return "ClipRRect"; | 32 case kClipRRect_OpType: return "ClipRRect"; |
33 case kConcat_OpType: return "Concat"; | 33 case kConcat_OpType: return "Concat"; |
34 case kDrawBitmap_OpType: return "DrawBitmap"; | 34 case kDrawBitmap_OpType: return "DrawBitmap"; |
35 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; | 35 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; |
36 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; | 36 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; |
37 case kDrawClear_OpType: return "DrawClear"; | 37 case kDrawClear_OpType: return "DrawClear"; |
38 case kDrawDRRect_OpType: return "DrawDRRect"; | 38 case kDrawDRRect_OpType: return "DrawDRRect"; |
| 39 case kDrawImage_OpType: return "DrawImage"; |
| 40 case kDrawImageRect_OpType: return "DrawImageRect"; |
39 case kDrawOval_OpType: return "DrawOval"; | 41 case kDrawOval_OpType: return "DrawOval"; |
40 case kDrawPaint_OpType: return "DrawPaint"; | 42 case kDrawPaint_OpType: return "DrawPaint"; |
41 case kDrawPatch_OpType: return "DrawPatch"; | 43 case kDrawPatch_OpType: return "DrawPatch"; |
42 case kDrawPath_OpType: return "DrawPath"; | 44 case kDrawPath_OpType: return "DrawPath"; |
43 case kDrawPoints_OpType: return "DrawPoints"; | 45 case kDrawPoints_OpType: return "DrawPoints"; |
44 case kDrawPosText_OpType: return "DrawPosText"; | 46 case kDrawPosText_OpType: return "DrawPosText"; |
45 case kDrawPosTextH_OpType: return "DrawPosTextH"; | 47 case kDrawPosTextH_OpType: return "DrawPosTextH"; |
46 case kDrawRect_OpType: return "DrawRect"; | 48 case kDrawRect_OpType: return "DrawRect"; |
47 case kDrawRRect_OpType: return "DrawRRect"; | 49 case kDrawRRect_OpType: return "DrawRRect"; |
48 case kDrawSprite_OpType: return "DrawSprite"; | 50 case kDrawSprite_OpType: return "DrawSprite"; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 353 |
352 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { | 354 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { |
353 canvas->drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstrain
t); | 355 canvas->drawBitmapRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fConstrain
t); |
354 } | 356 } |
355 | 357 |
356 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { | 358 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
357 render_bitmap(canvas, fBitmap, this->srcRect()); | 359 render_bitmap(canvas, fBitmap, this->srcRect()); |
358 return true; | 360 return true; |
359 } | 361 } |
360 | 362 |
| 363 SkDrawImageCommand::SkDrawImageCommand(const SkImage* image, SkScalar left, SkSc
alar top, |
| 364 const SkPaint* paint) |
| 365 : INHERITED(kDrawImage_OpType) |
| 366 , fImage(SkRef(image)) |
| 367 , fLeft(left) |
| 368 , fTop(top) { |
| 369 |
| 370 if (paint) { |
| 371 fPaint.set(*paint); |
| 372 } |
| 373 } |
| 374 |
| 375 void SkDrawImageCommand::execute(SkCanvas* canvas) const { |
| 376 canvas->drawImage(fImage, fLeft, fTop, fPaint.getMaybeNull()); |
| 377 } |
| 378 |
| 379 bool SkDrawImageCommand::render(SkCanvas* canvas) const { |
| 380 SkAutoCanvasRestore acr(canvas, true); |
| 381 canvas->clear(0xFFFFFFFF); |
| 382 |
| 383 xlate_and_scale_to_bounds(canvas, SkRect::MakeXYWH(fLeft, fTop, |
| 384 SkIntToScalar(fImage->wid
th()), |
| 385 SkIntToScalar(fImage->hei
ght()))); |
| 386 this->execute(canvas); |
| 387 return true; |
| 388 } |
| 389 |
| 390 SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRec
t* src, |
| 391 const SkRect& dst, const SkPaint*
paint, |
| 392 SkCanvas::SrcRectConstraint const
raint) |
| 393 : INHERITED(kDrawImageRect_OpType) |
| 394 , fImage(SkRef(image)) |
| 395 , fDst(dst) |
| 396 , fConstraint(constraint) { |
| 397 |
| 398 if (src) { |
| 399 fSrc.set(*src); |
| 400 } |
| 401 |
| 402 if (paint) { |
| 403 fPaint.set(*paint); |
| 404 } |
| 405 } |
| 406 |
| 407 void SkDrawImageRectCommand::execute(SkCanvas* canvas) const { |
| 408 canvas->drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull
(), fConstraint); |
| 409 } |
| 410 |
| 411 bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { |
| 412 SkAutoCanvasRestore acr(canvas, true); |
| 413 canvas->clear(0xFFFFFFFF); |
| 414 |
| 415 xlate_and_scale_to_bounds(canvas, fDst); |
| 416 |
| 417 this->execute(canvas); |
| 418 return true; |
| 419 } |
| 420 |
361 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) | 421 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) |
362 : INHERITED(kDrawOval_OpType) { | 422 : INHERITED(kDrawOval_OpType) { |
363 fOval = oval; | 423 fOval = oval; |
364 fPaint = paint; | 424 fPaint = paint; |
365 | 425 |
366 fInfo.push(SkObjectParser::RectToString(oval)); | 426 fInfo.push(SkObjectParser::RectToString(oval)); |
367 fInfo.push(SkObjectParser::PaintToString(paint)); | 427 fInfo.push(SkObjectParser::PaintToString(paint)); |
368 } | 428 } |
369 | 429 |
370 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { | 430 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 947 |
888 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 948 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
889 fUserMatrix = userMatrix; | 949 fUserMatrix = userMatrix; |
890 } | 950 } |
891 | 951 |
892 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 952 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
893 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 953 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
894 canvas->setMatrix(temp); | 954 canvas->setMatrix(temp); |
895 } | 955 } |
896 | 956 |
OLD | NEW |