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 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // hairline+fill == fill | 93 // hairline+fill == fill |
94 this->setFillStyle(); | 94 this->setFillStyle(); |
95 } else { | 95 } else { |
96 fWidth = width; | 96 fWidth = width; |
97 fStrokeAndFill = strokeAndFill; | 97 fStrokeAndFill = strokeAndFill; |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 #include "SkStroke.h" | 101 #include "SkStroke.h" |
102 | 102 |
| 103 #if defined SK_QUAD_STROKE_APPROXIMATION && defined SK_DEBUG |
| 104 // enables tweaking these values at runtime from SampleApp |
| 105 bool gDebugStrokerErrorSet = false; |
| 106 SkScalar gDebugStrokerError; |
| 107 #endif |
| 108 |
103 bool SkStrokeRec::applyToPath(SkPath* dst, const SkPath& src) const { | 109 bool SkStrokeRec::applyToPath(SkPath* dst, const SkPath& src) const { |
104 if (fWidth <= 0) { // hairline or fill | 110 if (fWidth <= 0) { // hairline or fill |
105 return false; | 111 return false; |
106 } | 112 } |
107 | 113 |
108 SkStroke stroker; | 114 SkStroke stroker; |
109 stroker.setCap(fCap); | 115 stroker.setCap(fCap); |
110 stroker.setJoin(fJoin); | 116 stroker.setJoin(fJoin); |
111 stroker.setMiterLimit(fMiterLimit); | 117 stroker.setMiterLimit(fMiterLimit); |
112 stroker.setWidth(fWidth); | 118 stroker.setWidth(fWidth); |
113 stroker.setDoFill(fStrokeAndFill); | 119 stroker.setDoFill(fStrokeAndFill); |
| 120 #if defined SK_QUAD_STROKE_APPROXIMATION && defined SK_DEBUG |
| 121 stroker.setResScale(gDebugStrokerErrorSet ? gDebugStrokerError : fResScale); |
| 122 #else |
114 stroker.setResScale(fResScale); | 123 stroker.setResScale(fResScale); |
115 #if QUAD_STROKE_APPROXIMATION | |
116 stroker.setError(1); | |
117 #endif | 124 #endif |
118 stroker.strokePath(src, dst); | 125 stroker.strokePath(src, dst); |
119 return true; | 126 return true; |
120 } | 127 } |
121 | 128 |
122 void SkStrokeRec::applyToPaint(SkPaint* paint) const { | 129 void SkStrokeRec::applyToPaint(SkPaint* paint) const { |
123 if (fWidth < 0) { // fill | 130 if (fWidth < 0) { // fill |
124 paint->setStyle(SkPaint::kFill_Style); | 131 paint->setStyle(SkPaint::kFill_Style); |
125 return; | 132 return; |
126 } | 133 } |
127 | 134 |
128 paint->setStyle(fStrokeAndFill ? SkPaint::kStrokeAndFill_Style : SkPaint::kS
troke_Style); | 135 paint->setStyle(fStrokeAndFill ? SkPaint::kStrokeAndFill_Style : SkPaint::kS
troke_Style); |
129 paint->setStrokeWidth(fWidth); | 136 paint->setStrokeWidth(fWidth); |
130 paint->setStrokeMiter(fMiterLimit); | 137 paint->setStrokeMiter(fMiterLimit); |
131 paint->setStrokeCap(fCap); | 138 paint->setStrokeCap(fCap); |
132 paint->setStrokeJoin(fJoin); | 139 paint->setStrokeJoin(fJoin); |
133 } | 140 } |
OLD | NEW |