1 //
2 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // Sampler.cpp : Implements the Sampler class, which represents a GLES 3
8 // sampler object. Sampler objects store some state needed to sample textures.
9 
10 #include "libANGLE/Sampler.h"
11 #include "libANGLE/angletypes.h"
12 #include "libANGLE/renderer/GLImplFactory.h"
13 #include "libANGLE/renderer/SamplerImpl.h"
14 
15 namespace gl
16 {
17 
Sampler(rx::GLImplFactory * factory,GLuint id)18 Sampler::Sampler(rx::GLImplFactory *factory, GLuint id)
19     : RefCountObject(id), mImpl(factory->createSampler()), mLabel(), mSamplerState()
20 {
21 }
22 
~Sampler()23 Sampler::~Sampler()
24 {
25     SafeDelete(mImpl);
26 }
27 
setLabel(const std::string & label)28 void Sampler::setLabel(const std::string &label)
29 {
30     mLabel = label;
31 }
32 
getLabel() const33 const std::string &Sampler::getLabel() const
34 {
35     return mLabel;
36 }
37 
setMinFilter(GLenum minFilter)38 void Sampler::setMinFilter(GLenum minFilter)
39 {
40     mSamplerState.minFilter = minFilter;
41 }
42 
getMinFilter() const43 GLenum Sampler::getMinFilter() const
44 {
45     return mSamplerState.minFilter;
46 }
47 
setMagFilter(GLenum magFilter)48 void Sampler::setMagFilter(GLenum magFilter)
49 {
50     mSamplerState.magFilter = magFilter;
51 }
52 
getMagFilter() const53 GLenum Sampler::getMagFilter() const
54 {
55     return mSamplerState.magFilter;
56 }
57 
setWrapS(GLenum wrapS)58 void Sampler::setWrapS(GLenum wrapS)
59 {
60     mSamplerState.wrapS = wrapS;
61 }
62 
getWrapS() const63 GLenum Sampler::getWrapS() const
64 {
65     return mSamplerState.wrapS;
66 }
67 
setWrapT(GLenum wrapT)68 void Sampler::setWrapT(GLenum wrapT)
69 {
70     mSamplerState.wrapT = wrapT;
71 }
72 
getWrapT() const73 GLenum Sampler::getWrapT() const
74 {
75     return mSamplerState.wrapT;
76 }
77 
setWrapR(GLenum wrapR)78 void Sampler::setWrapR(GLenum wrapR)
79 {
80     mSamplerState.wrapR = wrapR;
81 }
82 
getWrapR() const83 GLenum Sampler::getWrapR() const
84 {
85     return mSamplerState.wrapR;
86 }
87 
setMaxAnisotropy(float maxAnisotropy)88 void Sampler::setMaxAnisotropy(float maxAnisotropy)
89 {
90     mSamplerState.maxAnisotropy = maxAnisotropy;
91 }
92 
getMaxAnisotropy() const93 float Sampler::getMaxAnisotropy() const
94 {
95     return mSamplerState.maxAnisotropy;
96 }
97 
setMinLod(GLfloat minLod)98 void Sampler::setMinLod(GLfloat minLod)
99 {
100     mSamplerState.minLod = minLod;
101 }
102 
getMinLod() const103 GLfloat Sampler::getMinLod() const
104 {
105     return mSamplerState.minLod;
106 }
107 
setMaxLod(GLfloat maxLod)108 void Sampler::setMaxLod(GLfloat maxLod)
109 {
110     mSamplerState.maxLod = maxLod;
111 }
112 
getMaxLod() const113 GLfloat Sampler::getMaxLod() const
114 {
115     return mSamplerState.maxLod;
116 }
117 
setCompareMode(GLenum compareMode)118 void Sampler::setCompareMode(GLenum compareMode)
119 {
120     mSamplerState.compareMode = compareMode;
121 }
122 
getCompareMode() const123 GLenum Sampler::getCompareMode() const
124 {
125     return mSamplerState.compareMode;
126 }
127 
setCompareFunc(GLenum compareFunc)128 void Sampler::setCompareFunc(GLenum compareFunc)
129 {
130     mSamplerState.compareFunc = compareFunc;
131 }
132 
getCompareFunc() const133 GLenum Sampler::getCompareFunc() const
134 {
135     return mSamplerState.compareFunc;
136 }
137 
setSRGBDecode(GLenum sRGBDecode)138 void Sampler::setSRGBDecode(GLenum sRGBDecode)
139 {
140     mSamplerState.sRGBDecode = sRGBDecode;
141 }
142 
getSRGBDecode() const143 GLenum Sampler::getSRGBDecode() const
144 {
145     return mSamplerState.sRGBDecode;
146 }
147 
getSamplerState() const148 const SamplerState &Sampler::getSamplerState() const
149 {
150     return mSamplerState;
151 }
152 
getImplementation() const153 rx::SamplerImpl *Sampler::getImplementation() const
154 {
155     return mImpl;
156 }
157 
158 }
159