void GrGpuGLShaders::flushRadial2(int s) { const int &uni = fProgramData->fUniLocations.fStages[s].fRadial2Uni; const GrSamplerState& sampler = this->getDrawState().getSampler(s); if (GrGLProgram::kUnusedUniform != uni && (fProgramData->fRadial2CenterX1[s] != sampler.getRadial2CenterX1() || fProgramData->fRadial2Radius0[s] != sampler.getRadial2Radius0() || fProgramData->fRadial2PosRoot[s] != sampler.isRadial2PosRoot())) { GrScalar centerX1 = sampler.getRadial2CenterX1(); GrScalar radius0 = sampler.getRadial2Radius0(); GrScalar a = GrMul(centerX1, centerX1) - GR_Scalar1; // when were in the degenerate (linear) case the second // value will be INF but the program doesn't read it. (We // use the same 6 uniforms even though we don't need them // all in the linear case just to keep the code complexity // down). float values[6] = { GrScalarToFloat(a), 1 / (2.f * GrScalarToFloat(a)), GrScalarToFloat(centerX1), GrScalarToFloat(radius0), GrScalarToFloat(GrMul(radius0, radius0)), sampler.isRadial2PosRoot() ? 1.f : -1.f }; GL_CALL(Uniform1fv(uni, 6, values)); fProgramData->fRadial2CenterX1[s] = sampler.getRadial2CenterX1(); fProgramData->fRadial2Radius0[s] = sampler.getRadial2Radius0(); fProgramData->fRadial2PosRoot[s] = sampler.isRadial2PosRoot(); } }
void GrGpuGLShaders::flushConvolution(int s) { const GrSamplerState& sampler = this->getDrawState().getSampler(s); int kernelUni = fProgramData->fUniLocations.fStages[s].fKernelUni; if (GrGLProgram::kUnusedUniform != kernelUni) { GL_CALL(Uniform1fv(kernelUni, sampler.getKernelWidth(), sampler.getKernel())); } int imageIncrementUni = fProgramData->fUniLocations.fStages[s].fImageIncrementUni; if (GrGLProgram::kUnusedUniform != imageIncrementUni) { const GrGLTexture* texture = static_cast<const GrGLTexture*>(this->getDrawState().getTexture(s)); float imageIncrement[2] = { 0 }; switch (sampler.getFilterDirection()) { case GrSamplerState::kX_FilterDirection: imageIncrement[0] = 1.0f / texture->width(); break; case GrSamplerState::kY_FilterDirection: imageIncrement[1] = 1.0f / texture->height(); break; default: GrCrash("Unknown filter direction."); } GL_CALL(Uniform2fv(imageIncrementUni, 1, imageIncrement)); } }
void GrGpuGLShaders::flushConvolution(int s) { const GrSamplerState& sampler = this->getDrawState().getSampler(s); int kernelUni = fProgramData->fUniLocations.fStages[s].fKernelUni; if (GrGLProgram::kUnusedUniform != kernelUni) { GL_CALL(Uniform1fv(kernelUni, sampler.getKernelWidth(), sampler.getKernel())); } int imageIncrementUni = fProgramData->fUniLocations.fStages[s].fImageIncrementUni; if (GrGLProgram::kUnusedUniform != imageIncrementUni) { GL_CALL(Uniform2fv(imageIncrementUni, 1, sampler.getImageIncrement())); } }
void GrGpuGLShaders::flushRadial2(int stage) { const GrSamplerState& sampler = fCurrDrawState.fSamplerStates[stage]; GrScalar centerX1 = sampler.getRadial2CenterX1(); GrScalar radius0 = sampler.getRadial2Radius0(); GrScalar a = GrMul(centerX1, centerX1) - GR_Scalar1; float unis[6] = { GrScalarToFloat(a), 1 / (2.f * unis[0]), GrScalarToFloat(centerX1), GrScalarToFloat(radius0), GrScalarToFloat(GrMul(radius0, radius0)), sampler.isRadial2PosRoot() ? 1.f : -1.f }; GR_GL(Uniform1fv(fProgramData->fUniLocations.fStages[stage].fRadial2Uni, 6, unis)); }
GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v) { CONTEXT_EXEC(Uniform1fv(location, count, v)); }