| 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" | 
|   11 #include "GrProcessor.h" |   11 #include "GrProcessor.h" | 
|   12 #include "GrCoordTransform.h" |   12 #include "GrCoordTransform.h" | 
|   13 #include "GrGLGeometryProcessor.h" |   13 #include "GrGLGeometryProcessor.h" | 
|   14 #include "GrGLProcessor.h" |   14 #include "GrGLProcessor.h" | 
|   15 #include "GrGLXferProcessor.h" |   15 #include "GrGLXferProcessor.h" | 
|   16 #include "GrGLGpu.h" |   16 #include "GrGLGpu.h" | 
|   17 #include "GrGLPathRendering.h" |   17 #include "GrGLPathRendering.h" | 
|   18 #include "GrGLShaderVar.h" |   18 #include "GrGLShaderVar.h" | 
|   19 #include "GrGLSL.h" |   19 #include "GrGLSL.h" | 
|   20 #include "GrOptDrawState.h" |   20 #include "GrOptDrawState.h" | 
|   21 #include "GrXferProcessor.h" |   21 #include "GrXferProcessor.h" | 
|   22 #include "SkXfermode.h" |   22 #include "SkXfermode.h" | 
|   23  |   23  | 
|   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 /** |  | 
|   28  * Retrieves the final matrix that a transform needs to apply to its source coor
     ds. |  | 
|   29  */ |  | 
|   30 static SkMatrix get_transform_matrix(const GrPendingFragmentStage& stage, |  | 
|   31                                      int transformIdx, |  | 
|   32                                      const SkMatrix& localMatrix) { |  | 
|   33     const GrCoordTransform& coordTransform = stage.processor()->coordTransform(t
     ransformIdx); |  | 
|   34     SkMatrix combined; |  | 
|   35  |  | 
|   36     // We only apply the localmatrix to localcoords |  | 
|   37     if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { |  | 
|   38         combined.setConcat(coordTransform.getMatrix(), localMatrix); |  | 
|   39     } else { |  | 
|   40         combined = coordTransform.getMatrix(); |  | 
|   41     } |  | 
|   42     if (coordTransform.reverseY()) { |  | 
|   43         // combined.postScale(1,-1); |  | 
|   44         // combined.postTranslate(0,1); |  | 
|   45         combined.set(SkMatrix::kMSkewY, |  | 
|   46             combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); |  | 
|   47         combined.set(SkMatrix::kMScaleY, |  | 
|   48             combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); |  | 
|   49         combined.set(SkMatrix::kMTransY, |  | 
|   50             combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); |  | 
|   51     } |  | 
|   52     return combined; |  | 
|   53 } |  | 
|   54  |  | 
|   55 ////////////////////////////////////////////////////////////////////////////////
     /////////////////// |   27 ////////////////////////////////////////////////////////////////////////////////
     /////////////////// | 
