egdaniel | 09aa1fc | 2016-04-20 07:09:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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 | #ifndef GrGLSampler_DEFINED |
| 9 | #define GrGLSampler_DEFINED |
| 10 | |
| 11 | #include "glsl/GrGLSLSampler.h" |
| 12 | |
| 13 | #include "gl/GrGLTypes.h" |
| 14 | #include "glsl/GrGLSLShaderVar.h" |
| 15 | |
| 16 | class GrGLSampler : public GrGLSLSampler { |
| 17 | public: |
| 18 | GrGLSampler(uint32_t visibility, |
| 19 | GrPixelConfig config, |
| 20 | GrSLType type, |
| 21 | GrSLPrecision precision, |
| 22 | const char* name) : INHERITED(visibility, config) { |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame] | 23 | SkASSERT(GrSLTypeIsCombinedSamplerType(type)); |
egdaniel | 09aa1fc | 2016-04-20 07:09:46 -0700 | [diff] [blame] | 24 | fShaderVar.setType(type); |
| 25 | fShaderVar.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier); |
| 26 | fShaderVar.setPrecision(precision); |
| 27 | fShaderVar.accessName()->set(name); |
| 28 | } |
| 29 | |
| 30 | GrGLint location() const { return fLocation; } |
| 31 | GrSLType type() const override { return fShaderVar.getType(); } |
| 32 | |
| 33 | const char* onGetSamplerNameForTexture2D() const override { return fShaderVar.c_str(); } |
| 34 | const char* getSamplerNameForTexelFetch() const override { return fShaderVar.c_str(); } |
| 35 | |
| 36 | private: |
| 37 | GrGLSLShaderVar fShaderVar; |
| 38 | GrGLint fLocation; |
| 39 | |
| 40 | friend class GrGLUniformHandler; |
| 41 | |
| 42 | typedef GrGLSLSampler INHERITED; |
| 43 | }; |
| 44 | |
| 45 | #endif |