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), mState(), mImpl(factory->createSampler(mState)), mLabel()
20 {
21 }
22 
~Sampler()23 Sampler::~Sampler()
24 {
25     SafeDelete(mImpl);
26 }
27 
onDestroy(const Context * context)28 Error Sampler::onDestroy(const Context *context)
29 {
30     return NoError();
31 }
32 
setLabel(const std::string & label)33 void Sampler::setLabel(const std::string &label)
34 {
35     mLabel = label;
36 }
37 
getLabel() const38 const std::string &Sampler::getLabel() const
39 {
40     return mLabel;
41 }
42 
setMinFilter(GLenum minFilter)43 void Sampler::setMinFilter(GLenum minFilter)
44 {
45     mState.minFilter = minFilter;
46 }
47 
getMinFilter() const48 GLenum Sampler::getMinFilter() const
49 {
50     return mState.minFilter;
51 }
52 
setMagFilter(GLenum magFilter)53 void Sampler::setMagFilter(GLenum magFilter)
54 {
55     mState.magFilter = magFilter;
56 }
57 
getMagFilter() const58 GLenum Sampler::getMagFilter() const
59 {
60     return mState.magFilter;
61 }
62 
setWrapS(GLenum wrapS)63 void Sampler::setWrapS(GLenum wrapS)
64 {
65     mState.wrapS = wrapS;
66 }
67 
getWrapS() const68 GLenum Sampler::getWrapS() const
69 {
70     return mState.wrapS;
71 }
72 
setWrapT(GLenum wrapT)73 void Sampler::setWrapT(GLenum wrapT)
74 {
75     mState.wrapT = wrapT;
76 }
77 
getWrapT() const78 GLenum Sampler::getWrapT() const
79 {
80     return mState.wrapT;
81 }
82 
setWrapR(GLenum wrapR)83 void Sampler::setWrapR(GLenum wrapR)
84 {
85     mState.wrapR = wrapR;
86 }
87 
getWrapR() const88 GLenum Sampler::getWrapR() const
89 {
90     return mState.wrapR;
91 }
92 
setMaxAnisotropy(float maxAnisotropy)93 void Sampler::setMaxAnisotropy(float maxAnisotropy)
94 {
95     mState.maxAnisotropy = maxAnisotropy;
96 }
97 
getMaxAnisotropy() const98 float Sampler::getMaxAnisotropy() const
99 {
100     return mState.maxAnisotropy;
101 }
102 
setMinLod(GLfloat minLod)103 void Sampler::setMinLod(GLfloat minLod)
104 {
105     mState.minLod = minLod;
106 }
107 
getMinLod() const108 GLfloat Sampler::getMinLod() const
109 {
110     return mState.minLod;
111 }
112 
setMaxLod(GLfloat maxLod)113 void Sampler::setMaxLod(GLfloat maxLod)
114 {
115     mState.maxLod = maxLod;
116 }
117 
getMaxLod() const118 GLfloat Sampler::getMaxLod() const
119 {
120     return mState.maxLod;
121 }
122 
setCompareMode(GLenum compareMode)123 void Sampler::setCompareMode(GLenum compareMode)
124 {
125     mState.compareMode = compareMode;
126 }
127 
getCompareMode() const128 GLenum Sampler::getCompareMode() const
129 {
130     return mState.compareMode;
131 }
132 
setCompareFunc(GLenum compareFunc)133 void Sampler::setCompareFunc(GLenum compareFunc)
134 {
135     mState.compareFunc = compareFunc;
136 }
137 
getCompareFunc() const138 GLenum Sampler::getCompareFunc() const
139 {
140     return mState.compareFunc;
141 }
142 
setSRGBDecode(GLenum sRGBDecode)143 void Sampler::setSRGBDecode(GLenum sRGBDecode)
144 {
145     mState.sRGBDecode = sRGBDecode;
146 }
147 
getSRGBDecode() const148 GLenum Sampler::getSRGBDecode() const
149 {
150     return mState.sRGBDecode;
151 }
152 
getSamplerState() const153 const SamplerState &Sampler::getSamplerState() const
154 {
155     return mState;
156 }
157 
getImplementation() const158 rx::SamplerImpl *Sampler::getImplementation() const
159 {
160     return mImpl;
161 }
162 
syncState(const Context * context)163 void Sampler::syncState(const Context *context)
164 {
165     // TODO(jmadill): Use actual dirty bits for sampler.
166     mImpl->syncState(context);
167 }
168 
169 }  // namespace gl
170