| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |