egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 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 | |
| 8 | #include "gl/GrGLVaryingHandler.h" |
| 9 | |
| 10 | #include "gl/GrGLGpu.h" |
| 11 | #include "gl/builders/GrGLProgramBuilder.h" |
| 12 | |
| 13 | |
| 14 | GrGLSLVaryingHandler::VaryingHandle GrGLVaryingHandler::addPathProcessingVarying( |
| 15 | const char* name, |
Chris Dalton | 2737288 | 2017-12-08 13:34:21 -0700 | [diff] [blame] | 16 | GrGLSLVarying* v) { |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 17 | #ifdef SK_DEBUG |
| 18 | GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder; |
| 19 | // This call is not used for non-NVPR backends. |
| 20 | SkASSERT(glPB->gpu()->glCaps().shaderCaps()->pathRenderingSupport() && |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 21 | glPB->fPrimProc.isPathRendering() && |
| 22 | !glPB->fPrimProc.willUseGeoShader() && |
Brian Salomon | 92be2f7 | 2018-06-19 14:33:47 -0400 | [diff] [blame] | 23 | !glPB->fPrimProc.numVertexAttributes() && |
| 24 | !glPB->fPrimProc.numInstanceAttributes()); |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 25 | #endif |
Chris Dalton | fdde34e | 2017-10-16 14:15:26 -0600 | [diff] [blame] | 26 | this->addVarying(name, v); |
cdalton | c08f196 | 2016-02-12 12:14:06 -0800 | [diff] [blame] | 27 | auto varyingInfo = fPathProcVaryingInfos.push_back(); |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 28 | varyingInfo.fLocation = fPathProcVaryingInfos.count() - 1; |
| 29 | return VaryingHandle(varyingInfo.fLocation); |
| 30 | } |
cdalton | c08f196 | 2016-02-12 12:14:06 -0800 | [diff] [blame] | 31 | |
| 32 | void GrGLVaryingHandler::onFinalize() { |
| 33 | SkASSERT(fPathProcVaryingInfos.empty() || fPathProcVaryingInfos.count() == fFragInputs.count()); |
| 34 | for (int i = 0; i < fPathProcVaryingInfos.count(); ++i) { |
| 35 | fPathProcVaryingInfos[i].fVariable = fFragInputs[i]; |
| 36 | } |
| 37 | } |