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 "GrShape.h" | 8 #include "GrShape.h" |
9 | 9 |
10 GrShape& GrShape::operator=(const GrShape& that) { | 10 GrShape& GrShape::operator=(const GrShape& that) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 srcForPathEffect = parent.fPath.get(); | 197 srcForPathEffect = parent.fPath.get(); |
198 } else { | 198 } else { |
199 srcForPathEffect = tmpPath.init(); | 199 srcForPathEffect = tmpPath.init(); |
200 parent.asPath(tmpPath.get()); | 200 parent.asPath(tmpPath.get()); |
201 } | 201 } |
202 // Should we consider bounds? Would have to include in key, but it'd be
nice to know | 202 // Should we consider bounds? Would have to include in key, but it'd be
nice to know |
203 // if the bounds actually modified anything before including in key. | 203 // if the bounds actually modified anything before including in key. |
204 SkStrokeRec strokeRec = parent.fStyle.strokeRec(); | 204 SkStrokeRec strokeRec = parent.fStyle.strokeRec(); |
205 strokeRec.setResScale(scale); | 205 strokeRec.setResScale(scale); |
206 if (!pe->filterPath(fPath.get(), *srcForPathEffect, &strokeRec, nullptr)
) { | 206 if (!pe->filterPath(fPath.get(), *srcForPathEffect, &strokeRec, nullptr)
) { |
207 // Make an empty unstyled shape if filtering fails. | 207 // If the path effect fails then we continue as though there was no
path effect. |
208 fType = Type::kEmpty; | 208 // If the original was a rrect that we couldn't canonicalize because
of the path |
209 fStyle = GrStyle(); | 209 // effect, then do so now. |
210 fPath.reset(); | 210 if (parent.fType == Type::kRRect && (parent.fRRectDir != kDefaultRRe
ctDir || |
211 return; | 211 parent.fRRectStart != kDefaultR
RectStart)) { |
| 212 SkASSERT(srcForPathEffect == tmpPath.get()); |
| 213 tmpPath.get()->reset(); |
| 214 tmpPath.get()->addRRect(parent.fRRect, kDefaultRRectDir, kDefaul
tRRectDir); |
| 215 } |
| 216 *fPath.get() = *srcForPathEffect; |
212 } | 217 } |
213 // A path effect has access to change the res scale but we aren't expect
ing it to and it | 218 // A path effect has access to change the res scale but we aren't expect
ing it to and it |
214 // would mess up our key computation. | 219 // would mess up our key computation. |
215 SkASSERT(scale == strokeRec.getResScale()); | 220 SkASSERT(scale == strokeRec.getResScale()); |
216 if (GrStyle::Apply::kPathEffectAndStrokeRec == apply) { | 221 if (GrStyle::Apply::kPathEffectAndStrokeRec == apply) { |
217 if (strokeRec.needToApply()) { | 222 if (strokeRec.needToApply()) { |
218 // The intermediate shape may not be a general path. If we we're
just applying | 223 // The intermediate shape may not be a general path. If we we're
just applying |
219 // the path effect then attemptToReduceFromPath would catch it.
This means that | 224 // the path effect then attemptToReduceFromPath would catch it.
This means that |
220 // when we subsequently applied the remaining strokeRec we would
have a non-path | 225 // when we subsequently applied the remaining strokeRec we would
have a non-path |
221 // parent shape that would be used to determine the the stroked
path's key. | 226 // parent shape that would be used to determine the the stroked
path's key. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 rrect->setRect(rect); | 319 rrect->setRect(rect); |
315 // Since there is no path effect the dir and start index is imma
terial. | 320 // Since there is no path effect the dir and start index is imma
terial. |
316 *rrectDir = kDefaultRRectDir; | 321 *rrectDir = kDefaultRRectDir; |
317 *rrectStart = kDefaultRRectStart; | 322 *rrectStart = kDefaultRRectStart; |
318 return Type::kRRect; | 323 return Type::kRRect; |
319 } | 324 } |
320 } | 325 } |
321 } | 326 } |
322 return Type::kPath; | 327 return Type::kPath; |
323 } | 328 } |
OLD | NEW |