• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
inPosition()32     const Attribute& inPosition() const { return fInPosition; }
inColor()33     const Attribute& inColor() const { return fInColor; }
inShadowParams()34     const Attribute& inShadowParams() const { return fInShadowParams; }
color()35     GrColor color() const { return fColor; }
36 
addToKey(const GrShaderCaps &,GrProcessorKeyBuilder *)37     void addToKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
38 
39     std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const override;
40 
41 private:
42     class Impl;
43 
44     GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView);
45 
onTextureSampler(int i)46     const TextureSampler& onTextureSampler(int i) const override { return fLUTTextureSampler; }
47 
48     GrColor          fColor;
49     TextureSampler   fLUTTextureSampler;
50 
51     Attribute fInPosition;
52     Attribute fInColor;
53     Attribute fInShadowParams;
54 
55     GR_DECLARE_GEOMETRY_PROCESSOR_TEST
56 
57     using INHERITED = GrGeometryProcessor;
58 };
59 
60 #endif
61