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 |
11 | 11 |
12 #include "builders/GrGLProgramBuilder.h" | 12 #include "builders/GrGLProgramBuilder.h" |
13 #include "GrDrawState.h" | 13 #include "GrDrawState.h" |
14 #include "GrGLContext.h" | 14 #include "GrGLContext.h" |
15 #include "GrGLProgramDesc.h" | 15 #include "GrGLProgramDesc.h" |
16 #include "GrGLSL.h" | 16 #include "GrGLSL.h" |
17 #include "GrGLTexture.h" | 17 #include "GrGLTexture.h" |
18 #include "GrGLProgramDataManager.h" | 18 #include "GrGLProgramDataManager.h" |
19 | 19 |
20 #include "SkString.h" | 20 #include "SkString.h" |
21 #include "SkXfermode.h" | 21 #include "SkXfermode.h" |
22 | 22 |
23 class GrGLEffect; | 23 class GrGLProcessor; |
24 class GrGLProgramEffects; | 24 class GrGLProgramEffects; |
25 class GrGLProgramBuilder; | 25 class GrGLProgramBuilder; |
26 | 26 |
27 /** | 27 /** |
28 * This class manages a GPU program and records per-program information. | 28 * This class manages a GPU program and records per-program information. |
29 * We can specify the attribute locations so that they are constant | 29 * We can specify the attribute locations so that they are constant |
30 * across our shaders. But the driver determines the uniform locations | 30 * across our shaders. But the driver determines the uniform locations |
31 * at link time. We don't need to remember the sampler uniform location | 31 * at link time. We don't need to remember the sampler uniform location |
32 * because we will bind a texture slot to it and never change it | 32 * because we will bind a texture slot to it and never change it |
33 * Uniforms are program-local so we can't rely on fHWState to hold the | 33 * Uniforms are program-local so we can't rely on fHWState to hold the |
34 * previous uniform state after a program change. | 34 * previous uniform state after a program change. |
35 */ | 35 */ |
36 class GrGLProgram : public SkRefCnt { | 36 class GrGLProgram : public SkRefCnt { |
37 public: | 37 public: |
38 SK_DECLARE_INST_COUNT(GrGLProgram) | 38 SK_DECLARE_INST_COUNT(GrGLProgram) |
39 | 39 |
40 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; | 40 typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles; |
41 | 41 |
42 static GrGLProgram* Create(GrGpuGL* gpu, | 42 static GrGLProgram* Create(GrGpuGL* gpu, |
43 const GrGLProgramDesc& desc, | 43 const GrGLProgramDesc& desc, |
44 const GrEffectStage* geometryProcessor, | 44 const GrGeometryStage* geometryProcessor, |
45 const GrEffectStage* colorStages[], | 45 const GrFragmentStage* colorStages[], |
46 const GrEffectStage* coverageStages[]); | 46 const GrFragmentStage* coverageStages[]); |
47 | 47 |
48 virtual ~GrGLProgram(); | 48 virtual ~GrGLProgram(); |
49 | 49 |
50 /** | 50 /** |
51 * Call to abandon GL objects owned by this program. | 51 * Call to abandon GL objects owned by this program. |
52 */ | 52 */ |
53 void abandon(); | 53 void abandon(); |
54 | 54 |
55 /** | 55 /** |
56 * The shader may modify the blend coefficients. Params are in/out. | 56 * The shader may modify the blend coefficients. Params are in/out. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 destVec[2] = -2.f / fRenderTargetSize.fHeight; | 145 destVec[2] = -2.f / fRenderTargetSize.fHeight; |
146 destVec[3] = 1.f; | 146 destVec[3] = 1.f; |
147 } else { | 147 } else { |
148 destVec[2] = 2.f / fRenderTargetSize.fHeight; | 148 destVec[2] = 2.f / fRenderTargetSize.fHeight; |
149 destVec[3] = -1.f; | 149 destVec[3] = -1.f; |
150 } | 150 } |
151 } | 151 } |
152 }; | 152 }; |
153 | 153 |
154 /** | 154 /** |
155 * This function uploads uniforms and calls each GrGLEffect's setData. It is
called before a | 155 * This function uploads uniforms and calls each GrGLProcessor's setData. It
is called before a |
156 * draw occurs using the program after the program has already been bound. I
t also uses the | 156 * draw occurs using the program after the program has already been bound. I
t also uses the |
157 * GrGpuGL object to bind the textures required by the GrGLEffects. The colo
r and coverage | 157 * GrGpuGL object to bind the textures required by the GrGLProcessors. The c
olor and coverage |
158 * stages come from GrGLProgramDesc::Build(). | 158 * stages come from GrGLProgramDesc::Build(). |
159 */ | 159 */ |
160 void setData(const GrOptDrawState&, | 160 void setData(const GrOptDrawState&, |
161 GrGpu::DrawType, | 161 GrGpu::DrawType, |
162 const GrEffectStage* geometryProcessor, | 162 const GrGeometryStage* geometryProcessor, |
163 const GrEffectStage* colorStages[], | 163 const GrFragmentStage* colorStages[], |
164 const GrEffectStage* coverageStages[], | 164 const GrFragmentStage* coverageStages[], |
165 const GrDeviceCoordTexture* dstCopy, // can be NULL | 165 const GrDeviceCoordTexture* dstCopy, // can be NULL |
166 SharedGLState*); | 166 SharedGLState*); |
167 | 167 |
168 private: | 168 private: |
169 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 169 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
170 | 170 |
171 GrGLProgram(GrGpuGL*, | 171 GrGLProgram(GrGpuGL*, |
172 const GrGLProgramDesc&, | 172 const GrGLProgramDesc&, |
173 const GrGLProgramBuilder&); | 173 const GrGLProgramBuilder&); |
174 | 174 |
(...skipping 27 matching lines...) Expand all Loading... |
202 | 202 |
203 GrGLProgramDesc fDesc; | 203 GrGLProgramDesc fDesc; |
204 GrGpuGL* fGpu; | 204 GrGpuGL* fGpu; |
205 | 205 |
206 GrGLProgramDataManager fProgramDataManager; | 206 GrGLProgramDataManager fProgramDataManager; |
207 | 207 |
208 typedef SkRefCnt INHERITED; | 208 typedef SkRefCnt INHERITED; |
209 }; | 209 }; |
210 | 210 |
211 #endif | 211 #endif |
OLD | NEW |