diff options
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 51 | ||||
-rw-r--r-- | src/gpu/gl/GrGLProgram.h | 11 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUniformManager.cpp | 55 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUniformManager.h | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 9 | ||||
-rw-r--r-- | tests/GLProgramsTest.cpp | 2 |
8 files changed, 69 insertions, 72 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 540ebcaeb3..d457a32c4e 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -21,8 +21,8 @@ SK_DEFINE_INST_COUNT(GrGLProgram) -#define GL_CALL(X) GR_GL_CALL(fContext.interface(), X) -#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fContext.interface(), R, X) +#define GL_CALL(X) GR_GL_CALL(fGpu->glInterface(), X) +#define GL_CALL_RET(R, X) GR_GL_CALL_RET(fGpu->glInterface(), R, X) SK_CONF_DECLARE(bool, c_PrintShaders, "gpu.printShaders", false, "Print the source code for all shaders generated."); @@ -36,11 +36,11 @@ inline const char* declared_color_output_name() { return "fsColorOut"; } inline const char* dual_source_output_name() { return "dualSourceOut"; } } -GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, +GrGLProgram* GrGLProgram::Create(GrGpuGL* gpu, const GrGLProgramDesc& desc, const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[]) { - GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gl, desc, colorStages, coverageStages)); + GrGLProgram* program = SkNEW_ARGS(GrGLProgram, (gpu, desc, colorStages, coverageStages)); if (!program->succeeded()) { delete program; program = NULL; @@ -48,12 +48,12 @@ GrGLProgram* GrGLProgram::Create(const GrGLContext& gl, return program; } -GrGLProgram::GrGLProgram(const GrGLContext& gl, +GrGLProgram::GrGLProgram(GrGpuGL* gpu, const GrGLProgramDesc& desc, const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[]) -: fContext(gl) -, fUniformManager(gl) { +: fGpu(gpu) +, fUniformManager(gpu) { fDesc = desc; fVShaderID = 0; fGShaderID = 0; @@ -286,7 +286,7 @@ void GrGLProgram::genGeometryShader(GrGLShaderBuilder::VertexBuilder* vertexBuil #if GR_GL_EXPERIMENTAL_GS // TODO: The builder should add all this glue code. if (fDesc.getHeader().fExperimentalGS) { - SkASSERT(fContext.info().glslGeneration() >= k150_GrGLSLGeneration); + SkASSERT(fGpu->glslGeneration() >= k150_GrGLSLGeneration); vertexBuilder->fGSHeader.append("layout(triangles) in;\n" "layout(triangle_strip, max_vertices = 6) out;\n"); vertexBuilder->gsCodeAppend("\tfor (int i = 0; i < 3; ++i) {\n" @@ -335,7 +335,7 @@ void print_shader(GrGLint stringCnt, } // Compiles a GL shader, returns shader ID or 0 if failed params have same meaning as glShaderSource -GrGLuint compile_shader(const GrGLContext& gl, +GrGLuint compile_shader(const GrGLInterface* gli, GrGLenum type, int stringCnt, const char** strings, @@ -344,12 +344,11 @@ GrGLuint compile_shader(const GrGLContext& gl, "stringCount", SkStringPrintf("%i", stringCnt).c_str()); GrGLuint shader; - GR_GL_CALL_RET(gl.interface(), shader, CreateShader(type)); + GR_GL_CALL_RET(gli, shader, CreateShader(type)); if (0 == shader) { return 0; } - const GrGLInterface* gli = gl.interface(); GrGLint compiled = GR_GL_INIT_ZERO; GR_GL_CALL(gli, ShaderSource(shader, stringCnt, strings, stringLengths)); GR_GL_CALL(gli, CompileShader(shader)); @@ -376,10 +375,10 @@ GrGLuint compile_shader(const GrGLContext& gl, } // helper version of above for when shader is already flattened into a single SkString -GrGLuint compile_shader(const GrGLContext& gl, GrGLenum type, const SkString& shader) { +GrGLuint compile_shader(const GrGLInterface* gli, GrGLenum type, const SkString& shader) { const GrGLchar* str = shader.c_str(); int length = shader.size(); - return compile_shader(gl, type, 1, &str, &length); + return compile_shader(gli, type, 1, &str, &length); } void expand_known_value4f(SkString* string, GrSLConstantVec vec) { @@ -412,7 +411,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { GrPrintf(shader.c_str()); GrPrintf("\n"); } - if (!(fVShaderID = compile_shader(fContext, GR_GL_VERTEX_SHADER, shader))) { + if (!(fVShaderID = compile_shader(fGpu->glInterface(), GR_GL_VERTEX_SHADER, shader))) { return false; } @@ -423,7 +422,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { GrPrintf(shader.c_str()); GrPrintf("\n"); } - if (!(fGShaderID = compile_shader(fContext, GR_GL_GEOMETRY_SHADER, shader))) { + if (!(fGShaderID = compile_shader(fGpu->glInterface(), GR_GL_GEOMETRY_SHADER, shader))) { return false; } } @@ -435,7 +434,7 @@ bool GrGLProgram::compileShaders(const GrGLShaderBuilder& builder) { GrPrintf(shader.c_str()); GrPrintf("\n"); } - if (!(fFShaderID = compile_shader(fContext, GR_GL_FRAGMENT_SHADER, shader))) { + if (!(fFShaderID = compile_shader(fGpu->glInterface(), GR_GL_FRAGMENT_SHADER, shader))) { return false; } @@ -450,7 +449,7 @@ bool GrGLProgram::genProgram(const GrEffectStage* colorStages[], bool needsVertexShader = true; - GrGLShaderBuilder builder(fContext.info(), fUniformManager, fDesc, needsVertexShader); + GrGLShaderBuilder builder(fGpu->ctxInfo(), fUniformManager, fDesc, needsVertexShader); if (GrGLShaderBuilder::VertexBuilder* vertexBuilder = builder.getVertexBuilder()) { const char* viewMName; @@ -476,7 +475,7 @@ bool GrGLProgram::genProgram(const GrEffectStage* colorStages[], bool dualSourceOutputWritten = false; GrGLShaderVar colorOutput; - bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneration(), + bool isColorDeclared = GrGLSLSetupFSColorOuput(fGpu->glslGeneration(), declared_color_output_name(), &colorOutput); if (isColorDeclared) { @@ -797,8 +796,7 @@ void GrGLProgram::initEffectSamplerUniforms(EffectAndSamplers* effect, int* texU /////////////////////////////////////////////////////////////////////////////// -void GrGLProgram::setEffectData(GrGpuGL* gpu, - const GrEffectStage& stage, +void GrGLProgram::setEffectData(const GrEffectStage& stage, const EffectAndSamplers& effect) { // Let the GrGLEffect set its data. @@ -815,18 +813,17 @@ void GrGLProgram::setEffectData(GrGpuGL* gpu, const GrTextureAccess& access = (*stage.getEffect())->textureAccess(s); GrGLTexture* texture = static_cast<GrGLTexture*>(access.getTexture()); int unit = effect.fTextureUnits[s]; - gpu->bindTexture(unit, access.getParams(), texture); + fGpu->bindTexture(unit, access.getParams(), texture); } } } -void GrGLProgram::setData(GrGpuGL* gpu, - GrDrawState::BlendOptFlags blendOpts, +void GrGLProgram::setData(GrDrawState::BlendOptFlags blendOpts, const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[], const GrDeviceCoordTexture* dstCopy, SharedGLState* sharedState) { - const GrDrawState& drawState = gpu->getDrawState(); + const GrDrawState& drawState = fGpu->getDrawState(); GrColor color; GrColor coverage; @@ -864,7 +861,7 @@ void GrGLProgram::setData(GrGpuGL* gpu, 1.f / dstCopy->texture()->height()); GrGLTexture* texture = static_cast<GrGLTexture*>(dstCopy->texture()); static GrTextureParams kParams; // the default is clamp, nearest filtering. - gpu->bindTexture(fDstCopyTexUnit, kParams, texture); + fGpu->bindTexture(fDstCopyTexUnit, kParams, texture); } else { SkASSERT(!fUniformHandles.fDstCopyScaleUni.isValid()); SkASSERT(!fUniformHandles.fDstCopySamplerUni.isValid()); @@ -879,13 +876,13 @@ void GrGLProgram::setData(GrGpuGL* gpu, // We may have omitted the GrGLEffect because of the color filter logic in genProgram. // This can be removed when the color filter is an effect. if (NULL != fColorEffects[e].fGLEffect) { - this->setEffectData(gpu, *colorStages[e], fColorEffects[e]); + this->setEffectData(*colorStages[e], fColorEffects[e]); } } for (int e = 0; e < fCoverageEffects.count(); ++e) { if (NULL != fCoverageEffects[e].fGLEffect) { - this->setEffectData(gpu, *coverageStages[e], fCoverageEffects[e]); + this->setEffectData(*coverageStages[e], fCoverageEffects[e]); } } } diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h index e39e9bf076..283ac03d22 100644 --- a/src/gpu/gl/GrGLProgram.h +++ b/src/gpu/gl/GrGLProgram.h @@ -37,7 +37,7 @@ class GrGLProgram : public GrRefCnt { public: SK_DECLARE_INST_COUNT(GrGLProgram) - static GrGLProgram* Create(const GrGLContext& gl, + static GrGLProgram* Create(GrGpuGL* gpu, const GrGLProgramDesc& desc, const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[]); @@ -108,8 +108,7 @@ public: * GrGpuGL object to bind the textures required by the GrGLEffects. The color and coverage * stages come from GrGLProgramDesc::Build(). */ - void setData(GrGpuGL*, - GrDrawState::BlendOptFlags, + void setData(GrDrawState::BlendOptFlags, const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[], const GrDeviceCoordTexture* dstCopy, // can be NULL @@ -146,7 +145,7 @@ private: TextureUnitSArray fTextureUnits; // texture unit used for each entry of fSamplerUnis }; - GrGLProgram(const GrGLContext& gl, + GrGLProgram(GrGpuGL* gpu, const GrGLProgramDesc& desc, const GrEffectStage* colorStages[], const GrEffectStage* coverageStages[]); @@ -179,7 +178,7 @@ private: const char* adjustInColor(const SkString& inColor) const; // Helper for setData(). - void setEffectData(GrGpuGL* gpu, const GrEffectStage& stage, const EffectAndSamplers& effect); + void setEffectData(const GrEffectStage& stage, const EffectAndSamplers& effect); // Helper for setData(). Makes GL calls to specify the initial color when there is not // per-vertex colors. @@ -209,7 +208,7 @@ private: SkTArray<EffectAndSamplers> fCoverageEffects; GrGLProgramDesc fDesc; - const GrGLContext& fContext; + GrGpuGL* fGpu; GrGLUniformManager fUniformManager; UniformHandles fUniformHandles; diff --git a/src/gpu/gl/GrGLUniformManager.cpp b/src/gpu/gl/GrGLUniformManager.cpp index 79895f1e2e..74bb651fa4 100644 --- a/src/gpu/gl/GrGLUniformManager.cpp +++ b/src/gpu/gl/GrGLUniformManager.cpp @@ -8,6 +8,7 @@ #include "gl/GrGLShaderBuilder.h" #include "gl/GrGLProgram.h" #include "gl/GrGLUniformHandle.h" +#include "gl/GrGpuGL.h" #include "SkMatrix.h" #define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, OFFSET, COUNT) \ @@ -34,10 +35,10 @@ void GrGLUniformManager::setSampler(UniformHandle u, GrGLint texUnit) const { // once stages insert their own samplers. // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform1i(uni.fFSLocation, texUnit)); + GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fFSLocation, texUnit)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform1i(uni.fVSLocation, texUnit)); + GR_GL_CALL(fGpu->glInterface(), Uniform1i(uni.fVSLocation, texUnit)); } } @@ -47,10 +48,10 @@ void GrGLUniformManager::set1f(UniformHandle u, GrGLfloat v0) const { SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform1f(uni.fFSLocation, v0)); + GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fFSLocation, v0)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform1f(uni.fVSLocation, v0)); + GR_GL_CALL(fGpu->glInterface(), Uniform1f(uni.fVSLocation, v0)); } } @@ -67,10 +68,10 @@ void GrGLUniformManager::set1fv(UniformHandle u, // arrays in VS and FS driver bug workaround, this can be enabled. //SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform1fv(uni.fFSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fFSLocation + offset, arrayCount, v)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform1fv(uni.fVSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform1fv(uni.fVSLocation + offset, arrayCount, v)); } } @@ -80,10 +81,10 @@ void GrGLUniformManager::set2f(UniformHandle u, GrGLfloat v0, GrGLfloat v1) cons SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform2f(uni.fFSLocation, v0, v1)); + GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fFSLocation, v0, v1)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform2f(uni.fVSLocation, v0, v1)); + GR_GL_CALL(fGpu->glInterface(), Uniform2f(uni.fVSLocation, v0, v1)); } } @@ -97,10 +98,10 @@ void GrGLUniformManager::set2fv(UniformHandle u, ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform2fv(uni.fFSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fFSLocation + offset, arrayCount, v)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform2fv(uni.fVSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform2fv(uni.fVSLocation + offset, arrayCount, v)); } } @@ -110,10 +111,10 @@ void GrGLUniformManager::set3f(UniformHandle u, GrGLfloat v0, GrGLfloat v1, GrGL SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform3f(uni.fFSLocation, v0, v1, v2)); + GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fFSLocation, v0, v1, v2)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform3f(uni.fVSLocation, v0, v1, v2)); + GR_GL_CALL(fGpu->glInterface(), Uniform3f(uni.fVSLocation, v0, v1, v2)); } } @@ -127,10 +128,10 @@ void GrGLUniformManager::set3fv(UniformHandle u, ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform3fv(uni.fFSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fFSLocation + offset, arrayCount, v)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform3fv(uni.fVSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform3fv(uni.fVSLocation + offset, arrayCount, v)); } } @@ -144,10 +145,10 @@ void GrGLUniformManager::set4f(UniformHandle u, SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v3)); + GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fFSLocation, v0, v1, v2, v3)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v3)); + GR_GL_CALL(fGpu->glInterface(), Uniform4f(uni.fVSLocation, v0, v1, v2, v3)); } } @@ -160,10 +161,10 @@ void GrGLUniformManager::set4fv(UniformHandle u, SkASSERT(arrayCount > 0); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform4fv(uni.fFSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fFSLocation + offset, arrayCount, v)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), Uniform4fv(uni.fVSLocation + offset, arrayCount, v)); + GR_GL_CALL(fGpu->glInterface(), Uniform4fv(uni.fVSLocation + offset, arrayCount, v)); } } @@ -174,10 +175,10 @@ void GrGLUniformManager::setMatrix3f(UniformHandle u, const GrGLfloat matrix[]) // TODO: Re-enable this assert once texture matrices aren't forced on all effects // SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fFSLocation, 1, false, matrix)); + GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fFSLocation, 1, false, matrix)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), UniformMatrix3fv(uni.fVSLocation, 1, false, matrix)); + GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fVSLocation, 1, false, matrix)); } } @@ -187,10 +188,10 @@ void GrGLUniformManager::setMatrix4f(UniformHandle u, const GrGLfloat matrix[]) SkASSERT(GrGLShaderVar::kNonArray == uni.fArrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), UniformMatrix4fv(uni.fFSLocation, 1, false, matrix)); + GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation, 1, false, matrix)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), UniformMatrix4fv(uni.fVSLocation, 1, false, matrix)); + GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation, 1, false, matrix)); } } @@ -204,11 +205,11 @@ void GrGLUniformManager::setMatrix3fv(UniformHandle u, ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), + GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fFSLocation + offset, arrayCount, false, matrices)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), + GR_GL_CALL(fGpu->glInterface(), UniformMatrix3fv(uni.fVSLocation + offset, arrayCount, false, matrices)); } } @@ -223,11 +224,11 @@ void GrGLUniformManager::setMatrix4fv(UniformHandle u, ASSERT_ARRAY_UPLOAD_IN_BOUNDS(uni, offset, arrayCount); SkASSERT(kUnusedUniform != uni.fFSLocation || kUnusedUniform != uni.fVSLocation); if (kUnusedUniform != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), + GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fFSLocation + offset, arrayCount, false, matrices)); } if (kUnusedUniform != uni.fVSLocation && uni.fVSLocation != uni.fFSLocation) { - GR_GL_CALL(fContext.interface(), + GR_GL_CALL(fGpu->glInterface(), UniformMatrix4fv(uni.fVSLocation + offset, arrayCount, false, matrices)); } } @@ -257,7 +258,7 @@ void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUn SkASSERT(uniforms[i].fVariable.getArrayCount() == fUniforms[i].fArrayCount); GrGLint location; // TODO: Move the Xoom uniform array in both FS and VS bug workaround here. - GR_GL_CALL_RET(fContext.interface(), location, + GR_GL_CALL_RET(fGpu->glInterface(), location, GetUniformLocation(programID, uniforms[i].fVariable.c_str())); if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) { fUniforms[i].fVSLocation = location; diff --git a/src/gpu/gl/GrGLUniformManager.h b/src/gpu/gl/GrGLUniformManager.h index 1ef262da9f..eefab04986 100644 --- a/src/gpu/gl/GrGLUniformManager.h +++ b/src/gpu/gl/GrGLUniformManager.h @@ -14,7 +14,7 @@ #include "SkTArray.h" -class GrGLContext; +class GrGpuGL; class SkMatrix; /** Manages a program's uniforms. @@ -46,7 +46,7 @@ public: friend class GrGLUniformManager; // For accessing toUniformIndex(). }; - GrGLUniformManager(const GrGLContext& context) : fContext(context) {} + GrGLUniformManager(GrGpuGL* gpu) : fGpu(gpu) {} UniformHandle appendUniform(GrSLType type, int arrayCount = GrGLShaderVar::kNonArray); @@ -104,7 +104,7 @@ private: }; SkTArray<Uniform, true> fUniforms; - const GrGLContext& fContext; + GrGpuGL* fGpu; }; #endif diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 28e41af5f0..a9fd41ed5a 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -148,7 +148,7 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) ctx.info().caps()->print(); } - fProgramCache = SkNEW_ARGS(ProgramCache, (this->glContext())); + fProgramCache = SkNEW_ARGS(ProgramCache, (this)); SkASSERT(this->glCaps().maxVertexAttributes() >= GrDrawState::kMaxVertexAttribCnt); diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 1d1cdc575e..669f21c9be 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -31,6 +31,7 @@ public: virtual ~GrGpuGL(); const GrGLInterface* glInterface() const { return fGLContext.interface(); } + const GrGLContextInfo& ctxInfo() const { return fGLContext.info(); } GrGLBinding glBinding() const { return fGLContext.info().binding(); } GrGLVersion glVersion() const { return fGLContext.info().version(); } GrGLSLGeneration glslGeneration() const { return fGLContext.info().glslGeneration(); } @@ -171,7 +172,7 @@ private: class ProgramCache : public ::GrNoncopyable { public: - ProgramCache(const GrGLContext& gl); + ProgramCache(GrGpuGL* gpu); ~ProgramCache(); void abandon(); @@ -203,7 +204,7 @@ private: int fCount; unsigned int fCurrLRUStamp; - const GrGLContext& fGL; + GrGpuGL* fGpu; #ifdef PROGRAM_CACHE_STATS int fTotalRequests; int fCacheMisses; diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index 2b1795d0ec..0795dfad4f 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -35,10 +35,10 @@ struct GrGpuGL::ProgramCache::ProgDescLess { } }; -GrGpuGL::ProgramCache::ProgramCache(const GrGLContext& gl) +GrGpuGL::ProgramCache::ProgramCache(GrGpuGL* gpu) : fCount(0) , fCurrLRUStamp(0) - , fGL(gl) + , fGpu(gpu) #ifdef PROGRAM_CACHE_STATS , fTotalRequests(0) , fCacheMisses(0) @@ -119,7 +119,7 @@ GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, #ifdef PROGRAM_CACHE_STATS ++fCacheMisses; #endif - GrGLProgram* program = GrGLProgram::Create(fGL, desc, colorStages, coverageStages); + GrGLProgram* program = GrGLProgram::Create(fGpu, desc, colorStages, coverageStages); if (NULL == program) { return NULL; } @@ -305,8 +305,7 @@ bool GrGpuGL::flushGraphicsState(DrawType type, const GrDeviceCoordTexture* dstC fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); - fCurrentProgram->setData(this, - blendOpts, + fCurrentProgram->setData(blendOpts, colorStages.begin(), coverageStages.begin(), dstCopy, diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 17ad6064f3..c9f69f0ef3 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -186,7 +186,7 @@ bool GrGpuGL::programUnitTest(int maxStages) { numCoverageStages, currAttribIndex); - SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this->glContext(), + SkAutoTUnref<GrGLProgram> program(GrGLProgram::Create(this, pdesc, stages, stages + numColorStages)); |