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 const GrGLProgramDesc& getDesc() { return fDesc; } | 55 const GrGLProgramDesc& getDesc() { return fDesc; } |
56 | 56 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 destVec[2] = -2.f / fRenderTargetSize.fHeight; | 140 destVec[2] = -2.f / fRenderTargetSize.fHeight; |
141 destVec[3] = 1.f; | 141 destVec[3] = 1.f; |
142 } else { | 142 } else { |
143 destVec[2] = 2.f / fRenderTargetSize.fHeight; | 143 destVec[2] = 2.f / fRenderTargetSize.fHeight; |
144 destVec[3] = -1.f; | 144 destVec[3] = -1.f; |
145 } | 145 } |
146 } | 146 } |
147 }; | 147 }; |
148 | 148 |
149 /** | 149 /** |
150 * This function uploads uniforms and calls each GrGLEffect's setData. It is
called before a | 150 * This function uploads uniforms and calls each GrGLProcessor's setData. It
is called before a |
151 * draw occurs using the program after the program has already been bound. I
t also uses the | 151 * draw occurs using the program after the program has already been bound. I
t also uses the |
152 * GrGpuGL object to bind the textures required by the GrGLEffects. The colo
r and coverage | 152 * GrGpuGL object to bind the textures required by the GrGLProcessors. The c
olor and coverage |
153 * stages come from GrGLProgramDesc::Build(). | 153 * stages come from GrGLProgramDesc::Build(). |
154 */ | 154 */ |
155 void setData(const GrOptDrawState&, | 155 void setData(const GrOptDrawState&, |
156 GrGpu::DrawType, | 156 GrGpu::DrawType, |
157 const GrEffectStage* geometryProcessor, | 157 const GrGeometryStage* geometryProcessor, |
158 const GrEffectStage* colorStages[], | 158 const GrFragmentStage* colorStages[], |
159 const GrEffectStage* coverageStages[], | 159 const GrFragmentStage* coverageStages[], |
160 const GrDeviceCoordTexture* dstCopy, // can be NULL | 160 const GrDeviceCoordTexture* dstCopy, // can be NULL |
161 SharedGLState*); | 161 SharedGLState*); |
162 | 162 |
163 private: | 163 private: |
164 typedef GrGLProgramDataManager::UniformHandle UniformHandle; | 164 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
165 | 165 |
166 GrGLProgram(GrGpuGL*, | 166 GrGLProgram(GrGpuGL*, |
167 const GrGLProgramDesc&, | 167 const GrGLProgramDesc&, |
168 const GrGLProgramBuilder&); | 168 const GrGLProgramBuilder&); |
169 | 169 |
(...skipping 27 matching lines...) Expand all Loading... |
197 | 197 |
198 GrGLProgramDesc fDesc; | 198 GrGLProgramDesc fDesc; |
199 GrGpuGL* fGpu; | 199 GrGpuGL* fGpu; |
200 | 200 |
201 GrGLProgramDataManager fProgramDataManager; | 201 GrGLProgramDataManager fProgramDataManager; |
202 | 202 |
203 typedef SkRefCnt INHERITED; | 203 typedef SkRefCnt INHERITED; |
204 }; | 204 }; |
205 | 205 |
206 #endif | 206 #endif |
OLD | NEW |