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) |
| 16 : fDrawType(type) |
| 17 , fVisible(true) { |
| 18 } |
| 19 |
15 SkDrawCommand::SkDrawCommand() { | 20 SkDrawCommand::SkDrawCommand() { |
16 fVisible = true; | 21 fVisible = true; |
17 } | 22 } |
18 | 23 |
19 SkDrawCommand::~SkDrawCommand() { | 24 SkDrawCommand::~SkDrawCommand() { |
20 fInfo.deleteAll(); | 25 fInfo.deleteAll(); |
21 } | 26 } |
22 | 27 |
23 const char* SkDrawCommand::GetCommandString(DrawType type) { | 28 const char* SkDrawCommand::GetCommandString(DrawType type) { |
24 switch (type) { | 29 switch (type) { |
(...skipping 24 matching lines...) Expand all Loading... |
49 case DRAW_VERTICES: return "Draw Vertices"; | 54 case DRAW_VERTICES: return "Draw Vertices"; |
50 case RESTORE: return "Restore"; | 55 case RESTORE: return "Restore"; |
51 case ROTATE: return "Rotate"; | 56 case ROTATE: return "Rotate"; |
52 case SAVE: return "Save"; | 57 case SAVE: return "Save"; |
53 case SAVE_LAYER: return "Save Layer"; | 58 case SAVE_LAYER: return "Save Layer"; |
54 case SCALE: return "Scale"; | 59 case SCALE: return "Scale"; |
55 case SET_MATRIX: return "Set Matrix"; | 60 case SET_MATRIX: return "Set Matrix"; |
56 case SKEW: return "Skew"; | 61 case SKEW: return "Skew"; |
57 case TRANSLATE: return "Translate"; | 62 case TRANSLATE: return "Translate"; |
58 case NOOP: return "NoOp"; | 63 case NOOP: return "NoOp"; |
| 64 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; |
| 65 case COMMENT: return "Comment"; |
| 66 case END_COMMENT_GROUP: return "EndCommentGroup"; |
59 default: | 67 default: |
60 SkDebugf("DrawType error 0x%08x\n", type); | 68 SkDebugf("DrawType error 0x%08x\n", type); |
61 SkASSERT(0); | 69 SkASSERT(0); |
62 break; | 70 break; |
63 } | 71 } |
64 SkDEBUGFAIL("DrawType UNUSED\n"); | 72 SkDEBUGFAIL("DrawType UNUSED\n"); |
65 return NULL; | 73 return NULL; |
66 } | 74 } |
67 | 75 |
68 SkString SkDrawCommand::toString() { | 76 SkString SkDrawCommand::toString() { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // TODO: add display of actual data? | 299 // TODO: add display of actual data? |
292 SkString* str = new SkString; | 300 SkString* str = new SkString; |
293 str->appendf("length: %d", (int) length); | 301 str->appendf("length: %d", (int) length); |
294 fInfo.push(str); | 302 fInfo.push(str); |
295 } | 303 } |
296 | 304 |
297 void DrawData::execute(SkCanvas* canvas) { | 305 void DrawData::execute(SkCanvas* canvas) { |
298 canvas->drawData(fData, fLength); | 306 canvas->drawData(fData, fLength); |
299 } | 307 } |
300 | 308 |
| 309 BeginCommentGroup::BeginCommentGroup(const char* description) |
| 310 : INHERITED(BEGIN_COMMENT_GROUP) |
| 311 , fDescription(description) { |
| 312 SkString* temp = new SkString; |
| 313 temp->appendf("Description: %s", description); |
| 314 fInfo.push(temp); |
| 315 } |
| 316 |
| 317 Comment::Comment(const char* kywd, const char* value) |
| 318 : INHERITED(COMMENT) |
| 319 , fKywd(kywd) |
| 320 , fValue(value) { |
| 321 SkString* temp = new SkString; |
| 322 temp->appendf("%s: %s", kywd, value); |
| 323 fInfo.push(temp); |
| 324 } |
| 325 |
| 326 EndCommentGroup::EndCommentGroup() : INHERITED(END_COMMENT_GROUP) { |
| 327 } |
| 328 |
301 DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) { | 329 DrawOval::DrawOval(const SkRect& oval, const SkPaint& paint) { |
302 fOval = oval; | 330 fOval = oval; |
303 fPaint = paint; | 331 fPaint = paint; |
304 fDrawType = DRAW_OVAL; | 332 fDrawType = DRAW_OVAL; |
305 | 333 |
306 fInfo.push(SkObjectParser::RectToString(oval)); | 334 fInfo.push(SkObjectParser::RectToString(oval)); |
307 fInfo.push(SkObjectParser::PaintToString(paint)); | 335 fInfo.push(SkObjectParser::PaintToString(paint)); |
308 } | 336 } |
309 | 337 |
310 void DrawOval::execute(SkCanvas* canvas) { | 338 void DrawOval::execute(SkCanvas* canvas) { |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 fDy = dy; | 731 fDy = dy; |
704 fDrawType = TRANSLATE; | 732 fDrawType = TRANSLATE; |
705 | 733 |
706 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); | 734 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
707 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); | 735 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
708 } | 736 } |
709 | 737 |
710 void Translate::execute(SkCanvas* canvas) { | 738 void Translate::execute(SkCanvas* canvas) { |
711 canvas->translate(fDx, fDy); | 739 canvas->translate(fDx, fDy); |
712 } | 740 } |
OLD | NEW |