GrGLVaryingHandler.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "src/gpu/gl/GrGLVaryingHandler.h"
  8. #include "src/gpu/gl/GrGLGpu.h"
  9. #include "src/gpu/gl/builders/GrGLProgramBuilder.h"
  10. GrGLSLVaryingHandler::VaryingHandle GrGLVaryingHandler::addPathProcessingVarying(
  11. const char* name,
  12. GrGLSLVarying* v) {
  13. #ifdef SK_DEBUG
  14. GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder;
  15. // This call is not used for non-NVPR backends.
  16. SkASSERT(glPB->gpu()->glCaps().shaderCaps()->pathRenderingSupport() &&
  17. glPB->fPrimProc.isPathRendering() &&
  18. !glPB->fPrimProc.willUseGeoShader() &&
  19. !glPB->fPrimProc.numVertexAttributes() &&
  20. !glPB->fPrimProc.numInstanceAttributes());
  21. #endif
  22. this->addVarying(name, v);
  23. auto varyingInfo = fPathProcVaryingInfos.push_back();
  24. varyingInfo.fLocation = fPathProcVaryingInfos.count() - 1;
  25. return VaryingHandle(varyingInfo.fLocation);
  26. }
  27. void GrGLVaryingHandler::onFinalize() {
  28. SkASSERT(fPathProcVaryingInfos.empty() || fPathProcVaryingInfos.count() == fFragInputs.count());
  29. for (int i = 0; i < fPathProcVaryingInfos.count(); ++i) {
  30. fPathProcVaryingInfos[i].fVariable = fFragInputs[i];
  31. }
  32. }