bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "GrStyle.h" |
| 9 | |
bsalomon | 308feba | 2016-05-03 10:11:55 -0700 | [diff] [blame] | 10 | void GrStyle::initPathEffect(SkPathEffect* pe) { |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 11 | if (!pe) { |
| 12 | fDashInfo.fType = SkPathEffect::kNone_DashType; |
| 13 | return; |
| 14 | } |
| 15 | SkPathEffect::DashInfo info; |
| 16 | if (SkPathEffect::kDash_DashType == pe->asADash(&info)) { |
| 17 | if (fStrokeRec.getStyle() == SkStrokeRec::kFill_Style) { |
| 18 | fPathEffect.reset(nullptr); |
| 19 | } else { |
bsalomon | 308feba | 2016-05-03 10:11:55 -0700 | [diff] [blame] | 20 | fPathEffect.reset(SkSafeRef(pe)); |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 21 | fDashInfo.fType = SkPathEffect::kDash_DashType; |
| 22 | fDashInfo.fIntervals.reset(info.fCount); |
| 23 | fDashInfo.fPhase = info.fPhase; |
| 24 | info.fIntervals = fDashInfo.fIntervals.get(); |
| 25 | pe->asADash(&info); |
| 26 | return; |
| 27 | } |
| 28 | } else { |
bsalomon | 308feba | 2016-05-03 10:11:55 -0700 | [diff] [blame] | 29 | fPathEffect.reset(SkSafeRef(pe)); |
bsalomon | 47cc769 | 2016-04-26 12:56:00 -0700 | [diff] [blame] | 30 | } |
| 31 | fDashInfo.fType = SkPathEffect::kNone_DashType; |
| 32 | fDashInfo.fIntervals.reset(0); |
| 33 | } |