Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/sksl/SkSLContext.h

Issue 2442063002: Reduced skslc memory consumption (Closed)
Patch Set: added a few more functions Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/sksl/SkSLIRGenerator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SKSL_CONTEXT 8 #ifndef SKSL_CONTEXT
9 #define SKSL_CONTEXT 9 #define SKSL_CONTEXT
10 10
11 #include "ir/SkSLType.h" 11 #include "ir/SkSLType.h"
12 #include "ir/SkSLExpression.h" 12 #include "ir/SkSLExpression.h"
13 13
14 namespace SkSL { 14 namespace SkSL {
15 15
16 /** 16 /**
17 * Contains compiler-wide objects, which currently means the core types. 17 * Contains compiler-wide objects, which currently means the core types.
18 */ 18 */
19 class Context { 19 class Context {
20 public: 20 public:
21 Context() 21 Context()
22 : fVoid_Type(new Type("void")) 22 : fInvalid_Type(new Type("<INVALID>"))
23 , fVoid_Type(new Type("void"))
23 , fDouble_Type(new Type("double", true)) 24 , fDouble_Type(new Type("double", true))
24 , fDVec2_Type(new Type("dvec2", *fDouble_Type, 2)) 25 , fDVec2_Type(new Type("dvec2", *fDouble_Type, 2))
25 , fDVec3_Type(new Type("dvec3", *fDouble_Type, 3)) 26 , fDVec3_Type(new Type("dvec3", *fDouble_Type, 3))
26 , fDVec4_Type(new Type("dvec4", *fDouble_Type, 4)) 27 , fDVec4_Type(new Type("dvec4", *fDouble_Type, 4))
27 , fFloat_Type(new Type("float", true, { fDouble_Type.get() })) 28 , fFloat_Type(new Type("float", true, { fDouble_Type.get() }))
28 , fVec2_Type(new Type("vec2", *fFloat_Type, 2)) 29 , fVec2_Type(new Type("vec2", *fFloat_Type, 2))
29 , fVec3_Type(new Type("vec3", *fFloat_Type, 3)) 30 , fVec3_Type(new Type("vec3", *fFloat_Type, 3))
30 , fVec4_Type(new Type("vec4", *fFloat_Type, 4)) 31 , fVec4_Type(new Type("vec4", *fFloat_Type, 4))
31 , fUInt_Type(new Type("uint", true, { fFloat_Type.get(), fDouble_Type.get() })) 32 , fUInt_Type(new Type("uint", true, { fFloat_Type.get(), fDouble_Type.get() }))
32 , fUVec2_Type(new Type("uvec2", *fUInt_Type, 2)) 33 , fUVec2_Type(new Type("uvec2", *fUInt_Type, 2))
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 fVec4_Type.get() })) 98 fVec4_Type.get() }))
98 , fGenDType_Type(new Type("$genDType", { fDouble_Type.get(), fDVec2_Type.get (), 99 , fGenDType_Type(new Type("$genDType", { fDouble_Type.get(), fDVec2_Type.get (),
99 fDVec3_Type.get(), fDVec4_Type.get( ) })) 100 fDVec3_Type.get(), fDVec4_Type.get( ) }))
100 , fGenIType_Type(new Type("$genIType", { fInt_Type.get(), fIVec2_Type.get(), fIVec3_Type.get(), 101 , fGenIType_Type(new Type("$genIType", { fInt_Type.get(), fIVec2_Type.get(), fIVec3_Type.get(),
101 fIVec4_Type.get() })) 102 fIVec4_Type.get() }))
102 , fGenUType_Type(new Type("$genUType", { fUInt_Type.get(), fUVec2_Type.get() , fUVec3_Type.get(), 103 , fGenUType_Type(new Type("$genUType", { fUInt_Type.get(), fUVec2_Type.get() , fUVec3_Type.get(),
103 fUVec4_Type.get() })) 104 fUVec4_Type.get() }))
104 , fGenBType_Type(new Type("$genBType", { fBool_Type.get(), fBVec2_Type.get() , fBVec3_Type.get(), 105 , fGenBType_Type(new Type("$genBType", { fBool_Type.get(), fBVec2_Type.get() , fBVec3_Type.get(),
105 fBVec4_Type.get() })) 106 fBVec4_Type.get() }))
106 , fMat_Type(new Type("$mat")) 107 , fMat_Type(new Type("$mat"))
107 , fVec_Type(new Type("$vec", { fVec2_Type.get(), fVec2_Type.get(), fVec3_Typ e.get(), 108 , fVec_Type(new Type("$vec", { fInvalid_Type.get(), fVec2_Type.get(), fVec3_ Type.get(),
108 fVec4_Type.get() })) 109 fVec4_Type.get() }))
109 , fGVec_Type(new Type("$gvec")) 110 , fGVec_Type(new Type("$gvec"))
110 , fGVec2_Type(new Type("$gvec2")) 111 , fGVec2_Type(new Type("$gvec2"))
111 , fGVec3_Type(new Type("$gvec3")) 112 , fGVec3_Type(new Type("$gvec3"))
112 , fGVec4_Type(new Type("$gvec4", static_type(*fVec4_Type))) 113 , fGVec4_Type(new Type("$gvec4", static_type(*fVec4_Type)))
113 , fDVec_Type(new Type("$dvec")) 114 , fDVec_Type(new Type("$dvec", { fInvalid_Type.get(), fDVec2_Type.get(), fDV ec3_Type.get(),
114 , fIVec_Type(new Type("$ivec")) 115 fDVec4_Type.get() }))
115 , fUVec_Type(new Type("$uvec")) 116 , fIVec_Type(new Type("$ivec", { fInvalid_Type.get(), fIVec2_Type.get(), fIV ec3_Type.get(),
116 , fBVec_Type(new Type("$bvec", { fBVec2_Type.get(), fBVec2_Type.get(), fBVec 3_Type.get(), 117 fIVec4_Type.get() }))
118 , fUVec_Type(new Type("$uvec", { fInvalid_Type.get(), fUVec2_Type.get(), fUV ec3_Type.get(),
119 fUVec4_Type.get() }))
120 , fBVec_Type(new Type("$bvec", { fInvalid_Type.get(), fBVec2_Type.get(), fBV ec3_Type.get(),
117 fBVec4_Type.get() })) 121 fBVec4_Type.get() }))
118 , fInvalid_Type(new Type("<INVALID>"))
119 , fDefined_Expression(new Defined(*fInvalid_Type)) {} 122 , fDefined_Expression(new Defined(*fInvalid_Type)) {}
120 123
121 static std::vector<const Type*> static_type(const Type& t) { 124 static std::vector<const Type*> static_type(const Type& t) {
122 return { &t, &t, &t, &t }; 125 return { &t, &t, &t, &t };
123 } 126 }
124 127
128 const std::unique_ptr<Type> fInvalid_Type;
125 const std::unique_ptr<Type> fVoid_Type; 129 const std::unique_ptr<Type> fVoid_Type;
126 130
127 const std::unique_ptr<Type> fDouble_Type; 131 const std::unique_ptr<Type> fDouble_Type;
128 const std::unique_ptr<Type> fDVec2_Type; 132 const std::unique_ptr<Type> fDVec2_Type;
129 const std::unique_ptr<Type> fDVec3_Type; 133 const std::unique_ptr<Type> fDVec3_Type;
130 const std::unique_ptr<Type> fDVec4_Type; 134 const std::unique_ptr<Type> fDVec4_Type;
131 135
132 const std::unique_ptr<Type> fFloat_Type; 136 const std::unique_ptr<Type> fFloat_Type;
133 const std::unique_ptr<Type> fVec2_Type; 137 const std::unique_ptr<Type> fVec2_Type;
134 const std::unique_ptr<Type> fVec3_Type; 138 const std::unique_ptr<Type> fVec3_Type;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 const std::unique_ptr<Type> fGVec_Type; 220 const std::unique_ptr<Type> fGVec_Type;
217 const std::unique_ptr<Type> fGVec2_Type; 221 const std::unique_ptr<Type> fGVec2_Type;
218 const std::unique_ptr<Type> fGVec3_Type; 222 const std::unique_ptr<Type> fGVec3_Type;
219 const std::unique_ptr<Type> fGVec4_Type; 223 const std::unique_ptr<Type> fGVec4_Type;
220 const std::unique_ptr<Type> fDVec_Type; 224 const std::unique_ptr<Type> fDVec_Type;
221 const std::unique_ptr<Type> fIVec_Type; 225 const std::unique_ptr<Type> fIVec_Type;
222 const std::unique_ptr<Type> fUVec_Type; 226 const std::unique_ptr<Type> fUVec_Type;
223 227
224 const std::unique_ptr<Type> fBVec_Type; 228 const std::unique_ptr<Type> fBVec_Type;
225 229
226 const std::unique_ptr<Type> fInvalid_Type;
227
228 // dummy expression used to mark that a variable has a value during dataflow analysis (when it 230 // dummy expression used to mark that a variable has a value during dataflow analysis (when it
229 // could have several different values, or the analyzer is otherwise unable to assign it a 231 // could have several different values, or the analyzer is otherwise unable to assign it a
230 // specific expression) 232 // specific expression)
231 const std::unique_ptr<Expression> fDefined_Expression; 233 const std::unique_ptr<Expression> fDefined_Expression;
232 234
233 private: 235 private:
234 class Defined : public Expression { 236 class Defined : public Expression {
235 public: 237 public:
236 Defined(const Type& type) 238 Defined(const Type& type)
237 : INHERITED(Position(), kDefined_Kind, type) {} 239 : INHERITED(Position(), kDefined_Kind, type) {}
238 240
239 virtual std::string description() const override { 241 virtual std::string description() const override {
240 return "<defined>"; 242 return "<defined>";
241 } 243 }
242 244
243 typedef Expression INHERITED; 245 typedef Expression INHERITED;
244 }; 246 };
245 }; 247 };
246 248
247 } // namespace 249 } // namespace
248 250
249 #endif 251 #endif
OLDNEW
« no previous file with comments | « no previous file | src/sksl/SkSLIRGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698