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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 case SAVE: return "Save"; | 57 case SAVE: return "Save"; |
58 case SAVE_LAYER: return "Save Layer"; | 58 case SAVE_LAYER: return "Save Layer"; |
59 case SCALE: return "Scale"; | 59 case SCALE: return "Scale"; |
60 case SET_MATRIX: return "Set Matrix"; | 60 case SET_MATRIX: return "Set Matrix"; |
61 case SKEW: return "Skew"; | 61 case SKEW: return "Skew"; |
62 case TRANSLATE: return "Translate"; | 62 case TRANSLATE: return "Translate"; |
63 case NOOP: return "NoOp"; | 63 case NOOP: return "NoOp"; |
64 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; | 64 case BEGIN_COMMENT_GROUP: return "BeginCommentGroup"; |
65 case COMMENT: return "Comment"; | 65 case COMMENT: return "Comment"; |
66 case END_COMMENT_GROUP: return "EndCommentGroup"; | 66 case END_COMMENT_GROUP: return "EndCommentGroup"; |
| 67 case DRAW_DRRECT: return "Draw DRRect"; |
67 default: | 68 default: |
68 SkDebugf("DrawType error 0x%08x\n", type); | 69 SkDebugf("DrawType error 0x%08x\n", type); |
69 SkASSERT(0); | 70 SkASSERT(0); |
70 break; | 71 break; |
71 } | 72 } |
72 SkDEBUGFAIL("DrawType UNUSED\n"); | 73 SkDEBUGFAIL("DrawType UNUSED\n"); |
73 return NULL; | 74 return NULL; |
74 } | 75 } |
75 | 76 |
76 SkString SkDrawCommand::toString() { | 77 SkString SkDrawCommand::toString() { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 xlate_and_scale_to_bounds(canvas, bounds); | 164 xlate_and_scale_to_bounds(canvas, bounds); |
164 | 165 |
165 SkPaint p; | 166 SkPaint p; |
166 p.setColor(SK_ColorBLACK); | 167 p.setColor(SK_ColorBLACK); |
167 p.setStyle(SkPaint::kStroke_Style); | 168 p.setStyle(SkPaint::kStroke_Style); |
168 | 169 |
169 canvas->drawRRect(rrect, p); | 170 canvas->drawRRect(rrect, p); |
170 canvas->restore(); | 171 canvas->restore(); |
171 } | 172 } |
172 | 173 |
| 174 void render_drrect(SkCanvas* canvas, const SkRRect& outer, const SkRRect& inner)
{ |
| 175 canvas->clear(0xFFFFFFFF); |
| 176 canvas->save(); |
| 177 |
| 178 const SkRect& bounds = outer.getBounds(); |
| 179 |
| 180 xlate_and_scale_to_bounds(canvas, bounds); |
| 181 |
| 182 SkPaint p; |
| 183 p.setColor(SK_ColorBLACK); |
| 184 p.setStyle(SkPaint::kStroke_Style); |
| 185 |
| 186 canvas->drawDRRect(outer, inner, p); |
| 187 canvas->restore(); |
| 188 } |
| 189 |
173 }; | 190 }; |
174 | 191 |
175 | 192 |
176 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) { | 193 SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkRegion::Op op, bool d
oAA) { |
177 fPath = path; | 194 fPath = path; |
178 fOp = op; | 195 fOp = op; |
179 fDoAA = doAA; | 196 fDoAA = doAA; |
180 fDrawType = CLIP_PATH; | 197 fDrawType = CLIP_PATH; |
181 | 198 |
182 fInfo.push(SkObjectParser::PathToString(path)); | 199 fInfo.push(SkObjectParser::PathToString(path)); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 644 |
628 void SkDrawRRectCommand::execute(SkCanvas* canvas) { | 645 void SkDrawRRectCommand::execute(SkCanvas* canvas) { |
629 canvas->drawRRect(fRRect, fPaint); | 646 canvas->drawRRect(fRRect, fPaint); |
630 } | 647 } |
631 | 648 |
632 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { | 649 bool SkDrawRRectCommand::render(SkCanvas* canvas) const { |
633 render_rrect(canvas, fRRect); | 650 render_rrect(canvas, fRRect); |
634 return true; | 651 return true; |
635 } | 652 } |
636 | 653 |
| 654 SkDrawDRRectCommand::SkDrawDRRectCommand(const SkRRect& outer, |
| 655 const SkRRect& inner, |
| 656 const SkPaint& paint) { |
| 657 fOuter = outer; |
| 658 fInner = inner; |
| 659 fPaint = paint; |
| 660 fDrawType = DRAW_DRRECT; |
| 661 |
| 662 fInfo.push(SkObjectParser::RRectToString(outer)); |
| 663 fInfo.push(SkObjectParser::RRectToString(inner)); |
| 664 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 665 } |
| 666 |
| 667 void SkDrawDRRectCommand::execute(SkCanvas* canvas) { |
| 668 canvas->drawDRRect(fOuter, fInner, fPaint); |
| 669 } |
| 670 |
| 671 bool SkDrawDRRectCommand::render(SkCanvas* canvas) const { |
| 672 render_drrect(canvas, fOuter, fInner); |
| 673 return true; |
| 674 } |
| 675 |
637 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, | 676 SkDrawSpriteCommand::SkDrawSpriteCommand(const SkBitmap& bitmap, int left, int t
op, |
638 const SkPaint* paint) { | 677 const SkPaint* paint) { |
639 fBitmap = bitmap; | 678 fBitmap = bitmap; |
640 fLeft = left; | 679 fLeft = left; |
641 fTop = top; | 680 fTop = top; |
642 if (NULL != paint) { | 681 if (NULL != paint) { |
643 fPaint = *paint; | 682 fPaint = *paint; |
644 fPaintPtr = &fPaint; | 683 fPaintPtr = &fPaint; |
645 } else { | 684 } else { |
646 fPaintPtr = NULL; | 685 fPaintPtr = NULL; |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 fDy = dy; | 929 fDy = dy; |
891 fDrawType = TRANSLATE; | 930 fDrawType = TRANSLATE; |
892 | 931 |
893 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); | 932 fInfo.push(SkObjectParser::ScalarToString(dx, "SkScalar dx: ")); |
894 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); | 933 fInfo.push(SkObjectParser::ScalarToString(dy, "SkScalar dy: ")); |
895 } | 934 } |
896 | 935 |
897 void SkTranslateCommand::execute(SkCanvas* canvas) { | 936 void SkTranslateCommand::execute(SkCanvas* canvas) { |
898 canvas->translate(fDx, fDy); | 937 canvas->translate(fDx, fDy); |
899 } | 938 } |
OLD | NEW |