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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/gl/GrGLVaryingHandler.h" |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "src/gpu/gl/GrGLGpu.h" |
| 11 | #include "src/gpu/gl/builders/GrGLProgramBuilder.h" |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 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() && |
Robert Phillips | 901aff0 | 2019-10-08 12:32:56 -0400 | [diff] [blame] | 21 | fProgramBuilder->fProgramInfo.isNVPR()); |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 22 | #endif |
Chris Dalton | fdde34e | 2017-10-16 14:15:26 -0600 | [diff] [blame] | 23 | this->addVarying(name, v); |
cdalton | c08f196 | 2016-02-12 12:14:06 -0800 | [diff] [blame] | 24 | auto varyingInfo = fPathProcVaryingInfos.push_back(); |
egdaniel | 0eafe79 | 2015-11-20 14:01:22 -0800 | [diff] [blame] | 25 | varyingInfo.fLocation = fPathProcVaryingInfos.count() - 1; |
| 26 | return VaryingHandle(varyingInfo.fLocation); |
| 27 | } |
cdalton | c08f196 | 2016-02-12 12:14:06 -0800 | [diff] [blame] | 28 | |
| 29 | void GrGLVaryingHandler::onFinalize() { |
| 30 | SkASSERT(fPathProcVaryingInfos.empty() || fPathProcVaryingInfos.count() == fFragInputs.count()); |
Michael Ludwig | 4519134 | 2020-03-24 12:29:39 -0400 | [diff] [blame] | 31 | VarArray::Iter::Item fragInputIter = fFragInputs.items().begin(); |
| 32 | for (auto& varyingInfo : fPathProcVaryingInfos.items()) { |
| 33 | varyingInfo.fVariable = *fragInputIter; |
| 34 | ++fragInputIter; |
cdalton | c08f196 | 2016-02-12 12:14:06 -0800 | [diff] [blame] | 35 | } |
| 36 | } |