| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrGLPathProcessor.h" | 8 #include "GrGLPathProcessor.h" |
| 9 | 9 |
| 10 #include "GrPathProcessor.h" | 10 #include "GrPathProcessor.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 tout->push_back_n(tin.count()); | 64 tout->push_back_n(tin.count()); |
| 65 fInstalledTransforms.push_back_n(tin.count()); | 65 fInstalledTransforms.push_back_n(tin.count()); |
| 66 for (int i = 0; i < tin.count(); i++) { | 66 for (int i = 0; i < tin.count(); i++) { |
| 67 const ProcCoords& coordTransforms = tin[i]; | 67 const ProcCoords& coordTransforms = tin[i]; |
| 68 fInstalledTransforms[i].push_back_n(coordTransforms.count()); | 68 fInstalledTransforms[i].push_back_n(coordTransforms.count()); |
| 69 for (int t = 0; t < coordTransforms.count(); t++) { | 69 for (int t = 0; t < coordTransforms.count(); t++) { |
| 70 GrSLType varyingType = | 70 GrSLType varyingType = |
| 71 coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_Gr
SLType : | 71 coordTransforms[t]->getMatrix().hasPerspective() ? kVec3f_Gr
SLType : |
| 72 kVec2f_Gr
SLType; | 72 kVec2f_Gr
SLType; |
| 73 | 73 |
| 74 | |
| 75 SkString strVaryingName("MatrixCoord"); | 74 SkString strVaryingName("MatrixCoord"); |
| 76 strVaryingName.appendf("_%i_%i", i, t); | 75 strVaryingName.appendf("_%i_%i", i, t); |
| 77 GrGLVertToFrag v(varyingType); | 76 GrGLVertToFrag v(varyingType); |
| 78 pb->addVarying(strVaryingName.c_str(), &v); | 77 fInstalledTransforms[i][t].fHandle = |
| 79 SeparableVaryingInfo& varyingInfo = fSeparableVaryingInfos.push_back
(); | 78 pb->addSeparableVarying(strVaryingName.c_str(), &v).toShader
BuilderIndex(); |
| 80 varyingInfo.fVariable = pb->getFragmentShaderBuilder()->fInputs.back
(); | |
| 81 varyingInfo.fLocation = fSeparableVaryingInfos.count() - 1; | |
| 82 varyingInfo.fType = varyingType; | |
| 83 fInstalledTransforms[i][t].fHandle = ShaderVarHandle(varyingInfo.fLo
cation); | |
| 84 fInstalledTransforms[i][t].fType = varyingType; | 79 fInstalledTransforms[i][t].fType = varyingType; |
| 85 | 80 |
| 86 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords
, | 81 SkNEW_APPEND_TO_TARRAY(&(*tout)[i], GrGLProcessor::TransformedCoords
, |
| 87 (SkString(v.fsIn()), varyingType)); | 82 (SkString(v.fsIn()), varyingType)); |
| 88 } | 83 } |
| 89 } | 84 } |
| 90 } | 85 } |
| 91 | 86 |
| 92 void GrGLPathProcessor::resolveSeparableVaryings(GrGLGpu* gpu, GrGLuint programI
d) { | |
| 93 int count = fSeparableVaryingInfos.count(); | |
| 94 for (int i = 0; i < count; ++i) { | |
| 95 GrGLint location; | |
| 96 GR_GL_CALL_RET(gpu->glInterface(), | |
| 97 location, | |
| 98 GetProgramResourceLocation(programId, | |
| 99 GR_GL_FRAGMENT_INPUT, | |
| 100 fSeparableVaryingInfos[i].fVar
iable.c_str())); | |
| 101 fSeparableVaryingInfos[i].fLocation = location; | |
| 102 } | |
| 103 } | |
| 104 | |
| 105 void GrGLPathProcessor::setTransformData( | 87 void GrGLPathProcessor::setTransformData( |
| 106 const GrPrimitiveProcessor& primProc, | 88 const GrPrimitiveProcessor& primProc, |
| 89 const GrGLPathProgramDataManager& pdman, |
| 107 int index, | 90 int index, |
| 108 const SkTArray<const GrCoordTransform*, true>& coordTransforms, | 91 const SkTArray<const GrCoordTransform*, true>& coordTransforms) { |
| 109 GrGLPathRendering* glpr, | |
| 110 GrGLuint programID) { | |
| 111 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); | 92 const GrPathProcessor& pathProc = primProc.cast<GrPathProcessor>(); |
| 112 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; | 93 SkSTArray<2, Transform, true>& transforms = fInstalledTransforms[index]; |
| 113 int numTransforms = transforms.count(); | 94 int numTransforms = transforms.count(); |
| 114 for (int t = 0; t < numTransforms; ++t) { | 95 for (int t = 0; t < numTransforms; ++t) { |
| 115 SkASSERT(transforms[t].fHandle.isValid()); | 96 SkASSERT(transforms[t].fHandle.isValid()); |
| 116 const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(), | 97 const SkMatrix& transform = GetTransformMatrix(pathProc.localMatrix(), |
| 117 *coordTransforms[t]); | 98 *coordTransforms[t]); |
| 118 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { | 99 if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { |
| 119 continue; | 100 continue; |
| 120 } | 101 } |
| 121 transforms[t].fCurrentValue = transform; | 102 transforms[t].fCurrentValue = transform; |
| 122 const SeparableVaryingInfo& fragmentInput = | 103 |
| 123 fSeparableVaryingInfos[transforms[t].fHandle.handle()]; | |
| 124 SkASSERT(transforms[t].fType == kVec2f_GrSLType || | 104 SkASSERT(transforms[t].fType == kVec2f_GrSLType || |
| 125 transforms[t].fType == kVec3f_GrSLType); | 105 transforms[t].fType == kVec3f_GrSLType); |
| 126 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; | 106 unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; |
| 127 glpr->setProgramPathFragmentInputTransform(programID, | 107 pdman.setPathFragmentInputTransform(transforms[t].fHandle.handle(), comp
onents, transform); |
| 128 fragmentInput.fLocation, | |
| 129 GR_GL_OBJECT_LINEAR, | |
| 130 components, | |
| 131 transform); | |
| 132 } | 108 } |
| 133 } | 109 } |
| OLD | NEW |