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 | 12 |
13 class GrCoordTransform; | 13 class GrCoordTransform; |
14 class GrGLSLCaps; | 14 class GrGLSLCaps; |
15 class GrGLFragmentProcessor; | 15 class GrGLFragmentProcessor; |
16 class GrInvariantOutput; | 16 class GrInvariantOutput; |
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 /** |
| 27 * In many instances (e.g. SkShader::asFragmentProcessor() implementations)
it is desirable to |
| 28 * only consider the input color's alpha. However, there is a competing desi
re to have reusable |
| 29 * GrFragmentProcessor subclasses that can be used in other scenarios where
the entire input |
| 30 * color is considered. This function exists to filter the input color and p
ass it to a FP. It |
| 31 * does so by returning a parent FP that multiplies the passed in FPs output
by the parent's |
| 32 * input alpha. The passed in FP will not receive an input color. |
| 33 */ |
| 34 static const GrFragmentProcessor* MulOuputByInputAlpha(const GrFragmentProce
ssor*); |
| 35 |
26 GrFragmentProcessor() | 36 GrFragmentProcessor() |
27 : INHERITED() | 37 : INHERITED() |
28 , fUsesLocalCoords(false) | 38 , fUsesLocalCoords(false) |
29 , fNumTexturesExclChildren(0) | 39 , fNumTexturesExclChildren(0) |
30 , fNumTransformsExclChildren(0) {} | 40 , fNumTransformsExclChildren(0) {} |
31 | 41 |
32 ~GrFragmentProcessor() override; | 42 ~GrFragmentProcessor() override; |
33 | 43 |
34 GrGLFragmentProcessor* createGLInstance() const; | 44 GrGLFragmentProcessor* createGLInstance() const; |
35 | 45 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 int fNumTransformsExclChildren; | 191 int fNumTransformsExclChildren; |
182 | 192 |
183 // TODO: These must convert their processors to pending-execution refs when
the parent is | 193 // TODO: These must convert their processors to pending-execution refs when
the parent is |
184 // converted (do this automatically in GrProgramElement?). | 194 // converted (do this automatically in GrProgramElement?). |
185 SkTArray<const GrFragmentProcessor*, true> fChildProcessors; | 195 SkTArray<const GrFragmentProcessor*, true> fChildProcessors; |
186 | 196 |
187 typedef GrProcessor INHERITED; | 197 typedef GrProcessor INHERITED; |
188 }; | 198 }; |
189 | 199 |
190 #endif | 200 #endif |
OLD | NEW |