diff options
Diffstat (limited to 'gfx/skia/skia/src/gpu/effects/GrOvalEffect.cpp')
-rw-r--r-- | gfx/skia/skia/src/gpu/effects/GrOvalEffect.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/gpu/effects/GrOvalEffect.cpp b/gfx/skia/skia/src/gpu/effects/GrOvalEffect.cpp new file mode 100644 index 0000000000..b7c001cd54 --- /dev/null +++ b/gfx/skia/skia/src/gpu/effects/GrOvalEffect.cpp @@ -0,0 +1,33 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "src/gpu/effects/GrOvalEffect.h" + +#include "include/core/SkRect.h" +#include "src/gpu/effects/generated/GrCircleEffect.h" +#include "src/gpu/effects/generated/GrEllipseEffect.h" + +std::unique_ptr<GrFragmentProcessor> GrOvalEffect::Make(GrClipEdgeType edgeType, const SkRect& oval, + const GrShaderCaps& caps) { + if (GrClipEdgeType::kHairlineAA == edgeType) { + return nullptr; + } + SkScalar w = oval.width(); + SkScalar h = oval.height(); + if (SkScalarNearlyEqual(w, h)) { + w /= 2; + return GrCircleEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + w), + w); + } else { + w /= 2; + h /= 2; + return GrEllipseEffect::Make(edgeType, SkPoint::Make(oval.fLeft + w, oval.fTop + h), + SkPoint::Make(w, h), caps); + } + + return nullptr; +} |