| 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" | |
| 17 #include "gl/GrGLGpu.h" | 16 #include "gl/GrGLGpu.h" |
| 18 #include "gl/GrGLProgram.h" | 17 #include "gl/GrGLProgram.h" |
| 19 #include "gl/GrGLSLPrettyPrint.h" | 18 #include "gl/GrGLSLPrettyPrint.h" |
| 20 #include "gl/builders/GrGLShaderStringBuilder.h" | 19 #include "gl/builders/GrGLShaderStringBuilder.h" |
| 21 #include "glsl/GrGLSLCaps.h" | 20 #include "glsl/GrGLSLCaps.h" |
| 22 #include "glsl/GrGLSLFragmentProcessor.h" | 21 #include "glsl/GrGLSLFragmentProcessor.h" |
| 22 #include "glsl/GrGLSLGeometryProcessor.h" |
| 23 #include "glsl/GrGLSLProgramDataManager.h" | 23 #include "glsl/GrGLSLProgramDataManager.h" |
| 24 #include "glsl/GrGLSLTextureSampler.h" | 24 #include "glsl/GrGLSLTextureSampler.h" |
| 25 #include "glsl/GrGLSLXferProcessor.h" | 25 #include "glsl/GrGLSLXferProcessor.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 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const { | 150 const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const { |
| 151 return this->fGpu->ctxInfo().caps()->glslCaps(); | 151 return this->fGpu->ctxInfo().caps()->glslCaps(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
4* inputCoverage) { | 154 bool GrGLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor, GrGLSLExpr
4* inputCoverage) { |
| 155 // First we loop over all of the installed processors and collect coord tran
sforms. These will | 155 // First we loop over all of the installed processors and collect coord tran
sforms. These will |
| 156 // be sent to the GrGLPrimitiveProcessor in its emitCode function | 156 // be sent to the GrGLSLPrimitiveProcessor in its emitCode function |
| 157 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); | 157 const GrPrimitiveProcessor& primProc = this->primitiveProcessor(); |
| 158 int totalTextures = primProc.numTextures(); | 158 int totalTextures = primProc.numTextures(); |
| 159 const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits(); | 159 const int maxTextureUnits = fGpu->glCaps().maxFragmentTextureUnits(); |
| 160 | 160 |
| 161 for (int i = 0; i < this->pipeline().numFragmentProcessors(); i++) { | 161 for (int i = 0; i < this->pipeline().numFragmentProcessors(); i++) { |
| 162 const GrFragmentProcessor& processor = this->pipeline().getFragmentProce
ssor(i); | 162 const GrFragmentProcessor& processor = this->pipeline().getFragmentProce
ssor(i); |
| 163 | 163 |
| 164 if (!primProc.hasTransformedLocalCoords()) { | 164 if (!primProc.hasTransformedLocalCoords()) { |
| 165 SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransfor
ms.push_back(); | 165 SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransfor
ms.push_back(); |
| 166 processor.gatherCoordTransforms(&procCoords); | 166 processor.gatherCoordTransforms(&procCoords); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 const char* outColor, | 277 const char* outColor, |
| 278 const char* outCoverage) { | 278 const char* outCoverage) { |
| 279 SkASSERT(!fGeometryProcessor); | 279 SkASSERT(!fGeometryProcessor); |
| 280 fGeometryProcessor = new GrGLInstalledGeoProc; | 280 fGeometryProcessor = new GrGLInstalledGeoProc; |
| 281 | 281 |
| 282 fGeometryProcessor->fGLProc.reset(gp.createGLInstance(*fGpu->glCaps().glslCa
ps())); | 282 fGeometryProcessor->fGLProc.reset(gp.createGLInstance(*fGpu->glCaps().glslCa
ps())); |
| 283 | 283 |
| 284 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); | 284 SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures()); |
| 285 this->emitSamplers(gp, &samplers, fGeometryProcessor); | 285 this->emitSamplers(gp, &samplers, fGeometryProcessor); |
| 286 | 286 |
| 287 GrGLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, sample
rs, | 287 GrGLSLGeometryProcessor::EmitArgs args(this, gp, outColor, outCoverage, samp
lers, |
| 288 fCoordTransforms, &fOutCoords); | 288 fCoordTransforms, &fOutCoords); |
| 289 fGeometryProcessor->fGLProc->emitCode(args); | 289 fGeometryProcessor->fGLProc->emitCode(args); |
| 290 | 290 |
| 291 // We have to check that effects and the code they emit are consistent, ie i
f an effect | 291 // We have to check that effects and the code they emit are consistent, ie i
f an effect |
| 292 // asks for dst color, then the emit code needs to follow suit | 292 // asks for dst color, then the emit code needs to follow suit |
| 293 verify(gp); | 293 verify(gp); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, | 296 void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp, |
| 297 const GrGLSLExpr4& colorIn, | 297 const GrGLSLExpr4& colorIn, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 536 } |
| 537 | 537 |
| 538 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 538 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 539 | 539 |
| 540 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { | 540 GrGLInstalledFragProcs::~GrGLInstalledFragProcs() { |
| 541 int numProcs = fProcs.count(); | 541 int numProcs = fProcs.count(); |
| 542 for (int i = 0; i < numProcs; ++i) { | 542 for (int i = 0; i < numProcs; ++i) { |
| 543 delete fProcs[i]; | 543 delete fProcs[i]; |
| 544 } | 544 } |
| 545 } | 545 } |
| OLD | NEW |