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 SKSL_CONTEXT
9 #define SKSL_CONTEXT
10 
11 #include "ir/SkSLType.h"
12 #include "ir/SkSLExpression.h"
13 
14 namespace SkSL {
15 
16 /**
17  * Contains compiler-wide objects, which currently means the core types.
18  */
19 class Context {
20 public:
Context()21     Context()
22     : fInvalid_Type(new Type("<INVALID>"))
23     , fVoid_Type(new Type("void"))
24     , fDouble_Type(new Type("double", Type::kFloat_NumberKind, 4))
25     , fDouble2_Type(new Type("double2", *fDouble_Type, 2))
26     , fDouble3_Type(new Type("double3", *fDouble_Type, 3))
27     , fDouble4_Type(new Type("double4", *fDouble_Type, 4))
28     , fFloat_Type(new Type("float", Type::kFloat_NumberKind, 3))
29     , fFloat2_Type(new Type("float2", *fFloat_Type, 2))
30     , fFloat3_Type(new Type("float3", *fFloat_Type, 3))
31     , fFloat4_Type(new Type("float4", *fFloat_Type, 4))
32     , fHalf_Type(new Type("half", Type::kFloat_NumberKind, 2))
33     , fHalf2_Type(new Type("half2", *fHalf_Type, 2))
34     , fHalf3_Type(new Type("half3", *fHalf_Type, 3))
35     , fHalf4_Type(new Type("half4", *fHalf_Type, 4))
36     , fUInt_Type(new Type("uint", Type::kUnsigned_NumberKind, 1))
37     , fUInt2_Type(new Type("uint2", *fUInt_Type, 2))
38     , fUInt3_Type(new Type("uint3", *fUInt_Type, 3))
39     , fUInt4_Type(new Type("uint4", *fUInt_Type, 4))
40     , fInt_Type(new Type("int", Type::kSigned_NumberKind, 1))
41     , fInt2_Type(new Type("int2", *fInt_Type, 2))
42     , fInt3_Type(new Type("int3", *fInt_Type, 3))
43     , fInt4_Type(new Type("int4", *fInt_Type, 4))
44     , fUShort_Type(new Type("ushort", Type::kUnsigned_NumberKind, 0))
45     , fUShort2_Type(new Type("ushort2", *fUShort_Type, 2))
46     , fUShort3_Type(new Type("ushort3", *fUShort_Type, 3))
47     , fUShort4_Type(new Type("ushort4", *fUShort_Type, 4))
48     , fShort_Type(new Type("short", Type::kSigned_NumberKind, 0))
49     , fShort2_Type(new Type("short2", *fShort_Type, 2))
50     , fShort3_Type(new Type("short3", *fShort_Type, 3))
51     , fShort4_Type(new Type("short4", *fShort_Type, 4))
52     , fUByte_Type(new Type("ubyte", Type::kUnsigned_NumberKind, 0))
53     , fUByte2_Type(new Type("ubyte2", *fUByte_Type, 2))
54     , fUByte3_Type(new Type("ubyte3", *fUByte_Type, 3))
55     , fUByte4_Type(new Type("ubyte4", *fUByte_Type, 4))
56     , fByte_Type(new Type("byte", Type::kSigned_NumberKind, 0))
57     , fByte2_Type(new Type("byte2", *fByte_Type, 2))
58     , fByte3_Type(new Type("byte3", *fByte_Type, 3))
59     , fByte4_Type(new Type("byte4", *fByte_Type, 4))
60     , fBool_Type(new Type("bool", Type::kNonnumeric_NumberKind, -1))
61     , fBool2_Type(new Type("bool2", *fBool_Type, 2))
62     , fBool3_Type(new Type("bool3", *fBool_Type, 3))
63     , fBool4_Type(new Type("bool4", *fBool_Type, 4))
64     , fFloat2x2_Type(new Type("float2x2", *fFloat_Type, 2, 2))
65     , fFloat2x3_Type(new Type("float2x3", *fFloat_Type, 2, 3))
66     , fFloat2x4_Type(new Type("float2x4", *fFloat_Type, 2, 4))
67     , fFloat3x2_Type(new Type("float3x2", *fFloat_Type, 3, 2))
68     , fFloat3x3_Type(new Type("float3x3", *fFloat_Type, 3, 3))
69     , fFloat3x4_Type(new Type("float3x4", *fFloat_Type, 3, 4))
70     , fFloat4x2_Type(new Type("float4x2", *fFloat_Type, 4, 2))
71     , fFloat4x3_Type(new Type("float4x3", *fFloat_Type, 4, 3))
72     , fFloat4x4_Type(new Type("float4x4", *fFloat_Type, 4, 4))
73     , fHalf2x2_Type(new Type("half2x2", *fHalf_Type, 2, 2))
74     , fHalf2x3_Type(new Type("half2x3", *fHalf_Type, 2, 3))
75     , fHalf2x4_Type(new Type("half2x4", *fHalf_Type, 2, 4))
76     , fHalf3x2_Type(new Type("half3x2", *fHalf_Type, 3, 2))
77     , fHalf3x3_Type(new Type("half3x3", *fHalf_Type, 3, 3))
78     , fHalf3x4_Type(new Type("half3x4", *fHalf_Type, 3, 4))
79     , fHalf4x2_Type(new Type("half4x2", *fHalf_Type, 4, 2))
80     , fHalf4x3_Type(new Type("half4x3", *fHalf_Type, 4, 3))
81     , fHalf4x4_Type(new Type("half4x4", *fHalf_Type, 4, 4))
82     , fDouble2x2_Type(new Type("double2x2", *fDouble_Type, 2, 2))
83     , fDouble2x3_Type(new Type("double2x3", *fDouble_Type, 2, 3))
84     , fDouble2x4_Type(new Type("double2x4", *fDouble_Type, 2, 4))
85     , fDouble3x2_Type(new Type("double3x2", *fDouble_Type, 3, 2))
86     , fDouble3x3_Type(new Type("double3x3", *fDouble_Type, 3, 3))
87     , fDouble3x4_Type(new Type("double3x4", *fDouble_Type, 3, 4))
88     , fDouble4x2_Type(new Type("double4x2", *fDouble_Type, 4, 2))
89     , fDouble4x3_Type(new Type("double4x3", *fDouble_Type, 4, 3))
90     , fDouble4x4_Type(new Type("double4x4", *fDouble_Type, 4, 4))
91     , fSampler1D_Type(new Type("sampler1D", SpvDim1D, false, false, false, true))
92     , fSampler2D_Type(new Type("sampler2D", SpvDim2D, false, false, false, true))
93     , fSampler3D_Type(new Type("sampler3D", SpvDim3D, false, false, false, true))
94     , fSamplerExternalOES_Type(new Type("samplerExternalOES", SpvDim2D, false, false,
95                                         false, true))
96     , fSamplerCube_Type(new Type("samplerCube", SpvDimCube, false, false, false, true))
97     , fSampler2DRect_Type(new Type("sampler2DRect", SpvDimRect, false, false, false, true))
98     , fSampler1DArray_Type(new Type("sampler1DArray"))
99     , fSampler2DArray_Type(new Type("sampler2DArray"))
100     , fSamplerCubeArray_Type(new Type("samplerCubeArray"))
101     , fSamplerBuffer_Type(new Type("samplerBuffer", SpvDimBuffer, false, false, false,
102                                    true))
103     , fSampler2DMS_Type(new Type("sampler2DMS"))
104     , fSampler2DMSArray_Type(new Type("sampler2DMSArray"))
105     , fSampler1DShadow_Type(new Type("sampler1DShadow"))
106     , fSampler2DShadow_Type(new Type("sampler2DShadow"))
107     , fSamplerCubeShadow_Type(new Type("samplerCubeShadow"))
108     , fSampler2DRectShadow_Type(new Type("sampler2DRectShadow"))
109     , fSampler1DArrayShadow_Type(new Type("sampler1DArrayShadow"))
110     , fSampler2DArrayShadow_Type(new Type("sampler2DArrayShadow"))
111     , fSamplerCubeArrayShadow_Type(new Type("samplerCubeArrayShadow"))
112 
113     // Related to below FIXME, gsampler*s don't currently expand to cover integer case.
114     , fISampler2D_Type(new Type("isampler2D", SpvDim2D, false, false, false, true))
115 
116     // FIXME express these as "gimage2D" that expand to image2D, iimage2D, and uimage2D.
117     , fImage2D_Type(new Type("image2D", SpvDim2D, false, false, false, true))
118     , fIImage2D_Type(new Type("iimage2D", SpvDim2D, false, false, false, true))
119 
120     // FIXME express these as "gsubpassInput" that expand to subpassInput, isubpassInput,
121     // and usubpassInput.
122     , fSubpassInput_Type(new Type("subpassInput", SpvDimSubpassData, false, false,
123                                   false, false))
124     , fSubpassInputMS_Type(new Type("subpassInputMS", SpvDimSubpassData, false, false,
125                                     true, false))
126 
127     // FIXME figure out what we're supposed to do with the gsampler et al. types)
128     , fGSampler1D_Type(new Type("$gsampler1D", static_type(*fSampler1D_Type)))
129     , fGSampler2D_Type(new Type("$gsampler2D", static_type(*fSampler2D_Type)))
130     , fGSampler3D_Type(new Type("$gsampler3D", static_type(*fSampler3D_Type)))
131     , fGSamplerCube_Type(new Type("$gsamplerCube", static_type(*fSamplerCube_Type)))
132     , fGSampler2DRect_Type(new Type("$gsampler2DRect", static_type(*fSampler2DRect_Type)))
133     , fGSampler1DArray_Type(new Type("$gsampler1DArray",
134                                      static_type(*fSampler1DArray_Type)))
135     , fGSampler2DArray_Type(new Type("$gsampler2DArray",
136                                      static_type(*fSampler2DArray_Type)))
137     , fGSamplerCubeArray_Type(new Type("$gsamplerCubeArray",
138                                        static_type(*fSamplerCubeArray_Type)))
139     , fGSamplerBuffer_Type(new Type("$gsamplerBuffer", static_type(*fSamplerBuffer_Type)))
140     , fGSampler2DMS_Type(new Type("$gsampler2DMS", static_type(*fSampler2DMS_Type)))
141     , fGSampler2DMSArray_Type(new Type("$gsampler2DMSArray",
142                                        static_type(*fSampler2DMSArray_Type)))
143     , fGSampler2DArrayShadow_Type(new Type("$gsampler2DArrayShadow",
144                                            static_type(*fSampler2DArrayShadow_Type)))
145     , fGSamplerCubeArrayShadow_Type(new Type("$gsamplerCubeArrayShadow",
146                                              static_type(*fSamplerCubeArrayShadow_Type)))
147     , fGenType_Type(new Type("$genType", { fFloat_Type.get(), fFloat2_Type.get(),
148                                            fFloat3_Type.get(), fFloat4_Type.get() }))
149     , fGenHType_Type(new Type("$genHType", { fHalf_Type.get(), fHalf2_Type.get(),
150                                              fHalf3_Type.get(), fHalf4_Type.get() }))
151     , fGenDType_Type(new Type("$genDType", { fDouble_Type.get(), fDouble2_Type.get(),
152                                              fDouble3_Type.get(), fDouble4_Type.get() }))
153     , fGenIType_Type(new Type("$genIType", { fInt_Type.get(), fInt2_Type.get(),
154                                              fInt3_Type.get(), fInt4_Type.get() }))
155     , fGenUType_Type(new Type("$genUType", { fUInt_Type.get(), fUInt2_Type.get(),
156                                              fUInt3_Type.get(), fUInt4_Type.get() }))
157     , fGenBType_Type(new Type("$genBType", { fBool_Type.get(), fBool2_Type.get(),
158                                              fBool3_Type.get(), fBool4_Type.get() }))
159     , fMat_Type(new Type("$mat", { fFloat2x2_Type.get(),  fFloat2x3_Type.get(),
160                                    fFloat2x4_Type.get(),  fFloat3x2_Type.get(),
161                                    fFloat3x3_Type.get(),  fFloat3x4_Type.get(),
162                                    fFloat4x2_Type.get(),  fFloat4x3_Type.get(),
163                                    fFloat4x4_Type.get(),  fHalf2x2_Type.get(),
164                                    fHalf2x3_Type.get(),   fHalf2x4_Type.get(),
165                                    fHalf3x2_Type.get(),   fHalf3x3_Type.get(),
166                                    fHalf3x4_Type.get(),   fHalf4x2_Type.get(),
167                                    fHalf4x3_Type.get(),   fHalf4x4_Type.get(),
168                                    fDouble2x2_Type.get(), fDouble2x3_Type.get(),
169                                    fDouble2x4_Type.get(), fDouble3x2_Type.get(),
170                                    fDouble3x3_Type.get(), fDouble3x4_Type.get(),
171                                    fDouble4x2_Type.get(), fDouble4x3_Type.get(),
172                                    fDouble4x4_Type.get() }))
173     , fVec_Type(new Type("$vec", { fInvalid_Type.get(), fFloat2_Type.get(),
174                                            fFloat3_Type.get(), fFloat4_Type.get() }))
175     , fGVec_Type(new Type("$gvec"))
176     , fGVec2_Type(new Type("$gfloat2"))
177     , fGVec3_Type(new Type("$gfloat3"))
178     , fGVec4_Type(new Type("$gfloat4", static_type(*fFloat4_Type)))
179     , fHVec_Type(new Type("$hvec", { fInvalid_Type.get(), fHalf2_Type.get(),
180                                      fHalf3_Type.get(), fHalf4_Type.get() }))
181     , fDVec_Type(new Type("$dvec", { fInvalid_Type.get(), fDouble2_Type.get(),
182                                      fDouble3_Type.get(), fDouble4_Type.get() }))
183     , fIVec_Type(new Type("$ivec", { fInvalid_Type.get(), fInt2_Type.get(),
184                                      fInt3_Type.get(), fInt4_Type.get() }))
185     , fUVec_Type(new Type("$uvec", { fInvalid_Type.get(), fUInt2_Type.get(),
186                                      fUInt3_Type.get(), fUInt4_Type.get() }))
187     , fSVec_Type(new Type("$svec", { fInvalid_Type.get(), fShort2_Type.get(),
188                                      fShort3_Type.get(), fShort4_Type.get() }))
189     , fUSVec_Type(new Type("$usvec", { fInvalid_Type.get(), fUShort2_Type.get(),
190                                        fUShort3_Type.get(), fUShort4_Type.get() }))
191     , fByteVec_Type(new Type("$bytevec", { fInvalid_Type.get(), fByte2_Type.get(),
192                                      fByte3_Type.get(), fByte4_Type.get() }))
193     , fUByteVec_Type(new Type("$ubytevec", { fInvalid_Type.get(), fUByte2_Type.get(),
194                                        fUByte3_Type.get(), fUByte4_Type.get() }))
195     , fBVec_Type(new Type("$bvec", { fInvalid_Type.get(), fBool2_Type.get(),
196                                      fBool3_Type.get(), fBool4_Type.get() }))
197     , fSkCaps_Type(new Type("$sk_Caps"))
198     , fSkArgs_Type(new Type("$sk_Args"))
199     , fFragmentProcessor_Type(fp_type(fInt_Type.get(), fBool_Type.get()))
200     , fSkRasterPipeline_Type(new Type("SkRasterPipeline"))
201     , fDefined_Expression(new Defined(*fInvalid_Type)) {}
202 
static_type(const Type & t)203     static std::vector<const Type*> static_type(const Type& t) {
204         return { &t, &t, &t, &t };
205     }
206 
207     const std::unique_ptr<Type> fInvalid_Type;
208     const std::unique_ptr<Type> fVoid_Type;
209 
210     const std::unique_ptr<Type> fDouble_Type;
211     const std::unique_ptr<Type> fDouble2_Type;
212     const std::unique_ptr<Type> fDouble3_Type;
213     const std::unique_ptr<Type> fDouble4_Type;
214 
215     const std::unique_ptr<Type> fFloat_Type;
216     const std::unique_ptr<Type> fFloat2_Type;
217     const std::unique_ptr<Type> fFloat3_Type;
218     const std::unique_ptr<Type> fFloat4_Type;
219 
220     const std::unique_ptr<Type> fHalf_Type;
221     const std::unique_ptr<Type> fHalf2_Type;
222     const std::unique_ptr<Type> fHalf3_Type;
223     const std::unique_ptr<Type> fHalf4_Type;
224 
225     const std::unique_ptr<Type> fUInt_Type;
226     const std::unique_ptr<Type> fUInt2_Type;
227     const std::unique_ptr<Type> fUInt3_Type;
228     const std::unique_ptr<Type> fUInt4_Type;
229 
230     const std::unique_ptr<Type> fInt_Type;
231     const std::unique_ptr<Type> fInt2_Type;
232     const std::unique_ptr<Type> fInt3_Type;
233     const std::unique_ptr<Type> fInt4_Type;
234 
235     const std::unique_ptr<Type> fUShort_Type;
236     const std::unique_ptr<Type> fUShort2_Type;
237     const std::unique_ptr<Type> fUShort3_Type;
238     const std::unique_ptr<Type> fUShort4_Type;
239 
240     const std::unique_ptr<Type> fShort_Type;
241     const std::unique_ptr<Type> fShort2_Type;
242     const std::unique_ptr<Type> fShort3_Type;
243     const std::unique_ptr<Type> fShort4_Type;
244 
245     const std::unique_ptr<Type> fUByte_Type;
246     const std::unique_ptr<Type> fUByte2_Type;
247     const std::unique_ptr<Type> fUByte3_Type;
248     const std::unique_ptr<Type> fUByte4_Type;
249 
250     const std::unique_ptr<Type> fByte_Type;
251     const std::unique_ptr<Type> fByte2_Type;
252     const std::unique_ptr<Type> fByte3_Type;
253     const std::unique_ptr<Type> fByte4_Type;
254 
255     const std::unique_ptr<Type> fBool_Type;
256     const std::unique_ptr<Type> fBool2_Type;
257     const std::unique_ptr<Type> fBool3_Type;
258     const std::unique_ptr<Type> fBool4_Type;
259 
260     const std::unique_ptr<Type> fFloat2x2_Type;
261     const std::unique_ptr<Type> fFloat2x3_Type;
262     const std::unique_ptr<Type> fFloat2x4_Type;
263     const std::unique_ptr<Type> fFloat3x2_Type;
264     const std::unique_ptr<Type> fFloat3x3_Type;
265     const std::unique_ptr<Type> fFloat3x4_Type;
266     const std::unique_ptr<Type> fFloat4x2_Type;
267     const std::unique_ptr<Type> fFloat4x3_Type;
268     const std::unique_ptr<Type> fFloat4x4_Type;
269 
270     const std::unique_ptr<Type> fHalf2x2_Type;
271     const std::unique_ptr<Type> fHalf2x3_Type;
272     const std::unique_ptr<Type> fHalf2x4_Type;
273     const std::unique_ptr<Type> fHalf3x2_Type;
274     const std::unique_ptr<Type> fHalf3x3_Type;
275     const std::unique_ptr<Type> fHalf3x4_Type;
276     const std::unique_ptr<Type> fHalf4x2_Type;
277     const std::unique_ptr<Type> fHalf4x3_Type;
278     const std::unique_ptr<Type> fHalf4x4_Type;
279 
280     const std::unique_ptr<Type> fDouble2x2_Type;
281     const std::unique_ptr<Type> fDouble2x3_Type;
282     const std::unique_ptr<Type> fDouble2x4_Type;
283     const std::unique_ptr<Type> fDouble3x2_Type;
284     const std::unique_ptr<Type> fDouble3x3_Type;
285     const std::unique_ptr<Type> fDouble3x4_Type;
286     const std::unique_ptr<Type> fDouble4x2_Type;
287     const std::unique_ptr<Type> fDouble4x3_Type;
288     const std::unique_ptr<Type> fDouble4x4_Type;
289 
290     const std::unique_ptr<Type> fSampler1D_Type;
291     const std::unique_ptr<Type> fSampler2D_Type;
292     const std::unique_ptr<Type> fSampler3D_Type;
293     const std::unique_ptr<Type> fSamplerExternalOES_Type;
294     const std::unique_ptr<Type> fSamplerCube_Type;
295     const std::unique_ptr<Type> fSampler2DRect_Type;
296     const std::unique_ptr<Type> fSampler1DArray_Type;
297     const std::unique_ptr<Type> fSampler2DArray_Type;
298     const std::unique_ptr<Type> fSamplerCubeArray_Type;
299     const std::unique_ptr<Type> fSamplerBuffer_Type;
300     const std::unique_ptr<Type> fSampler2DMS_Type;
301     const std::unique_ptr<Type> fSampler2DMSArray_Type;
302     const std::unique_ptr<Type> fSampler1DShadow_Type;
303     const std::unique_ptr<Type> fSampler2DShadow_Type;
304     const std::unique_ptr<Type> fSamplerCubeShadow_Type;
305     const std::unique_ptr<Type> fSampler2DRectShadow_Type;
306     const std::unique_ptr<Type> fSampler1DArrayShadow_Type;
307     const std::unique_ptr<Type> fSampler2DArrayShadow_Type;
308     const std::unique_ptr<Type> fSamplerCubeArrayShadow_Type;
309 
310     const std::unique_ptr<Type> fISampler2D_Type;
311 
312     const std::unique_ptr<Type> fImage2D_Type;
313     const std::unique_ptr<Type> fIImage2D_Type;
314 
315     const std::unique_ptr<Type> fSubpassInput_Type;
316     const std::unique_ptr<Type> fSubpassInputMS_Type;
317 
318     const std::unique_ptr<Type> fGSampler1D_Type;
319     const std::unique_ptr<Type> fGSampler2D_Type;
320     const std::unique_ptr<Type> fGSampler3D_Type;
321     const std::unique_ptr<Type> fGSamplerCube_Type;
322     const std::unique_ptr<Type> fGSampler2DRect_Type;
323     const std::unique_ptr<Type> fGSampler1DArray_Type;
324     const std::unique_ptr<Type> fGSampler2DArray_Type;
325     const std::unique_ptr<Type> fGSamplerCubeArray_Type;
326     const std::unique_ptr<Type> fGSamplerBuffer_Type;
327     const std::unique_ptr<Type> fGSampler2DMS_Type;
328     const std::unique_ptr<Type> fGSampler2DMSArray_Type;
329     const std::unique_ptr<Type> fGSampler2DArrayShadow_Type;
330     const std::unique_ptr<Type> fGSamplerCubeArrayShadow_Type;
331 
332     const std::unique_ptr<Type> fGenType_Type;
333     const std::unique_ptr<Type> fGenHType_Type;
334     const std::unique_ptr<Type> fGenDType_Type;
335     const std::unique_ptr<Type> fGenIType_Type;
336     const std::unique_ptr<Type> fGenUType_Type;
337     const std::unique_ptr<Type> fGenBType_Type;
338 
339     const std::unique_ptr<Type> fMat_Type;
340 
341     const std::unique_ptr<Type> fVec_Type;
342 
343     const std::unique_ptr<Type> fGVec_Type;
344     const std::unique_ptr<Type> fGVec2_Type;
345     const std::unique_ptr<Type> fGVec3_Type;
346     const std::unique_ptr<Type> fGVec4_Type;
347     const std::unique_ptr<Type> fHVec_Type;
348     const std::unique_ptr<Type> fDVec_Type;
349     const std::unique_ptr<Type> fIVec_Type;
350     const std::unique_ptr<Type> fUVec_Type;
351     const std::unique_ptr<Type> fSVec_Type;
352     const std::unique_ptr<Type> fUSVec_Type;
353     const std::unique_ptr<Type> fByteVec_Type;
354     const std::unique_ptr<Type> fUByteVec_Type;
355 
356     const std::unique_ptr<Type> fBVec_Type;
357 
358     const std::unique_ptr<Type> fSkCaps_Type;
359     const std::unique_ptr<Type> fSkArgs_Type;
360     const std::unique_ptr<Type> fFragmentProcessor_Type;
361     const std::unique_ptr<Type> fSkRasterPipeline_Type;
362 
363     // dummy expression used to mark that a variable has a value during dataflow analysis (when it
364     // could have several different values, or the analyzer is otherwise unable to assign it a
365     // specific expression)
366     const std::unique_ptr<Expression> fDefined_Expression;
367 
368 private:
369     class Defined : public Expression {
370     public:
Defined(const Type & type)371         Defined(const Type& type)
372         : INHERITED(-1, kDefined_Kind, type) {}
373 
hasSideEffects()374         bool hasSideEffects() const override {
375             return false;
376         }
377 
description()378         String description() const override {
379             return "<defined>";
380         }
381 
clone()382         std::unique_ptr<Expression> clone() const override {
383             return std::unique_ptr<Expression>(new Defined(fType));
384         }
385 
386         typedef Expression INHERITED;
387     };
388 
fp_type(const Type * intType,const Type * boolType)389     static std::unique_ptr<Type> fp_type(const Type* intType, const Type* boolType) {
390         // Build fields for FragmentProcessors, which should parallel the
391         // C++ API for GrFragmentProcessor.
392         Modifiers mods(Layout(), Modifiers::kConst_Flag);
393         std::vector<Type::Field> fields = {
394             Type::Field(mods, "numTextureSamplers", intType),
395             Type::Field(mods, "numCoordTransforms", intType),
396             Type::Field(mods, "numChildProcessors", intType),
397             Type::Field(mods, "usesLocalCoords", boolType),
398             Type::Field(mods, "compatibleWithCoverageAsAlpha", boolType),
399             Type::Field(mods, "preservesOpaqueInput", boolType),
400             Type::Field(mods, "hasConstantOutputForConstantInput", boolType)
401         };
402         return std::unique_ptr<Type>(new Type("fragmentProcessor", fields));
403     }
404 };
405 
406 } // namespace
407 
408 #endif
409