OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkStrokeRec.h" | 8 #include "SkStrokeRec.h" |
9 #include "SkPaintDefaults.h" | 9 #include "SkPaintDefaults.h" |
10 | 10 |
11 // must be < 0, since ==0 means hairline, and >0 means normal stroke | 11 // must be < 0, since ==0 means hairline, and >0 means normal stroke |
12 #define kStrokeRec_FillStyleWidth (-SK_Scalar1) | 12 #define kStrokeRec_FillStyleWidth (-SK_Scalar1) |
13 | 13 |
14 SkStrokeRec::SkStrokeRec(InitStyle s) { | 14 SkStrokeRec::SkStrokeRec(InitStyle s) { |
15 fWidth = (kFill_InitStyle == s) ? kStrokeRec_FillStyleWidth : 0; | 15 fWidth = (kFill_InitStyle == s) ? kStrokeRec_FillStyleWidth : 0; |
16 fMiterLimit = SkPaintDefaults_MiterLimit; | 16 fMiterLimit = SkPaintDefaults_MiterLimit; |
17 fCap = SkPaint::kDefault_Cap; | 17 fCap = SkPaint::kDefault_Cap; |
18 fJoin = SkPaint::kDefault_Join; | 18 fJoin = SkPaint::kDefault_Join; |
19 fStrokeAndFill = false; | 19 fStrokeAndFill = false; |
20 } | 20 } |
21 | 21 |
22 SkStrokeRec::SkStrokeRec(const SkStrokeRec& src) { | 22 SkStrokeRec::SkStrokeRec(const SkStrokeRec& src) { |
23 memcpy(this, &src, sizeof(src)); | 23 memcpy(this, &src, sizeof(src)); |
24 } | 24 } |
25 | 25 |
26 SkStrokeRec::SkStrokeRec(const SkPaint& paint) { | 26 SkStrokeRec::SkStrokeRec(const SkPaint& paint) { |
27 switch (paint.getStyle()) { | 27 this->init(paint, paint.getStyle()); |
| 28 } |
| 29 |
| 30 SkStrokeRec::SkStrokeRec(const SkPaint& paint, SkPaint::Style styleOverride) { |
| 31 this->init(paint, styleOverride); |
| 32 } |
| 33 |
| 34 void SkStrokeRec::init(const SkPaint& paint, SkPaint::Style style) { |
| 35 switch (style) { |
28 case SkPaint::kFill_Style: | 36 case SkPaint::kFill_Style: |
29 fWidth = kStrokeRec_FillStyleWidth; | 37 fWidth = kStrokeRec_FillStyleWidth; |
30 fStrokeAndFill = false; | 38 fStrokeAndFill = false; |
31 break; | 39 break; |
32 case SkPaint::kStroke_Style: | 40 case SkPaint::kStroke_Style: |
33 fWidth = paint.getStrokeWidth(); | 41 fWidth = paint.getStrokeWidth(); |
34 fStrokeAndFill = false; | 42 fStrokeAndFill = false; |
35 break; | 43 break; |
36 case SkPaint::kStrokeAndFill_Style: | 44 case SkPaint::kStrokeAndFill_Style: |
37 if (0 == paint.getStrokeWidth()) { | 45 if (0 == paint.getStrokeWidth()) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 104 |
97 SkStroke stroker; | 105 SkStroke stroker; |
98 stroker.setCap(fCap); | 106 stroker.setCap(fCap); |
99 stroker.setJoin(fJoin); | 107 stroker.setJoin(fJoin); |
100 stroker.setMiterLimit(fMiterLimit); | 108 stroker.setMiterLimit(fMiterLimit); |
101 stroker.setWidth(fWidth); | 109 stroker.setWidth(fWidth); |
102 stroker.setDoFill(fStrokeAndFill); | 110 stroker.setDoFill(fStrokeAndFill); |
103 stroker.strokePath(src, dst); | 111 stroker.strokePath(src, dst); |
104 return true; | 112 return true; |
105 } | 113 } |
OLD | NEW |