• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 Google LLC
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/ganesh/glsl/GrGLSLUniformHandler.h"
9 
10 #include "src/gpu/ganesh/glsl/GrGLSLShaderBuilder.h"
11 
getUniformMapping(const GrProcessor & owner,SkString rawName) const12 GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrProcessor& owner,
13                                                     SkString rawName) const {
14     for (int i = this->numUniforms() - 1; i >= 0; i--) {
15         const UniformInfo& u = this->uniform(i);
16         if (u.fOwner == &owner && u.fRawName == rawName) {
17             return u.fVariable;
18         }
19     }
20     return GrShaderVar();
21 }
22 
liftUniformToVertexShader(const GrProcessor & owner,SkString rawName)23 GrShaderVar GrGLSLUniformHandler::liftUniformToVertexShader(const GrProcessor& owner,
24                                                             SkString rawName) {
25     for (int i = this->numUniforms() - 1; i >= 0; i--) {
26         UniformInfo& u = this->uniform(i);
27         if (u.fOwner == &owner && u.fRawName == rawName) {
28             u.fVisibility |= kVertex_GrShaderFlag;
29             return u.fVariable;
30         }
31     }
32     // Uniform not found; it's better to return a void variable than to assert because sample
33     // matrices that are uniform are treated the same for most of the code. When the sample
34     // matrix expression can't be found as a uniform, we can infer it's a constant.
35     return GrShaderVar();
36 }
37