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