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

Side by Side Diff: include/gpu/GrProcessor.h

Issue 647183002: Revert of Opt state takes a GP instead of a GeometryStage (Closed) Base URL: https://skia.googlesource.com/skia.git@builder_cleanup
Patch Set: Created 6 years, 2 months 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 | include/gpu/GrProcessorStage.h » ('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 2012 Google Inc. 2 * Copyright 2012 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 GrProcessor_DEFINED 8 #ifndef GrProcessor_DEFINED
9 #define GrProcessor_DEFINED 9 #define GrProcessor_DEFINED
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 this->assertEquality(other); 117 this->assertEquality(other);
118 } 118 }
119 #endif 119 #endif
120 return result; 120 return result;
121 } 121 }
122 122
123 /** Human-meaningful string to identify this effect; may be embedded 123 /** Human-meaningful string to identify this effect; may be embedded
124 in generated shader code. */ 124 in generated shader code. */
125 const char* name() const; 125 const char* name() const;
126 126
127 int numTransforms() const { return fCoordTransforms.count(); }
128
129 /** Returns the coordinate transformation at index. index must be valid acco rding to
130 numTransforms(). */
131 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; }
132
127 int numTextures() const { return fTextureAccesses.count(); } 133 int numTextures() const { return fTextureAccesses.count(); }
128 134
129 /** Returns the access pattern for the texture at index. index must be valid according to 135 /** Returns the access pattern for the texture at index. index must be valid according to
130 numTextures(). */ 136 numTextures(). */
131 const GrTextureAccess& textureAccess(int index) const { return *fTextureAcce sses[index]; } 137 const GrTextureAccess& textureAccess(int index) const { return *fTextureAcce sses[index]; }
132 138
133 /** Shortcut for textureAccess(index).texture(); */ 139 /** Shortcut for textureAccess(index).texture(); */
134 GrTexture* texture(int index) const { return this->textureAccess(index).getT exture(); } 140 GrTexture* texture(int index) const { return this->textureAccess(index).getT exture(); }
135 141
136 /** Will this effect read the fragment position? */ 142 /** Will this effect read the fragment position? */
137 bool willReadFragmentPosition() const { return fWillReadFragmentPosition; } 143 bool willReadFragmentPosition() const { return fWillReadFragmentPosition; }
138 144
139 void* operator new(size_t size); 145 void* operator new(size_t size);
140 void operator delete(void* target); 146 void operator delete(void* target);
141 147
142 void* operator new(size_t size, void* placement) { 148 void* operator new(size_t size, void* placement) {
143 return ::operator new(size, placement); 149 return ::operator new(size, placement);
144 } 150 }
145 void operator delete(void* target, void* placement) { 151 void operator delete(void* target, void* placement) {
146 ::operator delete(target, placement); 152 ::operator delete(target, placement);
147 } 153 }
148 154
149 /** 155 /**
150 * Helper for down-casting to a GrProcessor subclass 156 * Helper for down-casting to a GrProcessor subclass
151 */ 157 */
152 template <typename T> const T& cast() const { return *static_cast<const T*>( this); } 158 template <typename T> const T& cast() const { return *static_cast<const T*>( this); }
153 159
154 protected: 160 protected:
155 /** 161 /**
162 * Subclasses call this from their constructor to register coordinate transf ormations. The
163 * effect subclass manages the lifetime of the transformations (this functio n only stores a
164 * pointer). The GrCoordTransform is typically a member field of the GrProce ssor subclass. When
165 * the matrix has perspective, the transformed coordinates will have 3 compo nents. Otherwise
166 * they'll have 2. This must only be called from the constructor because GrP rocessors are
167 * immutable.
168 */
169 void addCoordTransform(const GrCoordTransform* coordTransform);
170
171 /**
156 * Subclasses call this from their constructor to register GrTextureAccesses . The effect 172 * Subclasses call this from their constructor to register GrTextureAccesses . The effect
157 * subclass manages the lifetime of the accesses (this function only stores a pointer). The 173 * subclass manages the lifetime of the accesses (this function only stores a pointer). The
158 * GrTextureAccess is typically a member field of the GrProcessor subclass. This must only be 174 * GrTextureAccess is typically a member field of the GrProcessor subclass. This must only be
159 * called from the constructor because GrProcessors are immutable. 175 * called from the constructor because GrProcessors are immutable.
160 */ 176 */
161 void addTextureAccess(const GrTextureAccess* textureAccess); 177 void addTextureAccess(const GrTextureAccess* textureAccess);
162 178
163 GrProcessor() 179 GrProcessor()
164 : fWillReadFragmentPosition(false) {} 180 : fWillReadFragmentPosition(false) {}
165 181
166 /** 182 /**
167 * If the effect will generate a backend-specific effect that will read the fragment position 183 * If the effect will generate a backend-specific effect that will read the fragment position
168 * in the FS then it must call this method from its constructor. Otherwise, the request to 184 * in the FS then it must call this method from its constructor. Otherwise, the request to
169 * access the fragment position will be denied. 185 * access the fragment position will be denied.
170 */ 186 */
171 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } 187 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
172 188
173 private: 189 private:
174 SkDEBUGCODE(void assertEquality(const GrProcessor& other) const;) 190 SkDEBUGCODE(void assertEquality(const GrProcessor& other) const;)
175 191
176 /** Subclass implements this to support isEqual(). It will only be called if it is known that 192 /** Subclass implements this to support isEqual(). It will only be called if it is known that
177 the two effects are of the same subclass (i.e. they return the same obje ct from 193 the two effects are of the same subclass (i.e. they return the same obje ct from
178 getFactory()).*/ 194 getFactory()).*/
179 virtual bool onIsEqual(const GrProcessor& other) const = 0; 195 virtual bool onIsEqual(const GrProcessor& other) const = 0;
180 196
181 /** 197 /**
182 * Subclass implements this to support getConstantColorComponents(...). 198 * Subclass implements this to support getConstantColorComponents(...).
183 */ 199 */
184 virtual void onComputeInvariantOutput(InvariantOutput* inout) const = 0; 200 virtual void onComputeInvariantOutput(InvariantOutput* inout) const = 0;
201 friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes.
185 202
203 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
186 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; 204 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
187 bool fWillReadFragmentPosition; 205 bool fWillReadFragmentPosition;
188 206
189 typedef GrProgramElement INHERITED; 207 typedef GrProgramElement INHERITED;
190 }; 208 };
191 209
192 class GrFragmentProcessor : public GrProcessor { 210 class GrFragmentProcessor : public GrProcessor {
193 public: 211 public:
194 GrFragmentProcessor() 212 GrFragmentProcessor()
195 : INHERITED() 213 : INHERITED()
196 , fWillReadDstColor(false) 214 , fWillReadDstColor(false)
197 , fWillUseInputColor(true) {} 215 , fWillUseInputColor(true) {}
198 216
199 virtual const GrBackendFragmentProcessorFactory& getFactory() const = 0; 217 virtual const GrBackendFragmentProcessorFactory& getFactory() const = 0;
200 218
201 int numTransforms() const { return fCoordTransforms.count(); }
202
203 /** Returns the coordinate transformation at index. index must be valid acco rding to
204 numTransforms(). */
205 const GrCoordTransform& coordTransform(int index) const { return *fCoordTran sforms[index]; }
206
207 /** Will this effect read the destination pixel value? */ 219 /** Will this effect read the destination pixel value? */
208 bool willReadDstColor() const { return fWillReadDstColor; } 220 bool willReadDstColor() const { return fWillReadDstColor; }
209 221
210 /** Will this effect read the source color value? */ 222 /** Will this effect read the source color value? */
211 bool willUseInputColor() const { return fWillUseInputColor; } 223 bool willUseInputColor() const { return fWillUseInputColor; }
212 224
213 protected: 225 protected:
214 /** 226 /**
215 * Fragment Processor subclasses call this from their constructor to registe r coordinate
216 * transformations. The processor subclass manages the lifetime of the trans formations (this
217 * function only stores a pointer). The GrCoordTransform is typically a memb er field of the
218 * GrProcessor subclass. When the matrix has perspective, the transformed co ordinates will have
219 * 3 components. Otherwise they'll have 2. This must only be called from the constructor because
220 * GrProcessors are immutable.
221 */
222 void addCoordTransform(const GrCoordTransform*);
223
224 /**
225 * If the effect subclass will read the destination pixel value then it must call this function 227 * If the effect subclass will read the destination pixel value then it must call this function
226 * from its constructor. Otherwise, when its generated backend-specific effe ct class attempts 228 * from its constructor. Otherwise, when its generated backend-specific effe ct class attempts
227 * to generate code that reads the destination pixel it will fail. 229 * to generate code that reads the destination pixel it will fail.
228 */ 230 */
229 void setWillReadDstColor() { fWillReadDstColor = true; } 231 void setWillReadDstColor() { fWillReadDstColor = true; }
230 232
231 /** 233 /**
232 * If the effect will generate a result that does not depend on the input co lor value then it 234 * If the effect will generate a result that does not depend on the input co lor value then it
233 * must call this function from its constructor. Otherwise, when its generat ed backend-specific 235 * must call this function from its constructor. Otherwise, when its generat ed backend-specific
234 * code might fail during variable binding due to unused variables. 236 * code might fail during variable binding due to unused variables.
235 */ 237 */
236 void setWillNotUseInputColor() { fWillUseInputColor = false; } 238 void setWillNotUseInputColor() { fWillUseInputColor = false; }
237 239
238 private: 240 private:
239 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
240 bool fWillReadDstColor; 241 bool fWillReadDstColor;
241 bool fWillUseInputColor; 242 bool fWillUseInputColor;
242 243
243 typedef GrProcessor INHERITED; 244 typedef GrProcessor INHERITED;
244 }; 245 };
245 246
246 /** 247 /**
247 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called 248 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called
248 * at global destruction time. NAME will be the name of the created GrProcessor. 249 * at global destruction time. NAME will be the name of the created GrProcessor.
249 */ 250 */
250 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \ 251 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \
251 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ 252 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \
252 static GrFragmentProcessor* \ 253 static GrFragmentProcessor* \
253 NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \ 254 NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \
254 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME); 255 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME);
255 256
256 #endif 257 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrProcessorStage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698