2009-05-22 14:03:28 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2011-01-31 14:53:24 -08:00
|
|
|
#include "rsContext.h"
|
2009-05-22 14:03:28 -07:00
|
|
|
#include "rsSampler.h"
|
|
|
|
|
2009-06-22 17:15:15 -07:00
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
using namespace android;
|
|
|
|
using namespace android::renderscript;
|
|
|
|
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
Sampler::Sampler(Context *rsc) : ObjectBase(rsc) {
|
2009-05-22 14:03:28 -07:00
|
|
|
// Should not get called.
|
|
|
|
rsAssert(0);
|
|
|
|
}
|
|
|
|
|
2009-09-25 14:51:22 -07:00
|
|
|
Sampler::Sampler(Context *rsc,
|
|
|
|
RsSamplerValue magFilter,
|
2009-05-22 14:03:28 -07:00
|
|
|
RsSamplerValue minFilter,
|
|
|
|
RsSamplerValue wrapS,
|
|
|
|
RsSamplerValue wrapT,
|
2010-09-30 11:36:37 -07:00
|
|
|
RsSamplerValue wrapR,
|
2010-11-09 17:00:54 -08:00
|
|
|
float aniso) : ObjectBase(rsc) {
|
2011-05-04 17:45:36 -07:00
|
|
|
mHal.state.magFilter = magFilter;
|
|
|
|
mHal.state.minFilter = minFilter;
|
|
|
|
mHal.state.wrapS = wrapS;
|
|
|
|
mHal.state.wrapT = wrapT;
|
|
|
|
mHal.state.wrapR = wrapR;
|
|
|
|
mHal.state.aniso = aniso;
|
2009-05-22 14:03:28 -07:00
|
|
|
|
2011-05-05 16:56:27 -07:00
|
|
|
mRSC->mHal.funcs.sampler.init(mRSC, this);
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
2011-05-05 16:56:27 -07:00
|
|
|
Sampler::~Sampler() {
|
|
|
|
mRSC->mHal.funcs.sampler.destroy(mRSC, this);
|
2009-05-22 14:03:28 -07:00
|
|
|
}
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
void Sampler::bindToContext(SamplerState *ss, uint32_t slot) {
|
2009-05-22 14:03:28 -07:00
|
|
|
ss->mSamplers[slot].set(this);
|
|
|
|
mBoundSlot = slot;
|
|
|
|
}
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
void Sampler::unbindFromContext(SamplerState *ss) {
|
2009-05-22 14:03:28 -07:00
|
|
|
int32_t slot = mBoundSlot;
|
|
|
|
mBoundSlot = -1;
|
|
|
|
ss->mSamplers[slot].clear();
|
|
|
|
}
|
2010-05-21 12:53:13 -07:00
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
void Sampler::serialize(OStream *stream) const {
|
2010-05-21 12:53:13 -07:00
|
|
|
}
|
|
|
|
|
2010-11-09 17:00:54 -08:00
|
|
|
Sampler *Sampler::createFromStream(Context *rsc, IStream *stream) {
|
2010-05-21 12:53:13 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-05-22 14:03:28 -07:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
namespace renderscript {
|
|
|
|
|
2011-05-04 17:45:36 -07:00
|
|
|
RsSampler rsi_SamplerCreate(Context * rsc,
|
|
|
|
RsSamplerValue magFilter,
|
|
|
|
RsSamplerValue minFilter,
|
|
|
|
RsSamplerValue wrapS,
|
|
|
|
RsSamplerValue wrapT,
|
|
|
|
RsSamplerValue wrapR,
|
|
|
|
float aniso) {
|
|
|
|
Sampler * s = new Sampler(rsc, magFilter, minFilter, wrapS, wrapT, wrapR, aniso);
|
2009-08-27 20:23:34 -07:00
|
|
|
s->incUserRef();
|
2009-05-22 14:03:28 -07:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|