• 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         kBigKeyProcessor_ClassID,
36         kBlendFragmentProcessor_ClassID,
37         kBlockInputFragmentProcessor_ClassID,
38         kButtCapStrokedCircleGeometryProcessor_ClassID,
39         kCircleGeometryProcessor_ClassID,
40         kCircularRRectEffect_ClassID,
41         kClockwiseTestProcessor_ClassID,
42         kColorTableEffect_ClassID,
43         kCoverageSetOpXP_ClassID,
44         kCustomXP_ClassID,
45         kDashingCircleEffect_ClassID,
46         kDashingLineEffect_ClassID,
47         kDefaultGeoProc_ClassID,
48         kDeviceSpace_ClassID,
49         kDIEllipseGeometryProcessor_ClassID,
50         kDisableColorXP_ClassID,
51         kDrawAtlasPathShader_ClassID,
52         kEllipseGeometryProcessor_ClassID,
53         kEllipticalRRectEffect_ClassID,
54         kFwidthSquircleTestProcessor_ClassID,
55         kGP_ClassID,
56         kGrBicubicEffect_ClassID,
57         kGrBitmapTextGeoProc_ClassID,
58         kGrColorSpaceXformEffect_ClassID,
59         kGrConicEffect_ClassID,
60         kGrConvexPolyEffect_ClassID,
61         kGrDiffuseLightingEffect_ClassID,
62         kGrDisplacementMapEffect_ClassID,
63         kGrDistanceFieldA8TextGeoProc_ClassID,
64         kGrDistanceFieldLCDTextGeoProc_ClassID,
65         kGrDistanceFieldPathGeoProc_ClassID,
66         kGrDSLFPTest_DoStatement_ClassID,
67         kGrDSLFPTest_ForStatement_ClassID,
68         kGrDSLFPTest_IfStatement_ClassID,
69         kGrDSLFPTest_SwitchStatement_ClassID,
70         kGrDSLFPTest_Swizzle_ClassID,
71         kGrDSLFPTest_Ternary_ClassID,
72         kGrDSLFPTest_WhileStatement_ClassID,
73         kGrFillRRectOp_Processor_ClassID,
74         kGrGaussianConvolutionFragmentProcessor_ClassID,
75         kGrMatrixConvolutionEffect_ClassID,
76         kGrMatrixEffect_ClassID,
77         kGrMeshTestProcessor_ClassID,
78         kGrMorphologyEffect_ClassID,
79         kGrPerlinNoise2Effect_ClassID,
80         kGrPipelineDynamicStateTestProcessor_ClassID,
81         kGrQuadEffect_ClassID,
82         kGrRRectShadowGeoProc_ClassID,
83         kGrSkSLFP_ClassID,
84         kGrSpecularLightingEffect_ClassID,
85         kGrTextureEffect_ClassID,
86         kGrUnrolledBinaryGradientColorizer_ClassID,
87         kGrYUVtoRGBEffect_ClassID,
88         kHighPrecisionFragmentProcessor_ClassID,
89         kLatticeGP_ClassID,
90         kPDLCDXferProcessor_ClassID,
91         kPorterDuffXferProcessor_ClassID,
92         kPremulFragmentProcessor_ClassID,
93         kQuadEdgeEffect_ClassID,
94         kQuadPerEdgeAAGeometryProcessor_ClassID,
95         kSeriesFragmentProcessor_ClassID,
96         kShaderPDXferProcessor_ClassID,
97         kSurfaceColorProcessor_ClassID,
98         kSwizzleFragmentProcessor_ClassID,
99         kTessellate_BoundingBoxShader_ClassID,
100         kTessellate_GrModulateAtlasCoverageEffect_ClassID,
101         kTessellate_GrStrokeTessellationShader_ClassID,
102         kTessellate_HardwareCurveShader_ClassID,
103         kTessellate_HardwareWedgeShader_ClassID,
104         kTessellate_HullShader_ClassID,
105         kTessellate_MiddleOutShader_ClassID,
106         kTessellate_SimpleTriangleShader_ClassID,
107         kTessellationTestTriShader_ClassID,
108         kTestFP_ClassID,
109         kTestRectOp_ClassID,
110         kVertexColorSpaceBenchGP_ClassID,
111         kVerticesGP_ClassID,
112     };
113 
114     virtual ~GrProcessor() = default;
115 
116     /** Human-meaningful string to identify this processor; may be embedded in generated shader
117         code and must be a legal SkSL identifier prefix. */
118     virtual const char* name() const = 0;
119 
120     /** Human-readable dump of all information */
121 #if GR_TEST_UTILS
onDumpInfo()122     virtual SkString onDumpInfo() const { return SkString(); }
123 
dumpInfo()124     SkString dumpInfo() const {
125         SkString info(name());
126         info.append(this->onDumpInfo());
127         return info;
128     }
129 #endif
130 
131     void* operator new(size_t size);
132     void* operator new(size_t object_size, size_t footer_size);
133     void operator delete(void* target);
134 
new(size_t size,void * placement)135     void* operator new(size_t size, void* placement) {
136         return ::operator new(size, placement);
137     }
delete(void * target,void * placement)138     void operator delete(void* target, void* placement) {
139         ::operator delete(target, placement);
140     }
141 
142     /** Helper for down-casting to a GrProcessor subclass */
cast()143     template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
144 
classID()145     ClassID classID() const { return fClassID; }
146 
147 protected:
GrProcessor(ClassID classID)148     GrProcessor(ClassID classID) : fClassID(classID) {}
149     GrProcessor(const GrProcessor&) = delete;
150     GrProcessor& operator=(const GrProcessor&) = delete;
151 
152     const ClassID fClassID;
153 };
154 
155 #endif
156