| 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 | 9 |
| 10 #include "GrAutoLocaleSetter.h" | 10 #include "GrAutoLocaleSetter.h" |
| 11 #include "GrCoordTransform.h" | 11 #include "GrCoordTransform.h" |
| 12 #include "GrGLProgramBuilder.h" | 12 #include "GrGLProgramBuilder.h" |
| 13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
| 14 #include "SkRTConf.h" | 14 #include "SkRTConf.h" |
| 15 #include "SkTraceEvent.h" | 15 #include "SkTraceEvent.h" |
| 16 #include "gl/GrGLGeometryProcessor.h" | 16 #include "gl/GrGLGeometryProcessor.h" |
| 17 #include "gl/GrGLGpu.h" | 17 #include "gl/GrGLGpu.h" |
| 18 #include "gl/GrGLProgram.h" | 18 #include "gl/GrGLProgram.h" |
| 19 #include "gl/GrGLSLPrettyPrint.h" | 19 #include "gl/GrGLSLPrettyPrint.h" |
| 20 #include "gl/GrGLXferProcessor.h" | 20 #include "gl/GrGLXferProcessor.h" |
| 21 #include "glsl/GrGLSLCaps.h" | 21 #include "glsl/GrGLSLCaps.h" |
| 22 #include "glsl/GrGLSLProgramDataManager.h" |
| 22 | 23 |
| 23 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 24 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
| 24 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
| 25 | 26 |
| 26 const int GrGLProgramBuilder::kVarsPerBlock = 8; | 27 const int GrGLProgramBuilder::kVarsPerBlock = 8; |
| 27 | 28 |
| 28 GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
u) { | 29 GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
u) { |
| 29 GrAutoLocaleSetter als("C"); | 30 GrAutoLocaleSetter als("C"); |
| 30 | 31 |
| 31 // create a builder. This will be handed off to effects so they can use it
to add | 32 // create a builder. This will be handed off to effects so they can use it
to add |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 112 } |
| 112 if (!fOutOfStage) { | 113 if (!fOutOfStage) { |
| 113 if (out->endsWith('_')) { | 114 if (out->endsWith('_')) { |
| 114 // Names containing "__" are reserved. | 115 // Names containing "__" are reserved. |
| 115 out->append("x"); | 116 out->append("x"); |
| 116 } | 117 } |
| 117 out->appendf("_Stage%d%s", fStageIndex, fFS.getMangleString().c_str()); | 118 out->appendf("_Stage%d%s", fStageIndex, fFS.getMangleString().c_str()); |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 121 GrGLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( | 122 GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::addUniformArray( |
| 122 uint32_t visibil
ity, | 123 uint32_t visibil
ity, |
| 123 GrSLType type, | 124 GrSLType type, |
| 124 GrSLPrecision pr
ecision, | 125 GrSLPrecision pr
ecision, |
| 125 const char* name
, | 126 const char* name
, |
| 126 int count, | 127 int count, |
| 127 const char** out
Name) { | 128 const char** out
Name) { |
| 128 SkASSERT(name && strlen(name)); | 129 SkASSERT(name && strlen(name)); |
| 129 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFr
agment_Visibility); | 130 SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFr
agment_Visibility); |
| 130 SkASSERT(0 == (~kVisibilityMask & visibility)); | 131 SkASSERT(0 == (~kVisibilityMask & visibility)); |
| 131 SkASSERT(0 != visibility); | 132 SkASSERT(0 != visibility); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 145 prefix = '\0'; | 146 prefix = '\0'; |
| 146 } | 147 } |
| 147 this->nameVariable(uni.fVariable.accessName(), prefix, name); | 148 this->nameVariable(uni.fVariable.accessName(), prefix, name); |
| 148 uni.fVariable.setArrayCount(count); | 149 uni.fVariable.setArrayCount(count); |
| 149 uni.fVisibility = visibility; | 150 uni.fVisibility = visibility; |
| 150 uni.fVariable.setPrecision(precision); | 151 uni.fVariable.setPrecision(precision); |
| 151 | 152 |
| 152 if (outName) { | 153 if (outName) { |
| 153 *outName = uni.fVariable.c_str(); | 154 *outName = uni.fVariable.c_str(); |
| 154 } | 155 } |
| 155 return GrGLProgramDataManager::UniformHandle(fUniforms.count() - 1); | 156 return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1); |
| 156 } | 157 } |
| 157 | 158 |
| 158 void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility, | 159 void GrGLProgramBuilder::appendUniformDecls(ShaderVisibility visibility, |
| 159 SkString* out) const { | 160 SkString* out) const { |
| 160 for (int i = 0; i < fUniforms.count(); ++i) { | 161 for (int i = 0; i < fUniforms.count(); ++i) { |
| 161 if (fUniforms[i].fVisibility & visibility) { | 162 if (fUniforms[i].fVisibility & visibility) { |
| 162 fUniforms[i].fVariable.appendDecl(this->glslCaps(), out); | 163 fUniforms[i].fVariable.appendDecl(this->glslCaps(), out); |
| 163 out->append(";\n"); | 164 out->append(";\n"); |
| 164 } | 165 } |
| 165 } | 166 } |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 519 } |
| 519 | 520 |
| 520 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 521 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 521 | 522 |
| 522 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 523 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 523 int numProcs = fProcs.count(); | 524 int numProcs = fProcs.count(); |
| 524 for (int i = 0; i < numProcs; ++i) { | 525 for (int i = 0; i < numProcs; ++i) { |
| 525 delete fProcs[i]; | 526 delete fProcs[i]; |
| 526 } | 527 } |
| 527 } | 528 } |
| OLD | NEW |