| 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 GrGLProcessor_DEFINED | 8 #ifndef GrGLProcessor_DEFINED |
| 9 #define GrGLProcessor_DEFINED | 9 #define GrGLProcessor_DEFINED |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 UniformHandle fSamplerUniform; | 58 UniformHandle fSamplerUniform; |
| 59 uint32_t fConfigComponentMask; | 59 uint32_t fConfigComponentMask; |
| 60 char fSwizzle[5]; | 60 char fSwizzle[5]; |
| 61 | 61 |
| 62 friend class GrGLShaderBuilder; | 62 friend class GrGLShaderBuilder; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 typedef SkTArray<TextureSampler> TextureSamplerArray; | 65 typedef SkTArray<TextureSampler> TextureSamplerArray; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class GrGLFPBuilder; | |
| 69 | |
| 70 class GrGLFragmentProcessor { | |
| 71 public: | |
| 72 GrGLFragmentProcessor() {} | |
| 73 | |
| 74 virtual ~GrGLFragmentProcessor() {} | |
| 75 | |
| 76 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | |
| 77 typedef GrGLProcessor::TransformedCoordsArray TransformedCoordsArray; | |
| 78 typedef GrGLProcessor::TextureSamplerArray TextureSamplerArray; | |
| 79 | |
| 80 /** Called when the program stage should insert its code into the shaders. T
he code in each | |
| 81 shader will be in its own block ({}) and so locally scoped names will no
t collide across | |
| 82 stages. | |
| 83 | |
| 84 @param builder Interface used to emit code in the shaders. | |
| 85 @param processor The processor that generated this program stage. | |
| 86 @param key The key that was computed by GenKey() from the gener
ating GrProcessor. | |
| 87 @param outputColor A predefined vec4 in the FS in which the stage shoul
d place its output | |
| 88 color (or coverage). | |
| 89 @param inputColor A vec4 that holds the input color to the stage in th
e FS. This may be | |
| 90 NULL in which case the implied input is solid white
(all ones). | |
| 91 TODO: Better system for communicating optimization i
nfo (e.g. input | |
| 92 color is solid white, trans black, known to be opaqu
e, etc.) that allows | |
| 93 the processor to communicate back similar known info
about its output. | |
| 94 @param samplers Contains one entry for each GrTextureAccess of the G
rProcessor. These | |
| 95 can be passed to the builder to emit texture reads i
n the generated | |
| 96 code. | |
| 97 TODO this should take a struct | |
| 98 */ | |
| 99 virtual void emitCode(GrGLFPBuilder* builder, | |
| 100 const GrFragmentProcessor&, | |
| 101 const char* outputColor, | |
| 102 const char* inputColor, | |
| 103 const TransformedCoordsArray& coords, | |
| 104 const TextureSamplerArray& samplers) = 0; | |
| 105 | |
| 106 /** A GrGLFragmentProcessor instance can be reused with any GrFragmentProces
sor that produces | |
| 107 the same stage key; this function reads data from a GrFragmentProcessor
and uploads any | |
| 108 uniform variables required by the shaders created in emitCode(). The GrF
ragmentProcessor | |
| 109 parameter is guaranteed to be of the same type that created this GrGLFra
gmentProcessor and | |
| 110 to have an identical processor key as the one that created this GrGLFrag
mentProcessor. */ | |
| 111 // TODO update this to pass in GrFragmentProcessor | |
| 112 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) {} | |
| 113 | |
| 114 static void GenKey(const GrProcessor&, const GrGLSLCaps&, GrProcessorKeyBuil
der*) {} | |
| 115 | |
| 116 private: | |
| 117 typedef GrGLProcessor INHERITED; | |
| 118 }; | |
| 119 | |
| 120 #endif | 68 #endif |
| OLD | NEW |