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