| 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 #include "GrGLProgram.h" | 8 #include "GrGLProgram.h" |
| 9 | 9 |
| 10 #include "GrAllocator.h" | 10 #include "GrAllocator.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) | 24 #define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) |
| 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) | 25 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) |
| 26 | 26 |
| 27 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 27 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 28 | 28 |
| 29 GrGLProgram::GrGLProgram(GrGLGpu* gpu, | 29 GrGLProgram::GrGLProgram(GrGLGpu* gpu, |
| 30 const GrProgramDesc& desc, | 30 const GrProgramDesc& desc, |
| 31 const BuiltinUniformHandles& builtinUniforms, | 31 const BuiltinUniformHandles& builtinUniforms, |
| 32 GrGLuint programID, | 32 GrGLuint programID, |
| 33 const UniformInfoArray& uniforms, | 33 const UniformInfoArray& uniforms, |
| 34 const SkTArray<GrGLSampler>& samplers, |
| 34 const VaryingInfoArray& pathProcVaryings, | 35 const VaryingInfoArray& pathProcVaryings, |
| 35 GrGLSLPrimitiveProcessor* geometryProcessor, | 36 GrGLSLPrimitiveProcessor* geometryProcessor, |
| 36 GrGLSLXferProcessor* xferProcessor, | 37 GrGLSLXferProcessor* xferProcessor, |
| 37 const GrGLSLFragProcs& fragmentProcessors, | 38 const GrGLSLFragProcs& fragmentProcessors) |
| 38 SkTArray<UniformHandle>* passSamplerUniforms) | |
| 39 : fBuiltinUniformHandles(builtinUniforms) | 39 : fBuiltinUniformHandles(builtinUniforms) |
| 40 , fProgramID(programID) | 40 , fProgramID(programID) |
| 41 , fGeometryProcessor(geometryProcessor) | 41 , fGeometryProcessor(geometryProcessor) |
| 42 , fXferProcessor(xferProcessor) | 42 , fXferProcessor(xferProcessor) |
| 43 , fFragmentProcessors(fragmentProcessors) | 43 , fFragmentProcessors(fragmentProcessors) |
| 44 , fDesc(desc) | 44 , fDesc(desc) |
| 45 , fGpu(gpu) | 45 , fGpu(gpu) |
| 46 , fProgramDataManager(gpu, programID, uniforms, pathProcVaryings) { | 46 , fProgramDataManager(gpu, programID, uniforms, pathProcVaryings) { |
| 47 fSamplerUniforms.swap(passSamplerUniforms); | |
| 48 // Assign texture units to sampler uniforms one time up front. | 47 // Assign texture units to sampler uniforms one time up front. |
| 49 GL_CALL(UseProgram(fProgramID)); | 48 GL_CALL(UseProgram(fProgramID)); |
| 50 for (int i = 0; i < fSamplerUniforms.count(); i++) { | 49 fProgramDataManager.setSamplers(samplers); |
| 51 fProgramDataManager.setSampler(fSamplerUniforms[i], i); | |
| 52 } | |
| 53 } | 50 } |
| 54 | 51 |
| 55 GrGLProgram::~GrGLProgram() { | 52 GrGLProgram::~GrGLProgram() { |
| 56 if (fProgramID) { | 53 if (fProgramID) { |
| 57 GL_CALL(DeleteProgram(fProgramID)); | 54 GL_CALL(DeleteProgram(fProgramID)); |
| 58 } | 55 } |
| 59 for (int i = 0; i < fFragmentProcessors.count(); ++i) { | 56 for (int i = 0; i < fFragmentProcessors.count(); ++i) { |
| 60 delete fFragmentProcessors[i]; | 57 delete fFragmentProcessors[i]; |
| 61 } | 58 } |
| 62 } | 59 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const GrTextureAccess& access = processor.textureAccess(i); | 139 const GrTextureAccess& access = processor.textureAccess(i); |
| 143 fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(), | 140 fGpu->bindTexture((*nextSamplerIdx)++, access.getParams(), |
| 144 allowSRGBInputs, static_cast<GrGLTexture*>(access.getT
exture())); | 141 allowSRGBInputs, static_cast<GrGLTexture*>(access.getT
exture())); |
| 145 } | 142 } |
| 146 for (int i = 0; i < processor.numBuffers(); ++i) { | 143 for (int i = 0; i < processor.numBuffers(); ++i) { |
| 147 const GrBufferAccess& access = processor.bufferAccess(i); | 144 const GrBufferAccess& access = processor.bufferAccess(i); |
| 148 fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), acces
s.texelConfig(), | 145 fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.offsetInBytes(), acces
s.texelConfig(), |
| 149 static_cast<GrGLBuffer*>(access.buffer())); | 146 static_cast<GrGLBuffer*>(access.buffer())); |
| 150 } | 147 } |
| 151 } | 148 } |
| OLD | NEW |