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 #include "SkPicture.h" | 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 SkDrawCommand::SkDrawCommand(OpType type) | 17 SkDrawCommand::SkDrawCommand(OpType type) |
18 : fOpType(type) | 18 : fOpType(type) |
19 , fVisible(true) { | 19 , fVisible(true) { |
20 } | 20 } |
21 | 21 |
22 SkDrawCommand::~SkDrawCommand() { | 22 SkDrawCommand::~SkDrawCommand() { |
23 fInfo.deleteAll(); | 23 fInfo.deleteAll(); |
24 } | 24 } |
25 | 25 |
26 const char* SkDrawCommand::GetCommandString(OpType type) { | 26 const char* SkDrawCommand::GetCommandString(OpType type) { |
27 switch (type) { | 27 switch (type) { |
28 case kBeginCommentGroup_OpType: return "BeginCommentGroup"; | |
29 case kBeginDrawPicture_OpType: return "BeginDrawPicture"; | 28 case kBeginDrawPicture_OpType: return "BeginDrawPicture"; |
30 case kClipPath_OpType: return "ClipPath"; | 29 case kClipPath_OpType: return "ClipPath"; |
31 case kClipRegion_OpType: return "ClipRegion"; | 30 case kClipRegion_OpType: return "ClipRegion"; |
32 case kClipRect_OpType: return "ClipRect"; | 31 case kClipRect_OpType: return "ClipRect"; |
33 case kClipRRect_OpType: return "ClipRRect"; | 32 case kClipRRect_OpType: return "ClipRRect"; |
34 case kComment_OpType: return "Comment"; | |
35 case kConcat_OpType: return "Concat"; | 33 case kConcat_OpType: return "Concat"; |
36 case kDrawBitmap_OpType: return "DrawBitmap"; | 34 case kDrawBitmap_OpType: return "DrawBitmap"; |
37 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; | 35 case kDrawBitmapNine_OpType: return "DrawBitmapNine"; |
38 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; | 36 case kDrawBitmapRect_OpType: return "DrawBitmapRect"; |
39 case kDrawClear_OpType: return "DrawClear"; | 37 case kDrawClear_OpType: return "DrawClear"; |
40 case kDrawDRRect_OpType: return "DrawDRRect"; | 38 case kDrawDRRect_OpType: return "DrawDRRect"; |
41 case kDrawOval_OpType: return "DrawOval"; | 39 case kDrawOval_OpType: return "DrawOval"; |
42 case kDrawPaint_OpType: return "DrawPaint"; | 40 case kDrawPaint_OpType: return "DrawPaint"; |
43 case kDrawPatch_OpType: return "DrawPatch"; | 41 case kDrawPatch_OpType: return "DrawPatch"; |
44 case kDrawPath_OpType: return "DrawPath"; | 42 case kDrawPath_OpType: return "DrawPath"; |
45 case kDrawPoints_OpType: return "DrawPoints"; | 43 case kDrawPoints_OpType: return "DrawPoints"; |
46 case kDrawPosText_OpType: return "DrawPosText"; | 44 case kDrawPosText_OpType: return "DrawPosText"; |
47 case kDrawPosTextH_OpType: return "DrawPosTextH"; | 45 case kDrawPosTextH_OpType: return "DrawPosTextH"; |
48 case kDrawRect_OpType: return "DrawRect"; | 46 case kDrawRect_OpType: return "DrawRect"; |
49 case kDrawRRect_OpType: return "DrawRRect"; | 47 case kDrawRRect_OpType: return "DrawRRect"; |
50 case kDrawSprite_OpType: return "DrawSprite"; | 48 case kDrawSprite_OpType: return "DrawSprite"; |
51 case kDrawText_OpType: return "DrawText"; | 49 case kDrawText_OpType: return "DrawText"; |
52 case kDrawTextBlob_OpType: return "DrawTextBlob"; | 50 case kDrawTextBlob_OpType: return "DrawTextBlob"; |
53 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; | 51 case kDrawTextOnPath_OpType: return "DrawTextOnPath"; |
54 case kDrawVertices_OpType: return "DrawVertices"; | 52 case kDrawVertices_OpType: return "DrawVertices"; |
55 case kEndCommentGroup_OpType: return "EndCommentGroup"; | |
56 case kEndDrawPicture_OpType: return "EndDrawPicture"; | 53 case kEndDrawPicture_OpType: return "EndDrawPicture"; |
57 case kRestore_OpType: return "Restore"; | 54 case kRestore_OpType: return "Restore"; |
58 case kSave_OpType: return "Save"; | 55 case kSave_OpType: return "Save"; |
59 case kSaveLayer_OpType: return "SaveLayer"; | 56 case kSaveLayer_OpType: return "SaveLayer"; |
60 case kSetMatrix_OpType: return "SetMatrix"; | 57 case kSetMatrix_OpType: return "SetMatrix"; |
61 default: | 58 default: |
62 SkDebugf("OpType error 0x%08x\n", type); | 59 SkDebugf("OpType error 0x%08x\n", type); |
63 SkASSERT(0); | 60 SkASSERT(0); |
64 break; | 61 break; |
65 } | 62 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 351 |
355 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { | 352 void SkDrawBitmapRectCommand::execute(SkCanvas* canvas) const { |
356 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); | 353 canvas->drawBitmapRectToRect(fBitmap, this->srcRect(), fDst, fPaintPtr, fFla
gs); |
357 } | 354 } |
358 | 355 |
359 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { | 356 bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const { |
360 render_bitmap(canvas, fBitmap, this->srcRect()); | 357 render_bitmap(canvas, fBitmap, this->srcRect()); |
361 return true; | 358 return true; |
362 } | 359 } |
363 | 360 |
364 SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description) | |
365 : INHERITED(kBeginCommentGroup_OpType) | |
366 , fDescription(description) { | |
367 SkString* temp = new SkString; | |
368 temp->appendf("Description: %s", description); | |
369 fInfo.push(temp); | |
370 } | |
371 | |
372 SkCommentCommand::SkCommentCommand(const char* kywd, const char* value) | |
373 : INHERITED(kComment_OpType) | |
374 , fKywd(kywd) | |
375 , fValue(value) { | |
376 SkString* temp = new SkString; | |
377 temp->appendf("%s: %s", kywd, value); | |
378 fInfo.push(temp); | |
379 } | |
380 | |
381 SkEndCommentGroupCommand::SkEndCommentGroupCommand() | |
382 : INHERITED(kEndCommentGroup_OpType) { | |
383 } | |
384 | |
385 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) | 361 SkDrawOvalCommand::SkDrawOvalCommand(const SkRect& oval, const SkPaint& paint) |
386 : INHERITED(kDrawOval_OpType) { | 362 : INHERITED(kDrawOval_OpType) { |
387 fOval = oval; | 363 fOval = oval; |
388 fPaint = paint; | 364 fPaint = paint; |
389 | 365 |
390 fInfo.push(SkObjectParser::RectToString(oval)); | 366 fInfo.push(SkObjectParser::RectToString(oval)); |
391 fInfo.push(SkObjectParser::PaintToString(paint)); | 367 fInfo.push(SkObjectParser::PaintToString(paint)); |
392 } | 368 } |
393 | 369 |
394 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { | 370 void SkDrawOvalCommand::execute(SkCanvas* canvas) const { |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 | 887 |
912 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { | 888 void SkSetMatrixCommand::setUserMatrix(const SkMatrix& userMatrix) { |
913 fUserMatrix = userMatrix; | 889 fUserMatrix = userMatrix; |
914 } | 890 } |
915 | 891 |
916 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { | 892 void SkSetMatrixCommand::execute(SkCanvas* canvas) const { |
917 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); | 893 SkMatrix temp = SkMatrix::Concat(fUserMatrix, fMatrix); |
918 canvas->setMatrix(temp); | 894 canvas->setMatrix(temp); |
919 } | 895 } |
920 | 896 |
OLD | NEW |