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
15class GrGLRRectShadowGeoProc;
16class GrSurfaceProxyView;
17
18/**
19 * The output color of this effect is a coverage mask for a rrect shadow,
20 * assuming circular corner geometry.
21 */
22class GrRRectShadowGeoProc : public GrGeometryProcessor {
23public:
24 static GrGeometryProcessor* Make(SkArenaAlloc* arena, const GrSurfaceProxyView& lutView) {
25 return arena->make<GrRRectShadowGeoProc>(lutView);
26 }
27
28 const char* name() const override { return "RRectShadow"; }
29
30 const Attribute& inPosition() const { return fInPosition; }
31 const Attribute& inColor() const { return fInColor; }
32 const Attribute& inShadowParams() const { return fInShadowParams; }
33 GrColor color() const { return fColor; }
34
35 void getGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override {}
36
37 GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
38
39private:
40 friend class ::SkArenaAlloc; // for access to ctor
41
42 GrRRectShadowGeoProc(const GrSurfaceProxyView& lutView);
43
44 const TextureSampler& onTextureSampler(int i) const override { return fLUTTextureSampler; }
45
46 GrColor fColor;
47 TextureSampler fLUTTextureSampler;
48
49 Attribute fInPosition;
50 Attribute fInColor;
51 Attribute fInShadowParams;
52
53 GR_DECLARE_GEOMETRY_PROCESSOR_TEST
54
55 typedef GrGeometryProcessor INHERITED;
56};
57
58#endif
59