1 | /* |
2 | * Copyright 2017 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 | /************************************************************************************************** |
9 | *** This file was autogenerated from GrEllipseEffect.fp; do not modify. |
10 | **************************************************************************************************/ |
11 | #ifndef GrEllipseEffect_DEFINED |
12 | #define GrEllipseEffect_DEFINED |
13 | #include "include/core/SkTypes.h" |
14 | #include "include/core/SkM44.h" |
15 | |
16 | #include "src/gpu/GrShaderCaps.h" |
17 | |
18 | #include "src/gpu/GrCoordTransform.h" |
19 | #include "src/gpu/GrFragmentProcessor.h" |
20 | class GrEllipseEffect : public GrFragmentProcessor { |
21 | public: |
22 | static std::unique_ptr<GrFragmentProcessor> Make(GrClipEdgeType edgeType, |
23 | SkPoint center, |
24 | SkPoint radii, |
25 | const GrShaderCaps& caps) { |
26 | // Small radii produce bad results on devices without full float. |
27 | if (!caps.floatIs32Bits() && (radii.fX < 0.5f || radii.fY < 0.5f)) { |
28 | return nullptr; |
29 | } |
30 | // Very narrow ellipses produce bad results on devices without full float |
31 | if (!caps.floatIs32Bits() && (radii.fX > 255 * radii.fY || radii.fY > 255 * radii.fX)) { |
32 | return nullptr; |
33 | } |
34 | // Very large ellipses produce bad results on devices without full float |
35 | if (!caps.floatIs32Bits() && (radii.fX > 16384 || radii.fY > 16384)) { |
36 | return nullptr; |
37 | } |
38 | return std::unique_ptr<GrFragmentProcessor>(new GrEllipseEffect(edgeType, center, radii)); |
39 | } |
40 | GrEllipseEffect(const GrEllipseEffect& src); |
41 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
42 | const char* name() const override { return "EllipseEffect" ; } |
43 | GrClipEdgeType edgeType; |
44 | SkPoint center; |
45 | SkPoint radii; |
46 | |
47 | private: |
48 | GrEllipseEffect(GrClipEdgeType edgeType, SkPoint center, SkPoint radii) |
49 | : INHERITED(kGrEllipseEffect_ClassID, |
50 | (OptimizationFlags)kCompatibleWithCoverageAsAlpha_OptimizationFlag) |
51 | , edgeType(edgeType) |
52 | , center(center) |
53 | , radii(radii) {} |
54 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
55 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
56 | bool onIsEqual(const GrFragmentProcessor&) const override; |
57 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
58 | typedef GrFragmentProcessor INHERITED; |
59 | }; |
60 | #endif |
61 | |