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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/effects/GrOvalEffect.h" |
joshualitt | eb2a676 | 2014-12-04 11:35:33 -0800 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkRect.h" |
| 11 | #include "src/gpu/effects/generated/GrCircleEffect.h" |
| 12 | #include "src/gpu/effects/generated/GrEllipseEffect.h" |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 13 | |
Brian Salomon | 1447177 | 2017-12-05 10:35:15 -0500 | [diff] [blame] | 14 | std::unique_ptr<GrFragmentProcessor> GrOvalEffect::Make(GrClipEdgeType edgeType, const SkRect& oval, |
| 15 | const GrShaderCaps& caps) { |
Ethan Nicholas | 1706f84 | 2017-11-10 11:58:19 -0500 | [diff] [blame] | 16 | if (GrClipEdgeType::kHairlineAA == edgeType) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 17 | return nullptr; |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 18 | } |
| 19 | SkScalar w = oval.width(); |
| 20 | SkScalar h = oval.height(); |
| 21 | if (SkScalarNearlyEqual(w, h)) { |
| 22 | w /= 2; |
Ethan Nicholas | aae47c8 | 2017-11-10 15:34:03 -0500 | [diff] [blame] | 23 | return GrCircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), |
Ethan Nicholas | 1706f84 | 2017-11-10 11:58:19 -0500 | [diff] [blame] | 24 | w); |
commit-bot@chromium.org | d0a5029 | 2014-04-02 15:00:39 +0000 | [diff] [blame] | 25 | } else { |
| 26 | w /= 2; |
| 27 | h /= 2; |
Ethan Nicholas | aae47c8 | 2017-11-10 15:34:03 -0500 | [diff] [blame] | 28 | return GrEllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), |
Brian Salomon | 1447177 | 2017-12-05 10:35:15 -0500 | [diff] [blame] | 29 | SkPoint::Make(w, h), caps); |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 30 | } |
| 31 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 32 | return nullptr; |
commit-bot@chromium.org | 3eedb80 | 2014-03-28 15:58:31 +0000 | [diff] [blame] | 33 | } |