| 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/GrGLFragmentProcessor.h" | |
| 17 #include "gl/GrGLGeometryProcessor.h" | 16 #include "gl/GrGLGeometryProcessor.h" |
| 18 #include "gl/GrGLGpu.h" | 17 #include "gl/GrGLGpu.h" |
| 19 #include "gl/GrGLProgram.h" | 18 #include "gl/GrGLProgram.h" |
| 20 #include "gl/GrGLSLPrettyPrint.h" | 19 #include "gl/GrGLSLPrettyPrint.h" |
| 21 #include "gl/GrGLXferProcessor.h" | 20 #include "gl/GrGLXferProcessor.h" |
| 22 #include "gl/builders/GrGLShaderStringBuilder.h" | 21 #include "gl/builders/GrGLShaderStringBuilder.h" |
| 23 #include "glsl/GrGLSLCaps.h" | 22 #include "glsl/GrGLSLCaps.h" |
| 23 #include "glsl/GrGLSLFragmentProcessor.h" |
| 24 #include "glsl/GrGLSLProgramDataManager.h" | 24 #include "glsl/GrGLSLProgramDataManager.h" |
| 25 #include "glsl/GrGLSLTextureSampler.h" | 25 #include "glsl/GrGLSLTextureSampler.h" |
| 26 | 26 |
| 27 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | 27 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) |
| 28 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | 28 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) |
| 29 | 29 |
| 30 GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
u) { | 30 GrGLProgram* GrGLProgramBuilder::CreateProgram(const DrawArgs& args, GrGLGpu* gp
u) { |
| 31 GrAutoLocaleSetter als("C"); | 31 GrAutoLocaleSetter als("C"); |
| 32 | 32 |
| 33 // create a builder. This will be handed off to effects so they can use it
to add | 33 // create a builder. This will be handed off to effects so they can use it
to add |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 int index, | 252 int index, |
| 253 const char* outColor, | 253 const char* outColor, |
| 254 const char* inColor) { | 254 const char* inColor) { |
| 255 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; | 255 GrGLInstalledFragProc* ifp = new GrGLInstalledFragProc; |
| 256 | 256 |
| 257 ifp->fGLProc.reset(fp.createGLInstance()); | 257 ifp->fGLProc.reset(fp.createGLInstance()); |
| 258 | 258 |
| 259 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); | 259 SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures()); |
| 260 this->emitSamplers(fp, &samplers, ifp); | 260 this->emitSamplers(fp, &samplers, ifp); |
| 261 | 261 |
| 262 GrGLFragmentProcessor::EmitArgs args(this, fp, outColor, inColor, fOutCoords
[index], samplers); | 262 GrGLSLFragmentProcessor::EmitArgs args(this, |
| 263 fp, |
| 264 outColor, |
| 265 inColor, |
| 266 fOutCoords[index], |
| 267 samplers); |
| 263 ifp->fGLProc->emitCode(args); | 268 ifp->fGLProc->emitCode(args); |
| 264 | 269 |
| 265 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 270 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 266 // asks for dst color, then the emit code needs to follow suit | 271 // asks for dst color, then the emit code needs to follow suit |
| 267 verify(fp); | 272 verify(fp); |
| 268 fFragmentProcessors->fProcs.push_back(ifp); | 273 fFragmentProcessors->fProcs.push_back(ifp); |
| 269 } | 274 } |
| 270 | 275 |
| 271 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, | 276 void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp, |
| 272 const char* outColor, | 277 const char* outColor, |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 536 } |
| 532 | 537 |
| 533 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 538 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 534 | 539 |
| 535 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 540 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 536 int numProcs = fProcs.count(); | 541 int numProcs = fProcs.count(); |
| 537 for (int i = 0; i < numProcs; ++i) { | 542 for (int i = 0; i < numProcs; ++i) { |
| 538 delete fProcs[i]; | 543 delete fProcs[i]; |
| 539 } | 544 } |
| 540 } | 545 } |
| OLD | NEW |