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 30 matching lines...) Expand all Loading... |
41 case kDrawImageRect_OpType: return "DrawImageRect"; | 41 case kDrawImageRect_OpType: return "DrawImageRect"; |
42 case kDrawOval_OpType: return "DrawOval"; | 42 case kDrawOval_OpType: return "DrawOval"; |
43 case kDrawPaint_OpType: return "DrawPaint"; | 43 case kDrawPaint_OpType: return "DrawPaint"; |
44 case kDrawPatch_OpType: return "DrawPatch"; | 44 case kDrawPatch_OpType: return "DrawPatch"; |
45 case kDrawPath_OpType: return "DrawPath"; | 45 case kDrawPath_OpType: return "DrawPath"; |
46 case kDrawPoints_OpType: return "DrawPoints"; | 46 case kDrawPoints_OpType: return "DrawPoints"; |
47 case kDrawPosText_OpType: return "DrawPosText"; | 47 case kDrawPosText_OpType: return "DrawPosText"; |
48 case kDrawPosTextH_OpType: return "DrawPosTextH"; | 48 case kDrawPosTextH_OpType: return "DrawPosTextH"; |
49 case kDrawRect_OpType: return "DrawRect"; | 49 case kDrawRect_OpType: return "DrawRect"; |
50 case kDrawRRect_OpType: return "DrawRRect"; | 50 case kDrawRRect_OpType: return "DrawRRect"; |
| 51 case kDrawSprite_OpType: return "DrawSprite"; |
51 case kDrawText_OpType: return "DrawText"; | 52 case kDrawText_OpType: return "DrawText"; |
52 case kDrawTextBlob_OpType: return "DrawTextBlob"; | 53 case kDrawTextBlob_OpType: return "DrawTextBlob"; |
53 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; | 54 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; |
54 case kDrawVertices_OpType: return "DrawVertices"; | 55 case kDrawVertices_OpType: return "DrawVertices"; |
55 case kEndDrawPicture_OpType: return "EndDrawPicture"; | 56 case kEndDrawPicture_OpType: return "EndDrawPicture"; |
56 case kRestore_OpType: return "Restore"; | 57 case kRestore_OpType: return "Restore"; |
57 case kSave_OpType: return "Save"; | 58 case kSave_OpType: return "Save"; |
58 case kSaveLayer_OpType: return "SaveLayer"; | 59 case kSaveLayer_OpType: return "SaveLayer"; |
59 case kSetMatrix_OpType: return "SetMatrix"; | 60 case kSetMatrix_OpType: return "SetMatrix"; |
60 default: | 61 default: |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 | 792 |
792 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { | 793 void SkDrawDRRectCommand::execute(SkCanvas* canvas) const { |
793 canvas->drawDRRect(fOuter, fInner, fPaint); | 794 canvas->drawDRRect(fOuter, fInner, fPaint); |
794 } | 795 } |
795 | 796 |
796 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { | 797 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
797 render_drrect(canvas, fOuter, fInner); | 798 render_drrect(canvas, fOuter, fInner); |
798 return true; | 799 return true; |
799 } | 800 } |
800 | 801 |
| 802 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
| 803 const SkPaint* paint) |
| 804 : INHERITED(kDrawSprite_OpType) { |
| 805 fBitmap = bitmap; |
| 806 fLeft = left; |
| 807 fTop = top; |
| 808 if (paint) { |
| 809 fPaint = *paint; |
| 810 fPaintPtr = &fPaint; |
| 811 } else { |
| 812 fPaintPtr = nullptr; |
| 813 } |
| 814 |
| 815 fInfo.push(SkObjectParser::BitmapToString(bitmap)); |
| 816 fInfo.push(SkObjectParser::IntToString(left, "Left: ")); |
| 817 fInfo.push(SkObjectParser::IntToString(top, "Top: ")); |
| 818 if (paint) { |
| 819 fInfo.push(SkObjectParser::PaintToString(*paint)); |
| 820 } |
| 821 } |
| 822 |
| 823 void SkDrawSpriteCommand::execute(SkCanvas* canvas) const { |
| 824 canvas->drawSprite(fBitmap, fLeft, fTop, fPaintPtr); |
| 825 } |
| 826 |
| 827 bool SkDrawSpriteCommand::render(SkCanvas* canvas) const { |
| 828 render_bitmap(canvas, fBitmap); |
| 829 return true; |
| 830 } |
| 831 |
801 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, | 832 SkDrawTextCommand::SkDrawTextCommand(const void* text, size_t byteLength, SkScal
ar x, SkScalar y, |
802 const SkPaint& paint) | 833 const SkPaint& paint) |
803 : INHERITED(kDrawText_OpType) { | 834 : INHERITED(kDrawText_OpType) { |
804 fText = new char[byteLength]; | 835 fText = new char[byteLength]; |
805 memcpy(fText, text, byteLength); | 836 memcpy(fText, text, byteLength); |
806 fByteLength = byteLength; | 837 fByteLength = byteLength; |
807 fX = x; | 838 fX = x; |
808 fY = y; | 839 fY = y; |
809 fPaint = paint; | 840 fPaint = paint; |
810 | 841 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 1002 |
972 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 1003 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
973 fUserMatrix = userMatrix; | 1004 fUserMatrix = userMatrix; |
974 } | 1005 } |
975 | 1006 |
976 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 1007 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
977 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 1008 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
978 canvas->setMatrix(temp); | 1009 canvas->setMatrix(temp); |
979 } | 1010 } |
980 | 1011 |
OLD | NEW |