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 "src/gpu/gl/GrGLVaryingHandler.h"
9
10#include "src/gpu/gl/GrGLGpu.h"
11#include "src/gpu/gl/builders/GrGLProgramBuilder.h"
12
13
14GrGLSLVaryingHandler::VaryingHandle GrGLVaryingHandler::addPathProcessingVarying(
15 const char* name,
16 GrGLSLVarying* v) {
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() &&
21 fProgramBuilder->fProgramInfo.isNVPR());
22#endif
23 this->addVarying(name, v);
24 auto varyingInfo = fPathProcVaryingInfos.push_back();
25 varyingInfo.fLocation = fPathProcVaryingInfos.count() - 1;
26 return VaryingHandle(varyingInfo.fLocation);
27}
28
29void GrGLVaryingHandler::onFinalize() {
30 SkASSERT(fPathProcVaryingInfos.empty() || fPathProcVaryingInfos.count() == fFragInputs.count());
31 VarArray::Iter::Item fragInputIter = fFragInputs.items().begin();
32 for (auto& varyingInfo : fPathProcVaryingInfos.items()) {
33 varyingInfo.fVariable = *fragInputIter;
34 ++fragInputIter;
35 }
36}
37