| 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 | |
| 14 | #include "include/core/SkM44.h" |
| 15 | #include "include/core/SkTypes.h" |
| 16 | |
| 17 | #include "src/gpu/GrShaderCaps.h" |
| 18 | |
| 19 | #include "src/gpu/GrFragmentProcessor.h" |
| 20 | |
| 21 | class GrEllipseEffect : public GrFragmentProcessor { |
| 22 | public: |
| 23 | static GrFPResult Make(std::unique_ptr<GrFragmentProcessor> inputFP, |
| 24 | GrClipEdgeType edgeType, |
| 25 | SkPoint center, |
| 26 | SkPoint radii, |
| 27 | const GrShaderCaps& caps) { |
| 28 | // Small radii produce bad results on devices without full float. |
| 29 | if (!caps.floatIs32Bits() && (radii.fX < 0.5f || radii.fY < 0.5f)) { |
| 30 | return GrFPFailure(std::move(inputFP)); |
| 31 | } |
| 32 | // Very narrow ellipses produce bad results on devices without full float |
| 33 | if (!caps.floatIs32Bits() && (radii.fX > 255 * radii.fY || radii.fY > 255 * radii.fX)) { |
| 34 | return GrFPFailure(std::move(inputFP)); |
| 35 | } |
| 36 | // Very large ellipses produce bad results on devices without full float |
| 37 | if (!caps.floatIs32Bits() && (radii.fX > 16384 || radii.fY > 16384)) { |
| 38 | return GrFPFailure(std::move(inputFP)); |
| 39 | } |
| 40 | return GrFPSuccess(std::unique_ptr<GrFragmentProcessor>( |
| 41 | new GrEllipseEffect(std::move(inputFP), edgeType, center, radii))); |
| 42 | } |
| 43 | GrEllipseEffect(const GrEllipseEffect& src); |
| 44 | std::unique_ptr<GrFragmentProcessor> clone() const override; |
| 45 | const char* name() const override { return "EllipseEffect" ; } |
| 46 | GrClipEdgeType edgeType; |
| 47 | SkPoint center; |
| 48 | SkPoint radii; |
| 49 | |
| 50 | private: |
| 51 | GrEllipseEffect(std::unique_ptr<GrFragmentProcessor> inputFP, |
| 52 | GrClipEdgeType edgeType, |
| 53 | SkPoint center, |
| 54 | SkPoint radii) |
| 55 | : INHERITED(kGrEllipseEffect_ClassID, |
| 56 | (OptimizationFlags)(inputFP ? ProcessorOptimizationFlags(inputFP.get()) |
| 57 | : kAll_OptimizationFlags) & |
| 58 | kCompatibleWithCoverageAsAlpha_OptimizationFlag) |
| 59 | , edgeType(edgeType) |
| 60 | , center(center) |
| 61 | , radii(radii) { |
| 62 | this->registerChild(std::move(inputFP), SkSL::SampleUsage::PassThrough()); |
| 63 | } |
| 64 | GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
| 65 | void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; |
| 66 | bool onIsEqual(const GrFragmentProcessor&) const override; |
| 67 | #if GR_TEST_UTILS |
| 68 | SkString onDumpInfo() const override; |
| 69 | #endif |
| 70 | GR_DECLARE_FRAGMENT_PROCESSOR_TEST |
| 71 | typedef GrFragmentProcessor INHERITED; |
| 72 | }; |
| 73 | #endif |
| 74 | |