blob: 3180533146eb26a5cbdd1b3eb5dc1e3eae583a65 [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
bungeman06ca8ec2016-06-09 08:01:03 -070014sk_sp<GrFragmentProcessor> GrOvalEffect::Make(GrPrimitiveEdgeType edgeType, const SkRect& oval) {
joshualittb0a8a372014-09-23 09:50:21 -070015 if (kHairlineAA_GrProcessorEdgeType == edgeType) {
halcanary96fcdcc2015-08-27 07:41:13 -070016 return nullptr;
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000017 }
18 SkScalar w = oval.width();
19 SkScalar h = oval.height();
20 if (SkScalarNearlyEqual(w, h)) {
21 w /= 2;
Ethan Nicholas83d11852017-07-13 16:00:16 -040022 return GrCircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
commit-bot@chromium.orgd0a50292014-04-02 15:00:39 +000023 } else {
24 w /= 2;
25 h /= 2;
Ethan Nicholas420f1562017-07-14 13:11:38 -040026 return GrEllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h),
27 SkPoint::Make(w, h));
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000028 }
29
halcanary96fcdcc2015-08-27 07:41:13 -070030 return nullptr;
commit-bot@chromium.org3eedb802014-03-28 15:58:31 +000031}