Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 */ | 33 */ |
| 34 class GrProcessor : public GrProgramElement { | 34 class GrProcessor : public GrProgramElement { |
| 35 public: | 35 public: |
| 36 SK_DECLARE_INST_COUNT(GrProcessor) | 36 SK_DECLARE_INST_COUNT(GrProcessor) |
| 37 | 37 |
| 38 virtual ~GrProcessor(); | 38 virtual ~GrProcessor(); |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * This function is used to perform optimizations. When called the color and validFlags params | 41 * This function is used to perform optimizations. When called the color and validFlags params |
| 42 * indicate whether the input components to this effect in the FS will have known values. | 42 * indicate whether the input components to this effect in the FS will have known values. |
| 43 * validFlags is a bitfield of GrColorComponentFlags. The function updates b oth params to | 43 * validFlags is a bitfield of GrColorComponentFlags. The isSingleComponent param indicates |
| 44 * indicate known values of its output. A component of the color param only has meaning if the | 44 * whether the input will be 1 or 4 bytes. The function updates all params t o indicate known |
| 45 * corresponding bit in validFlags is set. | 45 * values of its output. A component of the color param only has meaning if the corresponding |
| 46 * bit in validFlags is set. If an effect sets isSingleComponent to true, th en validFlags must | |
| 47 * be all 1's or all 0's. If it is all 1's then all color components must be equal. | |
|
bsalomon
2014/09/29 15:28:04
all 1's isn't quit right (since this is a uint32_t
egdaniel
2014/09/29 15:50:20
Done.
| |
| 46 */ | 48 */ |
| 47 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags ) const = 0; | 49 void getConstantColorComponents(GrColor* color, uint32_t* validFlags, |
| 50 bool* isSingleComponent) const { | |
| 51 this->onGetConstantColorComponents(color, validFlags, isSingleComponent) ; | |
| 52 #ifdef SK_DEBUG | |
| 53 this->validateComponents(*color, *validFlags, *isSingleComponent); | |
| 54 #endif | |
| 55 } | |
| 48 | 56 |
| 49 /** This object, besides creating back-end-specific helper objects, is used for run-time-type- | 57 /** This object, besides creating back-end-specific helper objects, is used for run-time-type- |
| 50 identification. The factory should be an instance of templated class, | 58 identification. The factory should be an instance of templated class, |
| 51 GrTBackendEffectFactory. It is templated on the subclass of GrProcessor. The subclass must | 59 GrTBackendEffectFactory. It is templated on the subclass of GrProcessor. The subclass must |
| 52 have a nested type (or typedef) named GLProcessor which will be the subc lass of | 60 have a nested type (or typedef) named GLProcessor which will be the subc lass of |
| 53 GrGLProcessor created by the factory. | 61 GrGLProcessor created by the factory. |
| 54 | 62 |
| 55 Example: | 63 Example: |
| 56 class MyCustomEffect : public GrProcessor { | 64 class MyCustomEffect : public GrProcessor { |
| 57 ... | 65 ... |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 /** | 154 /** |
| 147 * If the effect will generate a backend-specific effect that will read the fragment position | 155 * If the effect will generate a backend-specific effect that will read the fragment position |
| 148 * in the FS then it must call this method from its constructor. Otherwise, the request to | 156 * in the FS then it must call this method from its constructor. Otherwise, the request to |
| 149 * access the fragment position will be denied. | 157 * access the fragment position will be denied. |
| 150 */ | 158 */ |
| 151 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } | 159 void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; } |
| 152 | 160 |
| 153 private: | 161 private: |
| 154 SkDEBUGCODE(void assertEquality(const GrProcessor& other) const;) | 162 SkDEBUGCODE(void assertEquality(const GrProcessor& other) const;) |
| 155 | 163 |
| 164 SkDEBUGCODE(void validateComponents(GrColor color, uint32_t validFlags, | |
| 165 bool isSingleComponent) const;) | |
| 166 | |
| 156 /** Subclass implements this to support isEqual(). It will only be called if it is known that | 167 /** Subclass implements this to support isEqual(). It will only be called if it is known that |
| 157 the two effects are of the same subclass (i.e. they return the same obje ct from | 168 the two effects are of the same subclass (i.e. they return the same obje ct from |
| 158 getFactory()).*/ | 169 getFactory()).*/ |
| 159 virtual bool onIsEqual(const GrProcessor& other) const = 0; | 170 virtual bool onIsEqual(const GrProcessor& other) const = 0; |
| 160 | 171 |
| 172 /** | |
| 173 * Subclass implements this to support getConstantColorComponents(...). | |
| 174 */ | |
| 175 virtual void onGetConstantColorComponents(GrColor* color, uint32_t* validFla gs, | |
| 176 bool* isSingleComponent) const = 0 ; | |
| 161 friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes. | 177 friend class GrGeometryProcessor; // to set fRequiresVertexShader and build fVertexAttribTypes. |
| 162 | 178 |
| 163 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 179 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
| 164 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; | 180 SkSTArray<4, const GrTextureAccess*, true> fTextureAccesses; |
| 165 bool fWillReadFragmentPosition; | 181 bool fWillReadFragmentPosition; |
| 166 | 182 |
| 167 typedef GrProgramElement INHERITED; | 183 typedef GrProgramElement INHERITED; |
| 168 }; | 184 }; |
| 169 | 185 |
| 170 class GrFragmentProcessor : public GrProcessor { | 186 class GrFragmentProcessor : public GrProcessor { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called | 224 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called |
| 209 * at global destruction time. NAME will be the name of the created GrProcessor. | 225 * at global destruction time. NAME will be the name of the created GrProcessor. |
| 210 */ | 226 */ |
| 211 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \ | 227 #define GR_CREATE_STATIC_FRAGMENT_PROCESSOR(NAME, EFFECT_CLASS, ARGS) \ |
| 212 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ | 228 static SkAlignedSStorage<sizeof(EFFECT_CLASS)> g_##NAME##_Storage; \ |
| 213 static GrFragmentProcessor* \ | 229 static GrFragmentProcessor* \ |
| 214 NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \ | 230 NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), EFFECT_CLASS, ARGS); \ |
| 215 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME); | 231 static SkAutoTDestroy<GrFragmentProcessor> NAME##_ad(NAME); |
| 216 | 232 |
| 217 #endif | 233 #endif |
| OLD | NEW |