blob: 1f67ac9a5e8c0320e6e95c80d04b3911541b8b9f [file] [log] [blame]
egdaniel09aa1fc2016-04-20 07:09:46 -07001/*
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
16class GrGLSampler : public GrGLSLSampler {
17public:
18 GrGLSampler(uint32_t visibility,
19 GrPixelConfig config,
20 GrSLType type,
21 GrSLPrecision precision,
22 const char* name) : INHERITED(visibility, config) {
egdaniel990dbc82016-07-13 14:09:30 -070023 SkASSERT(GrSLTypeIsCombinedSamplerType(type));
egdaniel09aa1fc2016-04-20 07:09:46 -070024 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
36private:
37 GrGLSLShaderVar fShaderVar;
38 GrGLint fLocation;
39
40 friend class GrGLUniformHandler;
41
42 typedef GrGLSLSampler INHERITED;
43};
44
45#endif