|   56  |   28  | 
|   57 GrGLProgram::GrGLProgram(GrGLGpu* gpu, |   29 GrGLProgram::GrGLProgram(GrGLGpu* gpu, | 
|   58                          const GrProgramDesc& desc, |   30                          const GrProgramDesc& desc, | 
|   59                          const BuiltinUniformHandles& builtinUniforms, |   31                          const BuiltinUniformHandles& builtinUniforms, | 
|   60                          GrGLuint programID, |   32                          GrGLuint programID, | 
|   61                          const UniformInfoArray& uniforms, |   33                          const UniformInfoArray& uniforms, | 
|   62                          GrGLInstalledGeoProc* geometryProcessor, |   34                          GrGLInstalledGeoProc* geometryProcessor, | 
|   63                          GrGLInstalledXferProc* xferProcessor, |   35                          GrGLInstalledXferProc* xferProcessor, | 
|   64                          GrGLInstalledFragProcs* fragmentProcessors) |   36                          GrGLInstalledFragProcs* fragmentProcessors) | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|   86     fProgramID = 0; |   58     fProgramID = 0; | 
|   87 } |   59 } | 
|   88  |   60  | 
|   89 void GrGLProgram::initSamplerUniforms() { |   61 void GrGLProgram::initSamplerUniforms() { | 
|   90     GL_CALL(UseProgram(fProgramID)); |   62     GL_CALL(UseProgram(fProgramID)); | 
|   91     GrGLint texUnitIdx = 0; |   63     GrGLint texUnitIdx = 0; | 
|   92     if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { |   64     if (fBuiltinUniformHandles.fDstCopySamplerUni.isValid()) { | 
|   93         fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni
     , texUnitIdx); |   65         fProgramDataManager.setSampler(fBuiltinUniformHandles.fDstCopySamplerUni
     , texUnitIdx); | 
|   94         fDstCopyTexUnit = texUnitIdx++; |   66         fDstCopyTexUnit = texUnitIdx++; | 
|   95     } |   67     } | 
|   96     if (fGeometryProcessor.get()) { |   68     this->initSamplers(fGeometryProcessor.get(), &texUnitIdx); | 
|   97         this->initSamplers(fGeometryProcessor.get(), &texUnitIdx); |  | 
|   98     } |  | 
|   99     if (fXferProcessor.get()) { |   69     if (fXferProcessor.get()) { | 
|  100         this->initSamplers(fXferProcessor.get(), &texUnitIdx); |   70         this->initSamplers(fXferProcessor.get(), &texUnitIdx); | 
|  101     } |   71     } | 
|  102     int numProcs = fFragmentProcessors->fProcs.count(); |   72     int numProcs = fFragmentProcessors->fProcs.count(); | 
|  103     for (int i = 0; i < numProcs; i++) { |   73     for (int i = 0; i < numProcs; i++) { | 
|  104         this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx); |   74         this->initSamplers(fFragmentProcessors->fProcs[i], &texUnitIdx); | 
|  105     } |   75     } | 
|  106 } |   76 } | 
|  107  |   77  | 
|  108 void GrGLProgram::initSamplers(GrGLInstalledProc* ip, int* texUnitIdx) { |   78 template <class Proc> | 
|  109     SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers; |   79 void GrGLProgram::initSamplers(Proc* ip, int* texUnitIdx) { | 
 |   80     SkTArray<typename Proc::Sampler, true>& samplers = ip->fSamplers; | 
|  110     int numSamplers = samplers.count(); |   81     int numSamplers = samplers.count(); | 
|  111     for (int s = 0; s < numSamplers; ++s) { |   82     for (int s = 0; s < numSamplers; ++s) { | 
|  112         SkASSERT(samplers[s].fUniform.isValid()); |   83         SkASSERT(samplers[s].fUniform.isValid()); | 
|  113         fProgramDataManager.setSampler(samplers[s].fUniform, *texUnitIdx); |   84         fProgramDataManager.setSampler(samplers[s].fUniform, *texUnitIdx); | 
|  114         samplers[s].fTextureUnit = (*texUnitIdx)++; |   85         samplers[s].fTextureUnit = (*texUnitIdx)++; | 
|  115     } |   86     } | 
|  116 } |   87 } | 
|  117  |   88  | 
|  118 void GrGLProgram::bindTextures(const GrGLInstalledProc* ip, const GrProcessor& p
     rocessor) { |   89 template <class Proc> | 
|  119     const SkTArray<GrGLInstalledProc::Sampler, true>& samplers = ip->fSamplers; |   90 void GrGLProgram::bindTextures(const Proc* ip, const GrProcessor& processor) { | 
 |   91     const SkTArray<typename Proc::Sampler, true>& samplers = ip->fSamplers; | 
|  120     int numSamplers = samplers.count(); |   92     int numSamplers = samplers.count(); | 
|  121     SkASSERT(numSamplers == processor.numTextures()); |   93     SkASSERT(numSamplers == processor.numTextures()); | 
|  122     for (int s = 0; s < numSamplers; ++s) { |   94     for (int s = 0; s < numSamplers; ++s) { | 
|  123         SkASSERT(samplers[s].fTextureUnit >= 0); |   95         SkASSERT(samplers[s].fTextureUnit >= 0); | 
|  124         const GrTextureAccess& textureAccess = processor.textureAccess(s); |   96         const GrTextureAccess& textureAccess = processor.textureAccess(s); | 
|  125         fGpu->bindTexture(samplers[s].fTextureUnit, |   97         fGpu->bindTexture(samplers[s].fTextureUnit, | 
|  126                           textureAccess.getParams(), |   98                           textureAccess.getParams(), | 
|  127                           static_cast<GrGLTexture*>(textureAccess.getTexture()))
     ; |   99                           static_cast<GrGLTexture*>(textureAccess.getTexture()))
     ; | 
|  128     } |  100     } | 
|  129 } |  101 } | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|  154         SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); |  126         SkASSERT(!fBuiltinUniformHandles.fDstCopyTopLeftUni.isValid()); | 
|  155         SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); |  127         SkASSERT(!fBuiltinUniformHandles.fDstCopyScaleUni.isValid()); | 
|  156         SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); |  128         SkASSERT(!fBuiltinUniformHandles.fDstCopySamplerUni.isValid()); | 
|  157     } |  129     } | 
|  158  |  130  | 
|  159     // we set the textures, and uniforms for installed processors in a generic w
     ay, but subclasses |  131     // we set the textures, and uniforms for installed processors in a generic w
     ay, but subclasses | 
