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 #include "GrGLProgramBuilder.h" | 8 #include "GrGLProgramBuilder.h" |
9 #include "gl/GrGLProgram.h" | 9 #include "gl/GrGLProgram.h" |
10 #include "gl/GrGLSLPrettyPrint.h" | 10 #include "gl/GrGLSLPrettyPrint.h" |
11 #include "gl/GrGLUniformHandle.h" | 11 #include "gl/GrGLUniformHandle.h" |
12 #include "../GrGpuGL.h" | 12 #include "../GrGpuGL.h" |
13 #include "GrCoordTransform.h" | 13 #include "GrCoordTransform.h" |
14 #include "GrGLLegacyNvprProgramBuilder.h" | 14 #include "GrGLLegacyNvprProgramBuilder.h" |
15 #include "GrGLNvprProgramBuilder.h" | 15 #include "GrGLNvprProgramBuilder.h" |
16 #include "GrGLProgramBuilder.h" | 16 #include "GrGLProgramBuilder.h" |
17 #include "GrTexture.h" | 17 #include "GrTexture.h" |
18 #include "SkRTConf.h" | 18 #include "SkRTConf.h" |
19 #include "SkTraceEvent.h" | 19 #include "SkTraceEvent.h" |
20 | 20 |
21 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 21 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
22 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | 22 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
23 | 23 |
24 // ES2 FS only guarantees mediump and lowp support | |
25 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar:
:kMedium_Precision; | |
26 | |
27 ////////////////////////////////////////////////////////////////////////////// | 24 ////////////////////////////////////////////////////////////////////////////// |
28 | 25 |
29 const int GrGLProgramBuilder::kVarsPerBlock = 8; | 26 const int GrGLProgramBuilder::kVarsPerBlock = 8; |
30 | 27 |
31 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, | 28 GrGLProgram* GrGLProgramBuilder::CreateProgram(const GrOptDrawState& optState, |
32 GrGpu::DrawType drawType, | 29 GrGpu::DrawType drawType, |
33 GrGpuGL* gpu) { | 30 GrGpuGL* gpu) { |
34 // create a builder. This will be handed off to effects so they can use it
to add | 31 // create a builder. This will be handed off to effects so they can use it
to add |
35 // uniforms, varyings, textures, etc | 32 // uniforms, varyings, textures, etc |
36 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, | 33 SkAutoTDelete<GrGLProgramBuilder> builder(CreateProgramBuilder(optState, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 169 } |
173 this->nameVariable(uni.fVariable.accessName(), prefix, name); | 170 this->nameVariable(uni.fVariable.accessName(), prefix, name); |
174 uni.fVariable.setArrayCount(count); | 171 uni.fVariable.setArrayCount(count); |
175 uni.fVisibility = visibility; | 172 uni.fVisibility = visibility; |
176 | 173 |
177 // If it is visible in both the VS and FS, the precision must match. | 174 // If it is visible in both the VS and FS, the precision must match. |
178 // We declare a default FS precision, but not a default VS. So set the var | 175 // We declare a default FS precision, but not a default VS. So set the var |
179 // to use the default FS precision. | 176 // to use the default FS precision. |
180 if ((kVertex_Visibility | kFragment_Visibility) == visibility) { | 177 if ((kVertex_Visibility | kFragment_Visibility) == visibility) { |
181 // the fragment and vertex precisions must match | 178 // the fragment and vertex precisions must match |
182 uni.fVariable.setPrecision(kDefaultFragmentPrecision); | 179 uni.fVariable.setPrecision(GrShaderVar::kDefault_Precision); |
183 } | 180 } |
184 | 181 |
185 if (outName) { | 182 if (outName) { |
186 *outName = uni.fVariable.c_str(); | 183 *outName = uni.fVariable.c_str(); |
187 } | 184 } |
188 return GrGLProgramDataManager::UniformHandle::CreateFromUniformIndex(fUnifor
ms.count() - 1); | 185 return GrGLProgramDataManager::UniformHandle::CreateFromUniformIndex(fUnifor
ms.count() - 1); |
189 } | 186 } |
190 | 187 |
191 void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility, | 188 void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility, |
192 SkString* out) const { | 189 SkString* out) const { |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 551 } |
555 | 552 |
556 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 553 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
557 | 554 |
558 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 555 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
559 int numProcs = fProcs.count(); | 556 int numProcs = fProcs.count(); |
560 for (int e = 0; e < numProcs; ++e) { | 557 for (int e = 0; e < numProcs; ++e) { |
561 SkDELETE(fProcs[e]); | 558 SkDELETE(fProcs[e]); |
562 } | 559 } |
563 } | 560 } |
OLD | NEW |