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

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

Issue 571163002: removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: rebase after revert Created 6 years, 3 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 | « include/gpu/GrDrawEffect.h ('k') | include/gpu/GrTBackendEffectFactory.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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 void* operator new(size_t size); 123 void* operator new(size_t size);
124 void operator delete(void* target); 124 void operator delete(void* target);
125 125
126 void* operator new(size_t size, void* placement) { 126 void* operator new(size_t size, void* placement) {
127 return ::operator new(size, placement); 127 return ::operator new(size, placement);
128 } 128 }
129 void operator delete(void* target, void* placement) { 129 void operator delete(void* target, void* placement) {
130 ::operator delete(target, placement); 130 ::operator delete(target, placement);
131 } 131 }
132 132
133 /**
134 * Helper for down-casting to a GrEffect subclass
135 */
136 template <typename T> const T& cast() const { return *static_cast<const T*>( this); }
137
133 protected: 138 protected:
134 /** 139 /**
135 * Subclasses call this from their constructor to register coordinate transf ormations. The 140 * Subclasses call this from their constructor to register coordinate transf ormations. The
136 * effect subclass manages the lifetime of the transformations (this functio n only stores a 141 * effect subclass manages the lifetime of the transformations (this functio n only stores a
137 * pointer). The GrCoordTransform is typically a member field of the GrEffec t subclass. When the 142 * pointer). The GrCoordTransform is typically a member field of the GrEffec t subclass. When the
138 * matrix has perspective, the transformed coordinates will have 3 component s. Otherwise they'll 143 * matrix has perspective, the transformed coordinates will have 3 component s. Otherwise they'll
139 * have 2. This must only be called from the constructor because GrEffects a re immutable. 144 * have 2. This must only be called from the constructor because GrEffects a re immutable.
140 */ 145 */
141 void addCoordTransform(const GrCoordTransform* coordTransform); 146 void addCoordTransform(const GrCoordTransform* coordTransform);
142 147
143 /** 148 /**
144 * Subclasses call this from their constructor to register GrTextureAccesses . The effect 149 * Subclasses call this from their constructor to register GrTextureAccesses . The effect
145 * subclass manages the lifetime of the accesses (this function only stores a pointer). The 150 * subclass manages the lifetime of the accesses (this function only stores a pointer). The
146 * GrTextureAccess is typically a member field of the GrEffect subclass. Thi s must only be 151 * GrTextureAccess is typically a member field of the GrEffect subclass. Thi s must only be
147 * called from the constructor because GrEffects are immutable. 152 * called from the constructor because GrEffects are immutable.
148 */ 153 */
149 void addTextureAccess(const GrTextureAccess* textureAccess); 154 void addTextureAccess(const GrTextureAccess* textureAccess);
150 155
151 GrEffect() 156 GrEffect()
152 : fWillReadDstColor(false) 157 : fWillReadDstColor(false)
153 , fWillReadFragmentPosition(false) 158 , fWillReadFragmentPosition(false)
154 , fWillUseInputColor(true) 159 , fWillUseInputColor(true)
155 , fRequiresVertexShader(false) {} 160 , fRequiresVertexShader(false) {}
156 161
157 /** 162 /**
158 * Helper for down-casting to a GrEffect subclass
159 */
160 template <typename T> static const T& CastEffect(const GrEffect& effect) {
161 return *static_cast<const T*>(&effect);
162 }
163
164 /**
165 * If the effect subclass will read the destination pixel value then it must call this function 163 * If the effect subclass will read the destination pixel value then it must call this function
166 * from its constructor. Otherwise, when its generated backend-specific effe ct class attempts 164 * from its constructor. Otherwise, when its generated backend-specific effe ct class attempts
167 * to generate code that reads the destination pixel it will fail. 165 * to generate code that reads the destination pixel it will fail.
168 */ 166 */
169 void setWillReadDstColor() { fWillReadDstColor = true; } 167 void setWillReadDstColor() { fWillReadDstColor = true; }
170 168
171 /** 169 /**
172 * If the effect will generate a backend-specific effect that will read the fragment position 170 * If the effect will generate a backend-specific effect that will read the fragment position
173 * in the FS then it must call this method from its constructor. Otherwise, the request to 171 * in the FS then it must call this method from its constructor. Otherwise, the request to
174 * access the fragment position will be denied. 172 * access the fragment position will be denied.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 /** 204 /**
207 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called 205 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called
208 * at global destruction time. NAME will be the name of the created GrEffect. 206 * at global destruction time. NAME will be the name of the created GrEffect.
209 */ 207 */
210 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \ 208 #define GR_CREATE_STATIC_EFFECT(NAME, EFFECT_CLASS, ARGS) \
211 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ 209 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \
212 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS S, ARGS); \ 210 static GrEffect* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLAS S, ARGS); \
213 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME); 211 static SkAutoTDestroy<GrEffect> NAME##_ad(NAME);
214 212
215 #endif 213 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrDrawEffect.h ('k') | include/gpu/GrTBackendEffectFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698