OLD | NEW |
| (Empty) |
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 "GrGLPathProgramBuilder.h" | |
9 #include "gl/GrGLGpu.h" | |
10 #include "gl/GrGLPathProgram.h" | |
11 | |
12 #define GL_CALL(X) GR_GL_CALL(this->gpu()->glInterface(), X) | |
13 #define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->gpu()->glInterface(), R, X) | |
14 | |
15 GrGLPathProgramBuilder::GrGLPathProgramBuilder(GrGLGpu* gpu, const DrawArgs& arg
s) | |
16 : INHERITED(gpu, args) | |
17 , fSeparableVaryingInfos(kVarsPerBlock) { | |
18 } | |
19 | |
20 GrGLProgram* GrGLPathProgramBuilder::createProgram(GrGLuint programID) { | |
21 return new GrGLPathProgram(fGpu, this->desc(), fUniformHandles, programID, f
Uniforms, | |
22 fSeparableVaryingInfos, fGeometryProcessor, fXfer
Processor, | |
23 fFragmentProcessors.get(), &fSamplerUniforms); | |
24 } | |
25 | |
26 GrGLProgramBuilder::SeparableVaryingHandle GrGLPathProgramBuilder::addSeparableV
arying( | |
27 const char* name, GrGLVertToFrag* v, GrSLPrecision fsPrecision) { | |
28 this->addVarying(name, v, fsPrecision); | |
29 SeparableVaryingInfo& varyingInfo = fSeparableVaryingInfos.push_back(); | |
30 varyingInfo.fVariable = this->getFragmentShaderBuilder()->fInputs.back(); | |
31 varyingInfo.fLocation = fSeparableVaryingInfos.count() - 1; | |
32 return SeparableVaryingHandle(varyingInfo.fLocation); | |
33 } | |
34 | |
35 void GrGLPathProgramBuilder::bindProgramResourceLocations(GrGLuint programID) { | |
36 this->INHERITED::bindProgramResourceLocations(programID); | |
37 if (!fGpu->glPathRendering()->shouldBindFragmentInputs()) { | |
38 return; | |
39 } | |
40 int count = fSeparableVaryingInfos.count(); | |
41 for (int i = 0; i < count; ++i) { | |
42 GL_CALL(BindFragmentInputLocation(programID, | |
43 i, | |
44 fSeparableVaryingInfos[i].fVariable.c_
str())); | |
45 fSeparableVaryingInfos[i].fLocation = i; | |
46 } | |
47 } | |
48 | |
49 void GrGLPathProgramBuilder::resolveProgramResourceLocations(GrGLuint programID)
{ | |
50 this->INHERITED::resolveProgramResourceLocations(programID); | |
51 if (fGpu->glPathRendering()->shouldBindFragmentInputs()) { | |
52 return; | |
53 } | |
54 int count = fSeparableVaryingInfos.count(); | |
55 for (int i = 0; i < count; ++i) { | |
56 GrGLint location; | |
57 GL_CALL_RET(location, | |
58 GetProgramResourceLocation(programID, | |
59 GR_GL_FRAGMENT_INPUT, | |
60 fSeparableVaryingInfos[i].fVariab
le.c_str())); | |
61 fSeparableVaryingInfos[i].fLocation = location; | |
62 } | |
63 } | |
OLD | NEW |