blob: b7c001cd54b52542ae0cb04c3111f861f6282d29 [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "src/gpu/effects/GrOvalEffect.h"
joshualitteb2a6762014-12-04 11:35:33 -08009
Mike Kleinc0bd9f92019-04-23 12:05:21 -050010#include "include/core/SkRect.h"
11#include "src/gpu/effects/generated/GrCircleEffect.h"
12#include "src/gpu/effects/generated/GrEllipseEffect.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}