• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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         return GrFragmentProcessor::Circle(std::move(inputFP), edgeType,
19                                            SkPoint::Make(oval.fLeft + w, oval.fTop + w), w);
20     } else {
21         w /= 2;
22         h /= 2;
23         return GrFragmentProcessor::Ellipse(std::move(inputFP), edgeType,
24                                             SkPoint::Make(oval.fLeft + w, oval.fTop + h),
25                                             SkPoint::Make(w, h), caps);
26     }
27     SkUNREACHABLE;
28 }
29