1 /* 2 * Copyright 2016 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 #ifndef GrShadowGeoProc_DEFINED 9 #define GrShadowGeoProc_DEFINED 10 11 #include "src/core/SkArenaAlloc.h" 12 #include "src/gpu/GrGeometryProcessor.h" 13 #include "src/gpu/GrProcessor.h" 14 15 class GrGLRRectShadowGeoProc; 16 class GrSurfaceProxyView; 17 18 /** 19 * The output color of this effect is a coverage mask for a rrect shadow, 20 * assuming circular corner geometry. 21 */ 22 class GrRRectShadowGeoProc : public GrGeometryProcessor { 23 public: Make(SkArenaAlloc * arena,const GrSurfaceProxyView & lutView)24 static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrSurfaceProxyView& lutView) { 25 return arena->make([&](void* ptr) { 26 return new (ptr) GrRRectShadowGeoProc(lutView); 27 }); 28 } 29 name()30 const char* name() const override { return "RRectShadow"; } 31 getShaderDfxInfo()32 SkString getShaderDfxInfo() const override { return SkString("ShaderDfx_GrRRectShadowGeoProc"); } 33 inPosition()34 const Attribute& inPosition() const { return fInPosition; } inColor()35 const Attribute& inColor() const { return fInColor; } inShadowParams()36 const Attribute& inShadowParams() const { return fInShadowParams; } color()37 GrColor color() const { return fColor; } 38 addToKey(const GrShaderCaps &,GrProcessorKeyBuilder *)39 void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} 40 41 std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override; 42 43 private: 44 class Impl; 45 46 GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView); 47 onTextureSampler(int i)48 const TextureSampler& onTextureSampler(int i) const override { return fLUTTextureSampler; } 49 50 GrColor fColor; 51 TextureSampler fLUTTextureSampler; 52 53 Attribute fInPosition; 54 Attribute fInColor; 55 Attribute fInShadowParams; 56 57 GR_DECLARE_GEOMETRY_PROCESSOR_TEST 58 59 using INHERITED = GrGeometryProcessor; 60 }; 61 62 #endif 63