commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 "GrOvalEffect.h" |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 9 | |
Ethan Nicholas | 83d1185 | 2017-07-13 16:00:16 -0400 | [diff] [blame] | 10 | #include "GrCircleEffect.h" |
Ethan Nicholas | 420f156 | 2017-07-14 13:11:38 -0400 | [diff] [blame^] | 11 | #include "GrEllipseEffect.h" |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 12 | #include "SkRect.h" |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 13 | |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 14 | sk_sp<GrFragmentProcessor> GrOvalEffect::Make(GrPrimitiveEdgeType edgeType, const SkRect& oval) { |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 15 | if (kHairlineAA_GrProcessorEdgeType == edgeType) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 16 | return nullptr; |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 17 | } |
| 18 | SkScalar w = oval.width(); |
| 19 | SkScalar h = oval.height(); |
| 20 | if (SkScalarNearlyEqual(w, h)) { |
| 21 | w /= 2; |
Ethan Nicholas | 83d1185 | 2017-07-13 16:00:16 -0400 | [diff] [blame] | 22 | return GrCircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), w); |
commit-bot@chromium.org | d0a5029 | 2014-04-02 15:00:39 +0000 | [diff] [blame] | 23 | } else { |
| 24 | w /= 2; |
| 25 | h /= 2; |
Ethan Nicholas | 420f156 | 2017-07-14 13:11:38 -0400 | [diff] [blame^] | 26 | return GrEllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), |
| 27 | SkPoint::Make(w, h)); |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 28 | } |
| 29 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 30 | return nullptr; |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 31 | } |