• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012 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 GrProcessor_DEFINED
9 #define GrProcessor_DEFINED
10 
11 #include "include/core/SkMath.h"
12 #include "include/core/SkString.h"
13 #include "src/gpu/GrColor.h"
14 #include "src/gpu/GrGpuBuffer.h"
15 #include "src/gpu/GrProcessorUnitTest.h"
16 #include "src/gpu/GrProgramDesc.h"
17 #include "src/gpu/GrSamplerState.h"
18 #include "src/gpu/GrShaderVar.h"
19 #include "src/gpu/GrSurfaceProxyPriv.h"
20 #include "src/gpu/GrTextureProxy.h"
21 
22 class GrResourceProvider;
23 
24 /** Provides custom shader code to the Ganesh shading pipeline. GrProcessor objects *must* be
25     immutable: after being constructed, their fields may not change.
26 
27     Dynamically allocated GrProcessors are managed by a per-thread memory pool. The ref count of an
28     processor must reach 0 before the thread terminates and the pool is destroyed.
29  */
30 class GrProcessor {
31 public:
32     enum ClassID {
33         kNull_ClassID,  // Reserved ID for missing (null) processors
34 
35         kAttributeTestProcessor_ClassID,
36         kBigKeyProcessor_ClassID,
37         kBlendFragmentProcessor_ClassID,
38         kBlockInputFragmentProcessor_ClassID,
39         kButtCapStrokedCircleGeometryProcessor_ClassID,
40         kCircleGeometryProcessor_ClassID,
41         kCircularRRectEffect_ClassID,
42         kClockwiseTestProcessor_ClassID,
43         kColorTableEffect_ClassID,
44         kCoverageSetOpXP_ClassID,
45         kCustomXP_ClassID,
46         kDashingCircleEffect_ClassID,
47         kDashingLineEffect_ClassID,
48         kDefaultGeoProc_ClassID,
49         kDeviceSpace_ClassID,
50         kDIEllipseGeometryProcessor_ClassID,
51         kDisableColorXP_ClassID,
52         kDrawAtlasPathShader_ClassID,
53         kEllipseGeometryProcessor_ClassID,
54         kEllipticalRRectEffect_ClassID,
55         kFwidthSquircleTestProcessor_ClassID,
56         kGP_ClassID,
57         kGrBicubicEffect_ClassID,
58         kGrBitmapTextGeoProc_ClassID,
59         kGrColorSpaceXformEffect_ClassID,
60         kGrConicEffect_ClassID,
61         kGrConvexPolyEffect_ClassID,
62         kGrDiffuseLightingEffect_ClassID,
63         kGrDisplacementMapEffect_ClassID,
64         kGrDistanceFieldA8TextGeoProc_ClassID,
65         kGrDistanceFieldLCDTextGeoProc_ClassID,
66         kGrDistanceFieldPathGeoProc_ClassID,
67         kGrDSLFPTest_DoStatement_ClassID,
68         kGrDSLFPTest_ForStatement_ClassID,
69         kGrDSLFPTest_IfStatement_ClassID,
70         kGrDSLFPTest_SwitchStatement_ClassID,
71         kGrDSLFPTest_Swizzle_ClassID,
72         kGrDSLFPTest_Ternary_ClassID,
73         kGrDSLFPTest_WhileStatement_ClassID,
74         kGrFillRRectOp_Processor_ClassID,
75         kGrGaussianConvolutionFragmentProcessor_ClassID,
76         kGrMatrixConvolutionEffect_ClassID,
77         kGrMatrixEffect_ClassID,
78         kGrMeshTestProcessor_ClassID,
79         kGrMorphologyEffect_ClassID,
80         kGrPerlinNoise2Effect_ClassID,
81         kGrPipelineDynamicStateTestProcessor_ClassID,
82         kGrQuadEffect_ClassID,
83         kGrRRectShadowGeoProc_ClassID,
84         kGrSkSLFP_ClassID,
85         kGrSpecularLightingEffect_ClassID,
86         kGrTextureEffect_ClassID,
87         kGrUnrolledBinaryGradientColorizer_ClassID,
88         kGrYUVtoRGBEffect_ClassID,
89         kHighPrecisionFragmentProcessor_ClassID,
90         kLatticeGP_ClassID,
91         kPDLCDXferProcessor_ClassID,
92         kPorterDuffXferProcessor_ClassID,
93         kPremulFragmentProcessor_ClassID,
94         kQuadEdgeEffect_ClassID,
95         kQuadPerEdgeAAGeometryProcessor_ClassID,
96         kSeriesFragmentProcessor_ClassID,
97         kShaderPDXferProcessor_ClassID,
98         kSurfaceColorProcessor_ClassID,
99         kSwizzleFragmentProcessor_ClassID,
100         kTessellate_BoundingBoxShader_ClassID,
101         kTessellate_GrModulateAtlasCoverageEffect_ClassID,
102         kTessellate_GrStrokeTessellationShader_ClassID,
103         kTessellate_HardwareCurveShader_ClassID,
104         kTessellate_HardwareWedgeShader_ClassID,
105         kTessellate_HullShader_ClassID,
106         kTessellate_MiddleOutShader_ClassID,
107         kTessellate_SimpleTriangleShader_ClassID,
108         kTessellationTestTriShader_ClassID,
109         kTestFP_ClassID,
110         kTestRectOp_ClassID,
111         kVertexColorSpaceBenchGP_ClassID,
112         kVerticesGP_ClassID,
113     };
114 
115     virtual ~GrProcessor() = default;
116 
117     /** Human-meaningful string to identify this processor; may be embedded in generated shader
118         code and must be a legal SkSL identifier prefix. */
119     virtual const char* name() const = 0;
120 
121     /** Human-readable dump of all information */
122 #if GR_TEST_UTILS
onDumpInfo()123     virtual SkString onDumpInfo() const { return SkString(); }
124 
dumpInfo()125     SkString dumpInfo() const {
126         SkString info(name());
127         info.append(this->onDumpInfo());
128         return info;
129     }
130 #endif
131 
132     void* operator new(size_t size);
133     void* operator new(size_t object_size, size_t footer_size);
134     void operator delete(void* target);
135 
new(size_t size,void * placement)136     void* operator new(size_t size, void* placement) {
137         return ::operator new(size, placement);
138     }
delete(void * target,void * placement)139     void operator delete(void* target, void* placement) {
140         ::operator delete(target, placement);
141     }
142 
143     /** Helper for down-casting to a GrProcessor subclass */
cast()144     template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
145 
classID()146     ClassID classID() const { return fClassID; }
147 
148 protected:
GrProcessor(ClassID classID)149     GrProcessor(ClassID classID) : fClassID(classID) {}
150     GrProcessor(const GrProcessor&) = delete;
151     GrProcessor& operator=(const GrProcessor&) = delete;
152 
153     const ClassID fClassID;
154 };
155 
156 #endif
157