diff options
Diffstat (limited to 'libs/rs/rsSampler.cpp')
-rw-r--r-- | libs/rs/rsSampler.cpp | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp index 71f508f..c6a848c 100644 --- a/libs/rs/rsSampler.cpp +++ b/libs/rs/rsSampler.cpp @@ -14,10 +14,16 @@ * limitations under the License. */ +#ifndef ANDROID_RS_BUILD_FOR_HOST #include <GLES/gl.h> #include <GLES/glext.h> - #include "rsContext.h" +#else +#include "rsContextHostStub.h" +#include <OpenGL/gl.h> +#include <OpenGL/glext.h> +#endif //ANDROID_RS_BUILD_FOR_HOST + #include "rsSampler.h" @@ -53,7 +59,7 @@ Sampler::~Sampler() { } -void Sampler::setupGL(const Context *rsc, bool npot) +void Sampler::setupGL(const Context *rsc, const Allocation *tex) { GLenum trans[] = { GL_NEAREST, //RS_SAMPLER_NEAREST, @@ -61,25 +67,33 @@ void Sampler::setupGL(const Context *rsc, bool npot) GL_LINEAR_MIPMAP_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR, GL_REPEAT, //RS_SAMPLER_WRAP, GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP - }; - bool forceNonMip = false; - if (!rsc->ext_OES_texture_npot() && npot) { - forceNonMip = true; - } + GLenum transNP[] = { + GL_NEAREST, //RS_SAMPLER_NEAREST, + GL_LINEAR, //RS_SAMPLER_LINEAR, + GL_LINEAR, //RS_SAMPLER_LINEAR_MIP_LINEAR, + GL_CLAMP_TO_EDGE, //RS_SAMPLER_WRAP, + GL_CLAMP_TO_EDGE, //RS_SAMPLER_CLAMP + }; - if ((mMinFilter == RS_SAMPLER_LINEAR_MIP_LINEAR) && forceNonMip) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + if (!rsc->ext_OES_texture_npot() && tex->getType()->getIsNp2()) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, transNP[mMagFilter]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, transNP[mWrapS]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, transNP[mWrapT]); } else { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + if (tex->getHasGraphicsMipmaps()) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, trans[mMinFilter]); + } else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, transNP[mMinFilter]); + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, trans[mMagFilter]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, trans[mWrapS]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, trans[mWrapT]); } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, trans[mMagFilter]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, trans[mWrapS]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, trans[mWrapT]); - - rsc->checkError("ProgramFragment::setupGL2 tex env"); + rsc->checkError("Sampler::setupGL2 tex env"); } void Sampler::bindToContext(SamplerState *ss, uint32_t slot) @@ -94,6 +108,17 @@ void Sampler::unbindFromContext(SamplerState *ss) mBoundSlot = -1; ss->mSamplers[slot].clear(); } + +void Sampler::serialize(OStream *stream) const +{ + +} + +Sampler *Sampler::createFromStream(Context *rsc, IStream *stream) +{ + return NULL; +} + /* void SamplerState::setupGL() { |