blob: a475ec02df7822dde5f8bddc55e949ae0d9c054a [file] [log] [blame]
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +00001/*
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"
joshualitteb2a6762014-12-04 11:35:33 -08009
Ethan Nicholas83d11852017-07-13 16:00:16 -040010#include "GrCircleEffect.h"
Ethan Nicholas420f1562017-07-14 13:11:38 -040011#include "GrEllipseEffect.h"
joshualitteb2a6762014-12-04 11:35:33 -080012#include "SkRect.h"
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000013
Brian Salomon14471772017-12-05 10:35:15 -050014std::unique_ptr<GrFragmentProcessor> GrOvalEffect::Make(GrClipEdgeType edgeType, const SkRect& oval,
15 const GrShaderCaps& caps) {
Ethan Nicholas1706f842017-11-10 11:58:19 -050016 if (GrClipEdgeType::kHairlineAA == edgeType) {
halcanary96fcdcc2015-08-27 07:41:13 -070017 return nullptr;
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000018 }
19 SkScalar w = oval.width();
20 SkScalar h = oval.height();
21 if (SkScalarNearlyEqual(w, h)) {
22 w /= 2;
Ethan Nicholasaae47c82017-11-10 15:34:03 -050023 return GrCircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w),
Ethan Nicholas1706f842017-11-10 11:58:19 -050024 w);
commit-bot@chromium.orgd0a50292014-04-02 15:00:39 +000025 } else {
26 w /= 2;
27 h /= 2;
Ethan Nicholasaae47c82017-11-10 15:34:03 -050028 return GrEllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h),
Brian Salomon14471772017-12-05 10:35:15 -050029 SkPoint::Make(w, h), caps);
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000030 }
31
halcanary96fcdcc2015-08-27 07:41:13 -070032 return nullptr;
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000033}