| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 GrFragmentProcessor_DEFINED | 8 #ifndef GrFragmentProcessor_DEFINED |
| 9 #define GrFragmentProcessor_DEFINED | 9 #define GrFragmentProcessor_DEFINED |
| 10 | 10 |
| 11 #include "GrProcessor.h" | 11 #include "GrProcessor.h" |
| 12 #include "GrStagedProcessor.h" | 12 #include "GrStagedProcessor.h" |
| 13 | 13 |
| 14 class GrCoordTransform; | 14 class GrCoordTransform; |
| 15 class GrGLSLCaps; | 15 class GrGLSLCaps; |
| 16 class GrGLFragmentProcessor; | 16 class GrGLFragmentProcessor; |
| 17 class GrProcessorKeyBuilder; | 17 class GrProcessorKeyBuilder; |
| 18 | 18 |
| 19 /** Provides custom fragment shader code. Fragment processors receive an input c
olor (vec4f) and | 19 /** Provides custom fragment shader code. Fragment processors receive an input c
olor (vec4f) and |
| 20 produce an output color. They may reference textures and uniforms. They may
use | 20 produce an output color. They may reference textures and uniforms. They may
use |
| 21 GrCoordTransforms to receive a transformation of the local coordinates that
map from local space | 21 GrCoordTransforms to receive a transformation of the local coordinates that
map from local space |
| 22 to the fragment being processed. | 22 to the fragment being processed. |
| 23 */ | 23 */ |
| 24 class GrFragmentProcessor : public GrProcessor { | 24 class GrFragmentProcessor : public GrProcessor { |
| 25 public: | 25 public: |
| 26 GrFragmentProcessor() | 26 GrFragmentProcessor() |
| 27 : INHERITED() | 27 : INHERITED() |
| 28 , fUsesLocalCoords(false) {} | 28 , fUsesLocalCoords(false) {} |
| 29 | 29 |
| 30 /** Returns a new instance of the appropriate *GL* implementation class | 30 GrGLFragmentProcessor* createGLInstance() const; |
| 31 for the given GrFragmentProcessor; caller is responsible for deleting | |
| 32 the object. */ | |
| 33 virtual GrGLFragmentProcessor* createGLInstance() const = 0; | |
| 34 | 31 |
| 35 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb
edded | 32 /** Human-meaningful string to identify this GrFragmentProcessor; may be emb
edded |
| 36 in generated shader code. */ | 33 in generated shader code. */ |
| 37 virtual const char* name() const = 0; | 34 virtual const char* name() const = 0; |
| 38 | 35 |
| 39 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st { | 36 void getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) con
st { |
| 40 this->onGetGLProcessorKey(caps, b); | 37 this->onGetGLProcessorKey(caps, b); |
| 41 for (int i = 0; i < fChildProcessors.count(); ++i) { | 38 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 42 fChildProcessors[i].processor()->getGLProcessorKey(caps, b); | 39 fChildProcessors[i].processor()->getGLProcessorKey(caps, b); |
| 43 } | 40 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 115 |
| 119 /** | 116 /** |
| 120 * Subclass implements this to support getConstantColorComponents(...). | 117 * Subclass implements this to support getConstantColorComponents(...). |
| 121 * | 118 * |
| 122 * Note: it's up to the subclass implementation to do any recursive call to
compute the child | 119 * Note: it's up to the subclass implementation to do any recursive call to
compute the child |
| 123 * procs' output invariants; computeInvariantOutput will not be recursive. | 120 * procs' output invariants; computeInvariantOutput will not be recursive. |
| 124 */ | 121 */ |
| 125 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; | 122 virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; |
| 126 | 123 |
| 127 private: | 124 private: |
| 125 /** Returns a new instance of the appropriate *GL* implementation class |
| 126 for the given GrFragmentProcessor; caller is responsible for deleting |
| 127 the object. */ |
| 128 virtual GrGLFragmentProcessor* onCreateGLInstance() const = 0; |
| 129 |
| 128 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ | 130 /** Implemented using GLFragmentProcessor::GenKey as described in this class
's comment. */ |
| 129 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, | 131 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 130 GrProcessorKeyBuilder* b) const = 0; | 132 GrProcessorKeyBuilder* b) const = 0; |
| 131 | 133 |
| 132 /** | 134 /** |
| 133 * Subclass implements this to support isEqual(). It will only be called if
it is known that | 135 * Subclass implements this to support isEqual(). It will only be called if
it is known that |
| 134 * the two processors are of the same subclass (i.e. they return the same ob
ject from | 136 * the two processors are of the same subclass (i.e. they return the same ob
ject from |
| 135 * getFactory()). The processor subclass should not compare its coord transf
orms as that will | 137 * getFactory()). The processor subclass should not compare its coord transf
orms as that will |
| 136 * be performed automatically in the non-virtual isEqual(). | 138 * be performed automatically in the non-virtual isEqual(). |
| 137 */ | 139 */ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 165 * The same goes for fTextureAccesses with textures. | 167 * The same goes for fTextureAccesses with textures. |
| 166 */ | 168 */ |
| 167 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; | 169 SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms; |
| 168 | 170 |
| 169 SkTArray<GrFragmentStage, false> fChildProcessors; | 171 SkTArray<GrFragmentStage, false> fChildProcessors; |
| 170 | 172 |
| 171 typedef GrProcessor INHERITED; | 173 typedef GrProcessor INHERITED; |
| 172 }; | 174 }; |
| 173 | 175 |
| 174 #endif | 176 #endif |
| OLD | NEW |