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

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

Issue 25023003: Implement color filter as GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « gyp/tests.gyp ('k') | include/gpu/GrPaint.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 GrEffect_DEFINED 8 #ifndef GrEffect_DEFINED
9 #define GrEffect_DEFINED 9 #define GrEffect_DEFINED
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 /** 89 /**
90 * This function is used to perform optimizations. When called the color and validFlags params 90 * This function is used to perform optimizations. When called the color and validFlags params
91 * indicate whether the input components to this effect in the FS will have known values. 91 * indicate whether the input components to this effect in the FS will have known values.
92 * validFlags is a bitfield of GrColorComponentFlags. The function updates b oth params to 92 * validFlags is a bitfield of GrColorComponentFlags. The function updates b oth params to
93 * indicate known values of its output. A component of the color param only has meaning if the 93 * indicate known values of its output. A component of the color param only has meaning if the
94 * corresponding bit in validFlags is set. 94 * corresponding bit in validFlags is set.
95 */ 95 */
96 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const = 0; 96 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const = 0;
97 97
98 /** Will this effect read the source color value? */
99 bool willUseInputColor() const { return fWillUseInputColor; }
100
98 /** This object, besides creating back-end-specific helper objects, is used for run-time-type- 101 /** This object, besides creating back-end-specific helper objects, is used for run-time-type-
99 identification. The factory should be an instance of templated class, 102 identification. The factory should be an instance of templated class,
100 GrTBackendEffectFactory. It is templated on the subclass of GrEffect. Th e subclass must have 103 GrTBackendEffectFactory. It is templated on the subclass of GrEffect. Th e subclass must have
101 a nested type (or typedef) named GLEffect which will be the subclass of GrGLEffect created 104 a nested type (or typedef) named GLEffect which will be the subclass of GrGLEffect created
102 by the factory. 105 by the factory.
103 106
104 Example: 107 Example:
105 class MyCustomEffect : public GrEffect { 108 class MyCustomEffect : public GrEffect {
106 ... 109 ...
107 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE { 110 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 * Subclasses call this from their constructor to register GrTextureAccesses . The effect 217 * Subclasses call this from their constructor to register GrTextureAccesses . The effect
215 * subclass manages the lifetime of the accesses (this function only stores a pointer). The 218 * subclass manages the lifetime of the accesses (this function only stores a pointer). The
216 * GrTextureAccess is typically a member field of the GrEffect subclass. Thi s must only be 219 * GrTextureAccess is typically a member field of the GrEffect subclass. Thi s must only be
217 * called from the constructor because GrEffects are immutable. 220 * called from the constructor because GrEffects are immutable.
218 */ 221 */
219 void addTextureAccess(const GrTextureAccess* textureAccess); 222 void addTextureAccess(const GrTextureAccess* textureAccess);
220 223
221 GrEffect() 224 GrEffect()
222 : fWillReadDstColor(false) 225 : fWillReadDstColor(false)
223 , fWillReadFragmentPosition(false) 226 , fWillReadFragmentPosition(false)
227 , fWillUseInputColor(true)
224 , fHasVertexCode(false) 228 , fHasVertexCode(false)
225 , fEffectRef(NULL) {} 229 , fEffectRef(NULL) {}
226 230
227 /** This should be called by GrEffect subclass factories. See the comment on AutoEffectUnref for 231 /** This should be called by GrEffect subclass factories. See the comment on AutoEffectUnref for
228 an example factory function. */ 232 an example factory function. */
229 static GrEffectRef* CreateEffectRef(GrEffect* effect) { 233 static GrEffectRef* CreateEffectRef(GrEffect* effect) {
230 if (NULL == effect->fEffectRef) { 234 if (NULL == effect->fEffectRef) {
231 effect->fEffectRef = SkNEW_ARGS(GrEffectRef, (effect)); 235 effect->fEffectRef = SkNEW_ARGS(GrEffectRef, (effect));
232 } else { 236 } else {
233 effect->fEffectRef->ref(); 237 effect->fEffectRef->ref();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 */ 284 */
281 void setWillReadDstColor() { fWillReadDstColor = true; } 285 void setWillReadDstColor() { fWillReadDstColor = true; }
282 286
283 /** 287 /**
284 * If the effect will generate a backend-specific effect that will read the fragment position 288 * If the effect will generate a backend-specific effect that will read the fragment position
285 * in the FS then it must call this method from its constructor. Otherwise, the request to 289 * in the FS then it must call this method from its constructor. Otherwise, the request to
286 * access the fragment position will be denied. 290 * access the fragment position will be denied.
287 */ 291 */
288 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } 292 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
289 293
294 /**
295 * If the effect will generate a result that does not depend on the input co lor value then it must
296 * call this function from its constructor. Otherwise, when its generated ba ckend-specific code
297 * might fail during variable binding due to unused variables.
298 */
299 void setWillNotUseInputColor() { fWillUseInputColor = false; }
300
290 private: 301 private:
291 bool isEqual(const GrEffect& other) const { 302 bool isEqual(const GrEffect& other) const {
292 if (&this->getFactory() != &other.getFactory()) { 303 if (&this->getFactory() != &other.getFactory()) {
293 return false; 304 return false;
294 } 305 }
295 bool result = this->onIsEqual(other); 306 bool result = this->onIsEqual(other);
296 #ifdef SK_DEBUG 307 #ifdef SK_DEBUG
297 if (result) { 308 if (result) {
298 this->assertEquality(other); 309 this->assertEquality(other);
299 } 310 }
(...skipping 14 matching lines...) Expand all
314 friend class GrEffectStage; // to rewrap GrEffect in GrEffectRef when resto ring an effect-stage 325 friend class GrEffectStage; // to rewrap GrEffect in GrEffectRef when resto ring an effect-stage
315 // from deferred state, to call isEqual on nake d GrEffects, and 326 // from deferred state, to call isEqual on nake d GrEffects, and
316 // to inc/dec deferred ref counts. 327 // to inc/dec deferred ref counts.
317 friend class GrVertexEffect; // to set fHasVertexCode and build fVertexAttri bTypes. 328 friend class GrVertexEffect; // to set fHasVertexCode and build fVertexAttri bTypes.
318 329
319 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; 330 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
320 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; 331 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
321 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes; 332 SkSTArray<kMaxVertexAttribs, GrSLType, true> fVertexAttribTypes;
322 bool fWillReadDstColor; 333 bool fWillReadDstColor;
323 bool fWillReadFragmentPosition; 334 bool fWillReadFragmentPosition;
335 bool fWillUseInputColor;
324 bool fHasVertexCode; 336 bool fHasVertexCode;
325 GrEffectRef* fEffectRef; 337 GrEffectRef* fEffectRef;
326 338
327 typedef SkRefCnt INHERITED; 339 typedef SkRefCnt INHERITED;
328 }; 340 };
329 341
330 inline GrEffectRef::GrEffectRef(GrEffect* effect) { 342 inline GrEffectRef::GrEffectRef(GrEffect* effect) {
331 SkASSERT(NULL != effect); 343 SkASSERT(NULL != effect);
332 effect->ref(); 344 effect->ref();
333 fEffect = effect; 345 fEffect = effect;
(...skipping 10 matching lines...) Expand all
344 }; \ 356 }; \
345 static SkAlignedSStorage<k_##NAME##_StorageSize> g_##NAME##_Storage; \ 357 static SkAlignedSStorage<k_##NAME##_StorageSize> g_##NAME##_Storage; \
346 static void* NAME##_RefLocation = (char*)g_##NAME##_Storage.get() + k_##NAME##_E ffectRefOffset; \ 358 static void* NAME##_RefLocation = (char*)g_##NAME##_Storage.get() + k_##NAME##_E ffectRefOffset; \
347 static GrEffect* NAME##_Effect SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EF FECT_CLASS, ARGS);\ 359 static GrEffect* NAME##_Effect SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EF FECT_CLASS, ARGS);\
348 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME##_Effect); \ 360 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME##_Effect); \
349 static GrEffectRef* NAME(GrEffect::CreateStaticEffectRef(NAME##_RefLocation, NAM E##_Effect)); \ 361 static GrEffectRef* NAME(GrEffect::CreateStaticEffectRef(NAME##_RefLocation, NAM E##_Effect)); \
350 static SkAutoTDestroy<GrEffectRef> NAME##_Ref_ad(NAME) 362 static SkAutoTDestroy<GrEffectRef> NAME##_Ref_ad(NAME)
351 363
352 364
353 #endif 365 #endif
OLDNEW
« no previous file with comments | « gyp/tests.gyp ('k') | include/gpu/GrPaint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698