|  160     // of GLProgram determine how to set coord transforms |  132     // of GLProgram determine how to set coord transforms | 
|  161     const GrPrimitiveProcessor& primProc = *optState.getPrimitiveProcessor(); |  133     const GrPrimitiveProcessor& primProc = *optState.getPrimitiveProcessor(); | 
|  162     const GrBatchTracker& bt = optState.getBatchTracker(); |  134     const GrBatchTracker& bt = optState.getBatchTracker(); | 
|  163     fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, bt); |  135     fGeometryProcessor->fGLProc->setData(fProgramDataManager, primProc, bt); | 
|  164     this->bindTextures(fGeometryProcessor, primProc); |  136     this->bindTextures(fGeometryProcessor.get(), primProc); | 
|  165  |  137  | 
|  166     if (fXferProcessor.get()) { |  138     if (fXferProcessor.get()) { | 
|  167         const GrXferProcessor& xp = *optState.getXferProcessor(); |  139         const GrXferProcessor& xp = *optState.getXferProcessor(); | 
|  168         fXferProcessor->fGLProc->setData(fProgramDataManager, xp); |  140         fXferProcessor->fGLProc->setData(fProgramDataManager, xp); | 
|  169         this->bindTextures(fXferProcessor, xp); |  141         this->bindTextures(fXferProcessor.get(), xp); | 
|  170     } |  142     } | 
|  171     this->setFragmentData(optState); |  143     this->setFragmentData(optState); | 
|  172  |  144  | 
|  173     // Some of GrGLProgram subclasses need to update state here |  145     // Some of GrGLProgram subclasses need to update state here | 
|  174     this->didSetData(optState.drawType()); |  146     this->didSetData(optState.drawType()); | 
|  175 } |  147 } | 
|  176  |  148  | 
|  177 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) { |  149 void GrGLProgram::setFragmentData(const GrOptDrawState& optState) { | 
|  178     int numProcessors = fFragmentProcessors->fProcs.count(); |  150     int numProcessors = fFragmentProcessors->fProcs.count(); | 
|  179     for (int e = 0; e < numProcessors; ++e) { |  151     for (int e = 0; e < numProcessors; ++e) { | 
|  180         const GrPendingFragmentStage& stage = optState.getFragmentStage(e); |  152         const GrPendingFragmentStage& stage = optState.getFragmentStage(e); | 
|  181         const GrProcessor& processor = *stage.processor(); |  153         const GrProcessor& processor = *stage.processor(); | 
|  182         fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr
     ocessor); |  154         fFragmentProcessors->fProcs[e]->fGLProc->setData(fProgramDataManager, pr
     ocessor); | 
|  183         const SkMatrix& localMatrix = optState.getPrimitiveProcessor()->localMat
     rix(); |  155         this->setTransformData(optState.getPrimitiveProcessor(), | 
|  184         this->setTransformData(stage, localMatrix, fFragmentProcessors->fProcs[e
     ]); |  156                                stage, | 
 |  157                                e, | 
 |  158                                fFragmentProcessors->fProcs[e]); | 
|  185         this->bindTextures(fFragmentProcessors->fProcs[e], processor); |  159         this->bindTextures(fFragmentProcessors->fProcs[e], processor); | 
|  186     } |  160     } | 
|  187 } |  161 } | 
|  188 void GrGLProgram::setTransformData(const GrPendingFragmentStage& processor, |  162 void GrGLProgram::setTransformData(const GrPrimitiveProcessor* primProc, | 
|  189                                    const SkMatrix& localMatrix, |  163                                    const GrPendingFragmentStage& processor, | 
 |  164                                    int index, | 
|  190                                    GrGLInstalledFragProc* ip) { |  165                                    GrGLInstalledFragProc* ip) { | 
|  191     SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor
     ms; |  166     GrGLGeometryProcessor* gp = | 
|  192     int numTransforms = transforms.count(); |  167             static_cast<GrGLGeometryProcessor*>(fGeometryProcessor.get()->fGLPro
     c.get()); | 
|  193     SkASSERT(numTransforms == processor.processor()->numTransforms()); |  168     gp->setTransformData(primProc, fProgramDataManager, index, | 
|  194     for (int t = 0; t < numTransforms; ++t) { |  169                          processor.processor()->coordTransforms()); | 
|  195         SkASSERT(transforms[t].fHandle.isValid()); |  | 
|  196         const SkMatrix& matrix = get_transform_matrix(processor, t, localMatrix)
     ; |  | 
|  197         if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { |  | 
|  198             fProgramDataManager.setSkMatrix(transforms[t].fHandle.convertToUnifo
     rmHandle(), matrix); |  | 
|  199             transforms[t].fCurrentValue = matrix; |  | 
|  200         } |  | 
|  201     } |  | 
|  202 } |  170 } | 
|  203  |  171  | 
|  204 void GrGLProgram::didSetData(GrGpu::DrawType drawType) { |  172 void GrGLProgram::didSetData(GrGpu::DrawType drawType) { | 
|  205     SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType)); |  173     SkASSERT(!GrGpu::IsPathRenderingDrawType(drawType)); | 
|  206 } |  174 } | 
|  207  |  175  | 
|  208 void GrGLProgram::setRenderTargetState(const GrOptDrawState& optState) { |  176 void GrGLProgram::setRenderTargetState(const GrOptDrawState& optState) { | 
|  209     // Load the RT height uniform if it is needed to y-flip gl_FragCoord. |  177     // Load the RT height uniform if it is needed to y-flip gl_FragCoord. | 
|  210     if (fBuiltinUniformHandles.fRTHeightUni.isValid() && |  178     if (fBuiltinUniformHandles.fRTHeightUni.isValid() && | 
|  211         fRenderTargetState.fRenderTargetSize.fHeight != optState.getRenderTarget
     ()->height()) { |  179         fRenderTargetState.fRenderTargetSize.fHeight != optState.getRenderTarget
     ()->height()) { | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
|  227         fRenderTargetState.fRenderTargetOrigin = rt->origin(); |  195         fRenderTargetState.fRenderTargetOrigin = rt->origin(); | 
|  228  |  196  | 
|  229         GrGLfloat rtAdjustmentVec[4]; |  197         GrGLfloat rtAdjustmentVec[4]; | 
|  230         fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); |  198         fRenderTargetState.getRTAdjustmentVec(rtAdjustmentVec); | 
|  231         fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
     tAdjustmentVec); |  199         fProgramDataManager.set4fv(fBuiltinUniformHandles.fRTAdjustmentUni, 1, r
     tAdjustmentVec); | 
|  232     } |  200     } | 
|  233 } |  201 } | 
|  234  |  202  | 
|  235 ////////////////////////////////////////////////////////////////////////////////
     ///////// |  203 ////////////////////////////////////////////////////////////////////////////////
     ///////// | 
