| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 8 |
| 9 #ifndef GrGLProgram_DEFINED | 9 #ifndef GrGLProgram_DEFINED |
| 10 #define GrGLProgram_DEFINED | 10 #define GrGLProgram_DEFINED |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * This function uploads uniforms and calls each GrGLProcessor's setData. It
is called before a | 93 * This function uploads uniforms and calls each GrGLProcessor's setData. It
is called before a |
| 94 * draw occurs using the program after the program has already been bound. I
t also uses the | 94 * draw occurs using the program after the program has already been bound. I
t also uses the |
| 95 * GrGLGpu object to bind the textures required by the GrGLProcessors. The c
olor and coverage | 95 * GrGLGpu object to bind the textures required by the GrGLProcessors. The c
olor and coverage |
| 96 * stages come from GrGLProgramDesc::Build(). | 96 * stages come from GrGLProgramDesc::Build(). |
| 97 */ | 97 */ |
| 98 void setData(const GrOptDrawState&); | 98 void setData(const GrPrimitiveProcessor&, const GrOptDrawState&, const GrBat
chTracker&); |
| 99 | 99 |
| 100 protected: | 100 protected: |
| 101 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 101 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
| 102 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; | 102 typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray; |
| 103 | 103 |
| 104 GrGLProgram(GrGLGpu*, | 104 GrGLProgram(GrGLGpu*, |
| 105 const GrProgramDesc&, | 105 const GrProgramDesc&, |
| 106 const BuiltinUniformHandles&, | 106 const BuiltinUniformHandles&, |
| 107 GrGLuint programID, | 107 GrGLuint programID, |
| 108 const UniformInfoArray&, | 108 const UniformInfoArray&, |
| 109 GrGLInstalledGeoProc* geometryProcessor, | 109 GrGLInstalledGeoProc* geometryProcessor, |
| 110 GrGLInstalledXferProc* xferProcessor, | 110 GrGLInstalledXferProc* xferProcessor, |
| 111 GrGLInstalledFragProcs* fragmentProcessors); | 111 GrGLInstalledFragProcs* fragmentProcessors); |
| 112 | 112 |
| 113 // Sets the texture units for samplers. | 113 // Sets the texture units for samplers. |
| 114 void initSamplerUniforms(); | 114 void initSamplerUniforms(); |
| 115 template <class Proc> | 115 template <class Proc> |
| 116 void initSamplers(Proc*, int* texUnitIdx); | 116 void initSamplers(Proc*, int* texUnitIdx); |
| 117 | 117 |
| 118 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures | 118 // A templated helper to loop over effects, set the transforms(via subclass)
and bind textures |
| 119 void setFragmentData(const GrOptDrawState&); | 119 void setFragmentData(const GrPrimitiveProcessor&, const GrOptDrawState&); |
| 120 virtual void setTransformData(const GrPrimitiveProcessor*, | 120 virtual void setTransformData(const GrPrimitiveProcessor&, |
| 121 const GrPendingFragmentStage&, | 121 const GrPendingFragmentStage&, |
| 122 int index, | 122 int index, |
| 123 GrGLInstalledFragProc*); | 123 GrGLInstalledFragProc*); |
| 124 template <class Proc> | 124 template <class Proc> |
| 125 void bindTextures(const Proc*, const GrProcessor&); | 125 void bindTextures(const Proc*, const GrProcessor&); |
| 126 | 126 |
| 127 /* | 127 /* |
| 128 * Legacy NVPR needs a hook here to flush path tex gen settings. | 128 * Legacy NVPR needs a hook here to flush path tex gen settings. |
| 129 * TODO when legacy nvpr is removed, remove this call. | 129 * TODO when legacy nvpr is removed, remove this call. |
| 130 */ | 130 */ |
| 131 virtual void didSetData(GrGpu::DrawType); | 131 virtual void didSetData(GrGpu::DrawType); |
| 132 | 132 |
| 133 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform | 133 // Helper for setData() that sets the view matrix and loads the render targe
t height uniform |
| 134 void setRenderTargetState(const GrOptDrawState&); | 134 void setRenderTargetState(const GrPrimitiveProcessor&, const GrOptDrawState&
); |
| 135 virtual void onSetRenderTargetState(const GrOptDrawState&); | 135 virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrOpt
DrawState&); |
| 136 | 136 |
| 137 // these reflect the current values of uniforms (GL uniform values travel wi
th program) | 137 // these reflect the current values of uniforms (GL uniform values travel wi
th program) |
| 138 RenderTargetState fRenderTargetState; | 138 RenderTargetState fRenderTargetState; |
| 139 GrColor fColor; | 139 GrColor fColor; |
| 140 uint8_t fCoverage; | 140 uint8_t fCoverage; |
| 141 int fDstCopyTexUnit; | 141 int fDstCopyTexUnit; |
| 142 BuiltinUniformHandles fBuiltinUniformHandles; | 142 BuiltinUniformHandles fBuiltinUniformHandles; |
| 143 GrGLuint fProgramID; | 143 GrGLuint fProgramID; |
| 144 | 144 |
| 145 // the installed effects | 145 // the installed effects |
| (...skipping 23 matching lines...) Expand all Loading... |
| 169 const GrProgramDesc&, | 169 const GrProgramDesc&, |
| 170 const BuiltinUniformHandles&, | 170 const BuiltinUniformHandles&, |
| 171 GrGLuint programID, | 171 GrGLuint programID, |
| 172 const UniformInfoArray&, | 172 const UniformInfoArray&, |
| 173 GrGLInstalledGeoProc*, | 173 GrGLInstalledGeoProc*, |
| 174 GrGLInstalledXferProc* xferProcessor, | 174 GrGLInstalledXferProc* xferProcessor, |
| 175 GrGLInstalledFragProcs* fragmentProcessors); | 175 GrGLInstalledFragProcs* fragmentProcessors); |
| 176 | 176 |
| 177 private: | 177 private: |
| 178 void didSetData(GrGpu::DrawType) SK_OVERRIDE; | 178 void didSetData(GrGpu::DrawType) SK_OVERRIDE; |
| 179 virtual void setTransformData(const GrPrimitiveProcessor*, | 179 virtual void setTransformData(const GrPrimitiveProcessor&, |
| 180 const GrPendingFragmentStage&, | 180 const GrPendingFragmentStage&, |
| 181 int index, | 181 int index, |
| 182 GrGLInstalledFragProc*) SK_OVERRIDE; | 182 GrGLInstalledFragProc*) SK_OVERRIDE; |
| 183 virtual void onSetRenderTargetState(const GrOptDrawState&); | 183 virtual void onSetRenderTargetState(const GrPrimitiveProcessor&, const GrOpt
DrawState&); |
| 184 | 184 |
| 185 friend class GrGLNvprProgramBuilder; | 185 friend class GrGLNvprProgramBuilder; |
| 186 | 186 |
| 187 typedef GrGLProgram INHERITED; | 187 typedef GrGLProgram INHERITED; |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 #endif | 190 #endif |
| OLD | NEW |