Flutter Engine
The Flutter Engine
GrOvalEffect.cpp
Go to the documentation of this file.
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
14
15#include <utility>
16
17enum class GrClipEdgeType;
18
19GrFPResult GrOvalEffect::Make(std::unique_ptr<GrFragmentProcessor> inputFP, GrClipEdgeType edgeType,
20 const SkRect& oval, const GrShaderCaps& caps) {
21 SkScalar w = oval.width();
23 if (SkScalarNearlyEqual(w, h)) {
24 w /= 2;
25 return GrFragmentProcessor::Circle(std::move(inputFP), edgeType,
27 } else {
28 w /= 2;
29 h /= 2;
30 return GrFragmentProcessor::Ellipse(std::move(inputFP), edgeType,
32 SkPoint::Make(w, h), caps);
33 }
35}
std::tuple< bool, std::unique_ptr< GrFragmentProcessor > > GrFPResult
GrClipEdgeType
Definition: GrTypesPriv.h:361
#define SkUNREACHABLE
Definition: SkAssert.h:135
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: SkScalar.h:107
static GrFPResult Circle(std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, float radius)
static GrFPResult Ellipse(std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, SkPoint radii, const GrShaderCaps &)
float SkScalar
Definition: extension.cpp:12
GrFPResult Make(std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, const SkRect &, const GrShaderCaps &)
SkRect oval
Definition: SkRecords.h:249
SkScalar w
SkScalar h
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15