OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "GrStyle.h" | 8 #include "GrStyle.h" |
9 | 9 |
10 int GrStyle::KeySize(const GrStyle &style, Apply apply, uint32_t flags) { | 10 int GrStyle::KeySize(const GrStyle &style, Apply apply, uint32_t flags) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return false; | 130 return false; |
131 } | 131 } |
132 *remainingStroke = strokeRec; | 132 *remainingStroke = strokeRec; |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 bool GrStyle::applyToPath(SkPath* dst, SkStrokeRec::InitStyle* style, const SkPa
th& src) const { | 136 bool GrStyle::applyToPath(SkPath* dst, SkStrokeRec::InitStyle* style, const SkPa
th& src) const { |
137 SkASSERT(style); | 137 SkASSERT(style); |
138 SkASSERT(dst); | 138 SkASSERT(dst); |
139 SkStrokeRec strokeRec = fStrokeRec; | 139 SkStrokeRec strokeRec = fStrokeRec; |
140 if (!apply_path_effect(dst, &strokeRec, fPathEffect, src)) { | 140 const SkPath* pathForStrokeRec = &src; |
| 141 if (apply_path_effect(dst, &strokeRec, fPathEffect, src)) { |
| 142 pathForStrokeRec = dst; |
| 143 } else if (fPathEffect) { |
141 return false; | 144 return false; |
142 } | 145 } |
143 if (strokeRec.needToApply()) { | 146 if (strokeRec.needToApply()) { |
144 if (!strokeRec.applyToPath(dst, *dst)) { | 147 if (!strokeRec.applyToPath(dst, *pathForStrokeRec)) { |
145 return false; | 148 return false; |
146 } | 149 } |
147 *style = SkStrokeRec::kFill_InitStyle; | 150 *style = SkStrokeRec::kFill_InitStyle; |
| 151 } else if (!fPathEffect) { |
| 152 // Nothing to do for path effect or stroke, fail. |
| 153 return false; |
148 } else { | 154 } else { |
149 SkASSERT(SkStrokeRec::kFill_Style == strokeRec.getStyle() || | 155 SkASSERT(SkStrokeRec::kFill_Style == strokeRec.getStyle() || |
150 SkStrokeRec::kHairline_Style == strokeRec.getStyle()); | 156 SkStrokeRec::kHairline_Style == strokeRec.getStyle()); |
151 *style = strokeRec.getStyle() == SkStrokeRec::kFill_Style | 157 *style = strokeRec.getStyle() == SkStrokeRec::kFill_Style |
152 ? SkStrokeRec::kFill_InitStyle | 158 ? SkStrokeRec::kFill_InitStyle |
153 : SkStrokeRec::kHairline_InitStyle; | 159 : SkStrokeRec::kHairline_InitStyle; |
154 } | 160 } |
155 return true; | 161 return true; |
156 } | 162 } |
OLD | NEW |