|  236  |  204  | 
|  237 GrGLNvprProgramBase::GrGLNvprProgramBase(GrGLGpu* gpu, |  | 
|  238                                          const GrProgramDesc& desc, |  | 
|  239                                          const BuiltinUniformHandles& builtinUni
     forms, |  | 
|  240                                          GrGLuint programID, |  | 
|  241                                          const UniformInfoArray& uniforms, |  | 
|  242                                          GrGLInstalledGeoProc* primProc, |  | 
|  243                                          GrGLInstalledXferProc* xferProcessor, |  | 
|  244                                          GrGLInstalledFragProcs* fragmentProcess
     ors) |  | 
|  245     : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc, |  | 
|  246                 xferProcessor, fragmentProcessors) { |  | 
|  247 } |  | 
|  248  |  | 
|  249 void GrGLNvprProgramBase::onSetRenderTargetState(const GrOptDrawState& optState)
      { |  | 
|  250     SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType())); |  | 
|  251     const GrRenderTarget* rt = optState.getRenderTarget(); |  | 
|  252     SkISize size; |  | 
|  253     size.set(rt->width(), rt->height()); |  | 
|  254     fGpu->glPathRendering()->setProjectionMatrix(optState.getPrimitiveProcessor(
     )->viewMatrix(), |  | 
|  255                                                  size, rt->origin()); |  | 
|  256 } |  | 
|  257  |  | 
|  258 ////////////////////////////////////////////////////////////////////////////////
     ///////// |  | 
