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

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

Issue 654313002: Auto-compare GrProcessors' texture accesses in isEqual(). (Closed) Base URL: https://skia.googlesource.com/skia.git@xformcomp
Patch Set: update 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 | « include/gpu/GrGeometryProcessor.h ('k') | src/core/SkXfermode.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 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void operator delete(void* target, void* placement) { 193 void operator delete(void* target, void* placement) {
194 ::operator delete(target, placement); 194 ::operator delete(target, placement);
195 } 195 }
196 196
197 /** 197 /**
198 * Helper for down-casting to a GrProcessor subclass 198 * Helper for down-casting to a GrProcessor subclass
199 */ 199 */
200 template <typename T> const T& cast() const { return *static_cast<const T*>( this); } 200 template <typename T> const T& cast() const { return *static_cast<const T*>( this); }
201 201
202 protected: 202 protected:
203 GrProcessor() : fWillReadFragmentPosition(false) {}
204
203 /** 205 /**
204 * Subclasses call this from their constructor to register GrTextureAccesses . The processor 206 * Subclasses call this from their constructor to register GrTextureAccesses . The processor
205 * subclass manages the lifetime of the accesses (this function only stores a pointer). The 207 * subclass manages the lifetime of the accesses (this function only stores a pointer). The
206 * GrTextureAccess is typically a member field of the GrProcessor subclass. This must only be 208 * GrTextureAccess is typically a member field of the GrProcessor subclass. This must only be
207 * called from the constructor because GrProcessors are immutable. 209 * called from the constructor because GrProcessors are immutable.
208 */ 210 */
209 void addTextureAccess(const GrTextureAccess* textureAccess); 211 void addTextureAccess(const GrTextureAccess* textureAccess);
210 212
211 GrProcessor() 213 bool hasSameTextureAccesses(const GrProcessor&) const;
212 : fWillReadFragmentPosition(false) {}
213 214
214 /** 215 /**
215 * If the prcoessor will generate a backend-specific processor that will rea d the fragment 216 * If the prcoessor will generate a backend-specific processor that will rea d the fragment
216 * position in the FS then it must call this method from its constructor. Ot herwise, the 217 * position in the FS then it must call this method from its constructor. Ot herwise, the
217 * request to access the fragment position will be denied. 218 * request to access the fragment position will be denied.
218 */ 219 */
219 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } 220 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
220 221
221 SkDEBUGCODE(void assertTexturesEqual(const GrProcessor& other) const;)
222
223 private: 222 private:
224 223
225 /** 224 /**
226 * Subclass implements this to support getConstantColorComponents(...). 225 * Subclass implements this to support getConstantColorComponents(...).
227 */ 226 */
228 virtual void onComputeInvariantOutput(InvariantOutput* inout) const = 0; 227 virtual void onComputeInvariantOutput(InvariantOutput* inout) const = 0;
229 228
230 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; 229 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses;
231 bool fWillReadFragmentPosition; 230 bool fWillReadFragmentPosition;
232 231
233 typedef GrProgramElement INHERITED; 232 typedef GrProgramElement INHERITED;
234 }; 233 };
235 234
236 235
237 /** 236 /**
238 * This creates a processor outside of the memory pool. The processor's destruct or will be called 237 * This creates a processor outside of the memory pool. The processor's destruct or will be called
239 * at global destruction time. NAME will be the name of the created instance. 238 * at global destruction time. NAME will be the name of the created instance.
240 */ 239 */
241 #define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \ 240 #define GR_CREATE_STATIC_PROCESSOR(NAME, PROC_CLASS, ARGS) \
242 static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \ 241 static SkAlignedSStorage<sizeof(PROC_CLASS)> g_##NAME##_Storage; \
243 static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLAS S, ARGS); \ 242 static PROC_CLASS* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), PROC_CLAS S, ARGS); \
244 static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME); 243 static SkAutoTDestroy<GrProcessor> NAME##_ad(NAME);
245 244
246 #endif 245 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrGeometryProcessor.h ('k') | src/core/SkXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698