| Index: src/gpu/gl/GrGLUniformManager.cpp
|
| diff --git a/src/gpu/gl/GrGLUniformManager.cpp b/src/gpu/gl/GrGLUniformManager.cpp
|
| index 29679aa409a4c07308fb972f53a45fe268eb8d6b..c4121f15ddc807674929131ffda5a43b5c64b411 100644
|
| --- a/src/gpu/gl/GrGLUniformManager.cpp
|
| +++ b/src/gpu/gl/GrGLUniformManager.cpp
|
| @@ -248,28 +248,89 @@ void GrGLUniformManager::setSkMatrix(UniformHandle u, const SkMatrix& matrix) co
|
| this->setMatrix3f(u, mt);
|
| }
|
|
|
| +void GrGLUniformManager::setFragmentInput(FragmentInputHandle i, size_t components, const SkMatrix& matrix) const {
|
| + const FragmentInput& fragmentInput = fFragmentInputs[i.toLocationIndex()];
|
|
|
| -void GrGLUniformManager::getUniformLocations(GrGLuint programID, const BuilderUniformArray& uniforms) {
|
| + GrGLfloat coefficients[3 * 3];
|
| + SkASSERT(components >= 1 && components <= 3);
|
| +
|
| + coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
|
| + coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]);
|
| + coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]);
|
| +
|
| + if (components >= 2) {
|
| + coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]);
|
| + coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]);
|
| + coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]);
|
| + }
|
| +
|
| + if (components >= 3) {
|
| + coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]);
|
| + coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]);
|
| + coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]);
|
| + }
|
| + fGpu->setProgramPathFragmentInputGen(fragmentInput.fLocation, components, coefficients);
|
| +}
|
| +
|
| +
|
| +void GrGLUniformManager::bindProgramResourceLocations(
|
| + GrGLuint programID,
|
| + const BuilderUniformArray& uniforms) {
|
| + if (!fUsingBindUniform) {
|
| + return;
|
| + }
|
| SkASSERT(uniforms.count() == fUniforms.count());
|
| int count = fUniforms.count();
|
| for (int i = 0; i < count; ++i) {
|
| SkASSERT(uniforms[i].fVariable.getType() == fUniforms[i].fType);
|
| SkASSERT(uniforms[i].fVariable.getArrayCount() == fUniforms[i].fArrayCount);
|
| - GrGLint location;
|
| // TODO: Move the Xoom uniform array in both FS and VS bug workaround here.
|
| - if (fUsingBindUniform) {
|
| - location = i;
|
| - GR_GL_CALL(fGpu->glInterface(),
|
| - BindUniformLocation(programID, location, uniforms[i].fVariable.c_str()));
|
| - } else {
|
| - GR_GL_CALL_RET(fGpu->glInterface(), location,
|
| - GetUniformLocation(programID, uniforms[i].fVariable.c_str()));
|
| - }
|
| +
|
| + GR_GL_CALL(fGpu->glInterface(),
|
| + BindUniformLocation(programID, i, uniforms[i].fVariable.c_str()));
|
| if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) {
|
| - fUniforms[i].fVSLocation = location;
|
| + fUniforms[i].fVSLocation = i;
|
| }
|
| if (GrGLShaderBuilder::kFragment_Visibility & uniforms[i].fVisibility) {
|
| - fUniforms[i].fFSLocation = location;
|
| + fUniforms[i].fFSLocation = i;
|
| + }
|
| + }
|
| +}
|
| +
|
| +void GrGLUniformManager::resolveProgramResourceLocations(
|
| + GrGLuint programID,
|
| + const BuilderUniformArray& uniforms,
|
| + const BuilderFragmentInputArray& fragmentInputs) {
|
| + if (!fUsingBindUniform) {
|
| + SkASSERT(uniforms.count() == fUniforms.count());
|
| + int count = fUniforms.count();
|
| + for (int i = 0; i < count; ++i) {
|
| + SkASSERT(uniforms[i].fVariable.getType() == fUniforms[i].fType);
|
| + 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(fGpu->glInterface(), location,
|
| + GetUniformLocation(programID, uniforms[i].fVariable.c_str()));
|
| +
|
| + if (GrGLShaderBuilder::kVertex_Visibility & uniforms[i].fVisibility) {
|
| + fUniforms[i].fVSLocation = location;
|
| + }
|
| + if (GrGLShaderBuilder::kFragment_Visibility & uniforms[i].fVisibility) {
|
| + fUniforms[i].fFSLocation = location;
|
| + }
|
| + }
|
| + }
|
| +
|
| + if (fGpu->glCaps().pathRenderingSupport()) {
|
| + int count = fFragmentInputs.count();
|
| + SkASSERT(fragmentInputs.count() == fFragmentInputs.count());
|
| + for (int i = 0; i < count; ++i) {
|
| + GrGLint location;
|
| + GR_GL_CALL_RET(fGpu->glInterface(), location,
|
| + GetProgramResourceLocation(programID,
|
| + GR_GL_FRAGMENT_INPUT,
|
| + fragmentInputs[i].c_str()));
|
| + fFragmentInputs[i].fLocation = location;
|
| }
|
| }
|
| }
|
| @@ -278,3 +339,9 @@ const GrGLUniformManager::BuilderUniform&
|
| GrGLUniformManager::getBuilderUniform(const BuilderUniformArray& array, UniformHandle handle) const {
|
| return array[handle.toUniformIndex()];
|
| }
|
| +
|
| +GrGLUniformManager::FragmentInputHandle GrGLUniformManager::appendFragmentInput() {
|
| + int idx = fFragmentInputs.count();
|
| + fFragmentInputs.push_back();
|
| + return FragmentInputHandle::CreateFromFragmentInputIndex(idx);
|
| +}
|
|
|