summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/gpu/gl/GrGLSampler.h
blob: 1f67ac9a5e8c0320e6e95c80d04b3911541b8b9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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(GrSLTypeIsCombinedSamplerType(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