aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLSampler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/gl/GrGLSampler.h')
-rw-r--r--src/gpu/gl/GrGLSampler.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/gpu/gl/GrGLSampler.h b/src/gpu/gl/GrGLSampler.h
new file mode 100644
index 0000000000..e270f5deac
--- /dev/null
+++ b/src/gpu/gl/GrGLSampler.h
@@ -0,0 +1,45 @@
+/*
+* Copyright 2016 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
+
+#ifndef GrGLSampler_DEFINED
+#define GrGLSampler_DEFINED
+
+#include "glsl/GrGLSLSampler.h"
+
+#include "gl/GrGLTypes.h"
+#include "glsl/GrGLSLShaderVar.h"
+
+class GrGLSampler : public GrGLSLSampler {
+public:
+ GrGLSampler(uint32_t visibility,
+ GrPixelConfig config,
+ GrSLType type,
+ GrSLPrecision precision,
+ const char* name) : INHERITED(visibility, config) {
+ SkASSERT(GrSLTypeIsSamplerType(type));
+ fShaderVar.setType(type);
+ fShaderVar.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
+ fShaderVar.setPrecision(precision);
+ fShaderVar.accessName()->set(name);
+ }
+
+ GrGLint location() const { return fLocation; }
+ GrSLType type() const override { return fShaderVar.getType(); }
+
+ const char* onGetSamplerNameForTexture2D() const override { return fShaderVar.c_str(); }
+ const char* getSamplerNameForTexelFetch() const override { return fShaderVar.c_str(); }
+
+private:
+ GrGLSLShaderVar fShaderVar;
+ GrGLint fLocation;
+
+ friend class GrGLUniformHandler;
+
+ typedef GrGLSLSampler INHERITED;
+};
+
+#endif