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