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 "include/core/SkRect.h"
9 #include "src/gpu/GrFragmentProcessor.h"
10 #include "src/gpu/effects/GrOvalEffect.h"
11 
Make(std::unique_ptr<GrFragmentProcessor> inputFP, GrClipEdgeType edgeType, const SkRect& oval, const GrShaderCaps& caps)12 GrFPResult GrOvalEffect::Make(std::unique_ptr<GrFragmentProcessor> inputFP, GrClipEdgeType edgeType,
13                               const SkRect& oval, const GrShaderCaps& caps) {
14     SkScalar w = oval.width();
15     SkScalar h = oval.height();
16     if (SkScalarNearlyEqual(w, h)) {
17         w /= 2;
18 #ifdef SKIA_OHOS
19         return GrFragmentProcessor::CircleSDF(std::move(inputFP), edgeType,
20             SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
21 #else
22         return GrFragmentProcessor::Circle(std::move(inputFP), edgeType,
23                                            SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
24 #endif
25     } else {
26         w /= 2;
27         h /= 2;
28         return GrFragmentProcessor::Ellipse(std::move(inputFP), edgeType,
29                                             SkPoint::Make(oval.fLeft + w, oval.fTop + h),
30                                             SkPoint::Make(w, h), caps);
31     }
32     SkUNREACHABLE;
33 }
34