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