aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLTextureSampler.h
blob: a4fbf550f25039dad0ed20d013b6a86abe8b0551 (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
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef GrGLSLTextureSampler_DEFINED
#define GrGLSLTextureSampler_DEFINED

#include "GrShaderVar.h"
#include "GrTextureAccess.h"
#include "glsl/GrGLSLProgramDataManager.h"

class GrGLSLTextureSampler {
public:
    typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
    typedef SkTArray<GrGLSLTextureSampler> TextureSamplerArray;

    GrGLSLTextureSampler(UniformHandle uniform, const GrTextureAccess& access)
        : fSamplerUniform(uniform)
        , fConfig(access.getTexture()->config()) {
        SkASSERT(kUnknown_GrPixelConfig != fConfig);
        memcpy(fSwizzle, access.getSwizzle(), 5);
    }

    GrPixelConfig config() const { return fConfig; }
    // this is .abcd
    const char* swizzle() const { return fSwizzle; }

private:
    UniformHandle fSamplerUniform;
    GrPixelConfig fConfig;
    char          fSwizzle[5];

    friend class GrGLSLShaderBuilder;
};

#endif