|  259  |  | 
|  260 GrGLNvprProgram::GrGLNvprProgram(GrGLGpu* gpu, |  205 GrGLNvprProgram::GrGLNvprProgram(GrGLGpu* gpu, | 
|  261                                  const GrProgramDesc& desc, |  206                                  const GrProgramDesc& desc, | 
|  262                                  const BuiltinUniformHandles& builtinUniforms, |  207                                  const BuiltinUniformHandles& builtinUniforms, | 
|  263                                  GrGLuint programID, |  208                                  GrGLuint programID, | 
|  264                                  const UniformInfoArray& uniforms, |  209                                  const UniformInfoArray& uniforms, | 
|  265                                  GrGLInstalledGeoProc* primProc, |  210                                  GrGLInstalledGeoProc* primProc, | 
|  266                                  GrGLInstalledXferProc* xferProcessor, |  211                                  GrGLInstalledXferProc* xferProcessor, | 
|  267                                  GrGLInstalledFragProcs* fragmentProcessors, |  212                                  GrGLInstalledFragProcs* fragmentProcessors) | 
|  268                                  const SeparableVaryingInfoArray& separableVaryi
     ngs) |  | 
|  269     : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc, |  213     : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc, | 
|  270                 xferProcessor, fragmentProcessors) { |  214                 xferProcessor, fragmentProcessors) { | 
|  271     int count = separableVaryings.count(); |  215 } | 
|  272     fVaryings.push_back_n(count); |  216 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) { | 
|  273     for (int i = 0; i < count; i++) { |  217     SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); | 
|  274         Varying& varying = fVaryings[i]; |  218     GrGLPathProcessor* pathProc = | 
|  275         const SeparableVaryingInfo& builderVarying = separableVaryings[i]; |  219             static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.ge
     t()); | 
|  276         SkASSERT(GrGLShaderVar::kNonArray == builderVarying.fVariable.getArrayCo
     unt()); |  220     pathProc->didSetData(fGpu->glPathRendering()); | 
