blob: 950fe3c9d4eece56394bc43cb89e703381876f74 [file] [log] [blame]
egdaniel0eafe792015-11-20 14:01:22 -08001/*
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
14GrGLSLVaryingHandler::VaryingHandle GrGLVaryingHandler::addPathProcessingVarying(
15 const char* name,
Chris Daltonfdde34e2017-10-16 14:15:26 -060016 GrGLSLVertToFrag* v) {
egdaniel0eafe792015-11-20 14:01:22 -080017#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() &&
egdaniel0e1853c2016-03-17 11:35:45 -070021 glPB->fPrimProc.isPathRendering() &&
22 !glPB->fPrimProc.willUseGeoShader() &&
23 glPB->fPrimProc.numAttribs() == 0);
egdaniel0eafe792015-11-20 14:01:22 -080024#endif
Chris Daltonfdde34e2017-10-16 14:15:26 -060025 this->addVarying(name, v);
cdaltonc08f1962016-02-12 12:14:06 -080026 auto varyingInfo = fPathProcVaryingInfos.push_back();
egdaniel0eafe792015-11-20 14:01:22 -080027 varyingInfo.fLocation = fPathProcVaryingInfos.count() - 1;
28 return VaryingHandle(varyingInfo.fLocation);
29}
cdaltonc08f1962016-02-12 12:14:06 -080030
31void GrGLVaryingHandler::onFinalize() {
32 SkASSERT(fPathProcVaryingInfos.empty() || fPathProcVaryingInfos.count() == fFragInputs.count());
33 for (int i = 0; i < fPathProcVaryingInfos.count(); ++i) {
34 fPathProcVaryingInfos[i].fVariable = fFragInputs[i];
35 }
36}