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