|  277         SkDEBUGCODE( |  | 
|  278             varying.fType = builderVarying.fVariable.getType(); |  | 
|  279         ); |  | 
|  280         varying.fLocation = builderVarying.fLocation; |  | 
|  281     } |  | 
|  282 } |  221 } | 
|  283  |  222  | 
|  284 void GrGLNvprProgram::didSetData(GrGpu::DrawType drawType) { |  223 void GrGLNvprProgram::setTransformData(const GrPrimitiveProcessor* primProc, | 
|  285     SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); |  224                                        const GrPendingFragmentStage& proc, | 
 |  225                                        int index, | 
 |  226                                        GrGLInstalledFragProc* ip) { | 
 |  227     GrGLPathProcessor* pathProc = | 
 |  228             static_cast<GrGLPathProcessor*>(fGeometryProcessor.get()->fGLProc.ge
     t()); | 
 |  229     pathProc->setTransformData(primProc, index, proc.processor()->coordTransform
     s(), | 
 |  230                                fGpu->glPathRendering(), fProgramID); | 
|  286 } |  231 } | 
|  287  |  232  | 
|  288 void GrGLNvprProgram::setTransformData(const GrPendingFragmentStage& proc, |  233 void GrGLNvprProgram::onSetRenderTargetState(const GrOptDrawState& optState) { | 
|  289                                        const SkMatrix& localMatrix, |  234     SkASSERT(GrGpu::IsPathRenderingDrawType(optState.drawType())); | 
|  290                                        GrGLInstalledFragProc* ip) { |  235     const GrRenderTarget* rt = optState.getRenderTarget(); | 
|  291     SkTArray<GrGLInstalledFragProc::Transform, true>& transforms = ip->fTransfor
     ms; |  236     SkISize size; | 
|  292     int numTransforms = transforms.count(); |  237     size.set(rt->width(), rt->height()); | 
|  293     SkASSERT(numTransforms == proc.processor()->numTransforms()); |  238     fGpu->glPathRendering()->setProjectionMatrix(optState.getPrimitiveProcessor(
     )->viewMatrix(), | 
|  294     for (int t = 0; t < numTransforms; ++t) { |  239                                                  size, rt->origin()); | 
|  295         SkASSERT(transforms[t].fHandle.isValid()); |  | 
|  296         const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix); |  | 
|  297         if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { |  | 
|  298             continue; |  | 
|  299         } |  | 
|  300         transforms[t].fCurrentValue = transform; |  | 
|  301         const Varying& fragmentInput = fVaryings[transforms[t].fHandle.handle()]
     ; |  | 
|  302         SkASSERT(transforms[t].fType == kVec2f_GrSLType || transforms[t].fType =
     = kVec3f_GrSLType); |  | 
|  303         unsigned components = transforms[t].fType == kVec2f_GrSLType ? 2 : 3; |  | 
|  304         fGpu->glPathRendering()->setProgramPathFragmentInputTransform(fProgramID
     , |  | 
|  305                                                                       fragmentIn
     put.fLocation, |  | 
|  306                                                                       GR_GL_OBJE
     CT_LINEAR, |  | 
|  307                                                                       components
     , |  | 
|  308                                                                       transform)
     ; |  | 
|  309     } |  | 
|  310 } |  240 } | 
|  311  |  | 
|  312 ////////////////////////////////////////////////////////////////////////////////
     ////// |  | 
|  313  |  | 
|  314 GrGLLegacyNvprProgram::GrGLLegacyNvprProgram(GrGLGpu* gpu, |  | 
|  315                                              const GrProgramDesc& desc, |  | 
|  316                                              const BuiltinUniformHandles& builti
     nUniforms, |  | 
|  317                                              GrGLuint programID, |  | 
|  318                                              const UniformInfoArray& uniforms, |  | 
|  319                                              GrGLInstalledGeoProc* primProc, |  | 
|  320                                              GrGLInstalledXferProc* xp, |  | 
|  321                                              GrGLInstalledFragProcs* fps, |  | 
|  322                                              int texCoordSetCnt) |  | 
|  323     : INHERITED(gpu, desc, builtinUniforms, programID, uniforms, primProc, xp, f
     ps) |  | 
|  324     , fTexCoordSetCnt(texCoordSetCnt) { |  | 
|  325 } |  | 
|  326  |  | 
|  327 void GrGLLegacyNvprProgram::didSetData(GrGpu::DrawType drawType) { |  | 
|  328     SkASSERT(GrGpu::IsPathRenderingDrawType(drawType)); |  | 
|  329     fGpu->glPathRendering()->flushPathTexGenSettings(fTexCoordSetCnt); |  | 
|  330 } |  | 
|  331  |  | 
|  332 void |  | 
|  333 GrGLLegacyNvprProgram::setTransformData(const GrPendingFragmentStage& proc, |  | 
|  334                                         const SkMatrix& localMatrix, |  | 
|  335                                         GrGLInstalledFragProc* ip) { |  | 
|  336     // We've hidden the texcoord index in the first entry of the transforms arra
     y for each effect |  | 
|  337     int texCoordIndex = ip->fTransforms[0].fHandle.handle(); |  | 
|  338     int numTransforms = proc.processor()->numTransforms(); |  | 
|  339     for (int t = 0; t < numTransforms; ++t) { |  | 
|  340         const SkMatrix& transform = get_transform_matrix(proc, t, localMatrix); |  | 
|  341         GrGLPathRendering::PathTexGenComponents components = |  | 
|  342                 GrGLPathRendering::kST_PathTexGenComponents; |  | 
|  343         if (proc.isPerspectiveCoordTransform(t)) { |  | 
|  344             components = GrGLPathRendering::kSTR_PathTexGenComponents; |  | 
|  345         } |  | 
|  346         fGpu->glPathRendering()->enablePathTexGen(texCoordIndex++, components, t
     ransform); |  | 
|  347     } |  | 
|  348 } |  | 
| OLD | NEW |