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