1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#include "include/core/SkRect.h"
9cb93a386Sopenharmony_ci#include "src/gpu/GrFragmentProcessor.h"
10cb93a386Sopenharmony_ci#include "src/gpu/effects/GrOvalEffect.h"
11cb93a386Sopenharmony_ci
12cb93a386Sopenharmony_ciGrFPResult GrOvalEffect::Make(std::unique_ptr<GrFragmentProcessor> inputFP, GrClipEdgeType edgeType,
13cb93a386Sopenharmony_ci                              const SkRect& oval, const GrShaderCaps& caps) {
14cb93a386Sopenharmony_ci    SkScalar w = oval.width();
15cb93a386Sopenharmony_ci    SkScalar h = oval.height();
16cb93a386Sopenharmony_ci    if (SkScalarNearlyEqual(w, h)) {
17cb93a386Sopenharmony_ci        w /= 2;
18cb93a386Sopenharmony_ci#ifdef SKIA_OHOS
19cb93a386Sopenharmony_ci        return GrFragmentProcessor::CircleSDF(std::move(inputFP), edgeType,
20cb93a386Sopenharmony_ci            SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
21cb93a386Sopenharmony_ci#else
22cb93a386Sopenharmony_ci        return GrFragmentProcessor::Circle(std::move(inputFP), edgeType,
23cb93a386Sopenharmony_ci                                           SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
24cb93a386Sopenharmony_ci#endif
25cb93a386Sopenharmony_ci    } else {
26cb93a386Sopenharmony_ci        w /= 2;
27cb93a386Sopenharmony_ci        h /= 2;
28cb93a386Sopenharmony_ci        return GrFragmentProcessor::Ellipse(std::move(inputFP), edgeType,
29cb93a386Sopenharmony_ci                                            SkPoint::Make(oval.fLeft + w, oval.fTop + h),
30cb93a386Sopenharmony_ci                                            SkPoint::Make(w, h), caps);
31cb93a386Sopenharmony_ci    }
32cb93a386Sopenharmony_ci    SkUNREACHABLE;
33cb93a386Sopenharmony_ci}
34