rsSampler.h revision 1aa5a4eb81b8b88aeb5d2b6f4c47356fd0a62923
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_RS_SAMPLER_H
18#define ANDROID_RS_SAMPLER_H
19
20#include "rsAllocation.h"
21#include "RenderScript.h"
22
23// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
27const static uint32_t RS_MAX_SAMPLER_SLOT = 16;
28
29class SamplerState;
30
31class Sampler : public ObjectBase
32{
33public:
34    Sampler(RsSamplerValue magFilter,
35            RsSamplerValue minFilter,
36            RsSamplerValue wrapS,
37            RsSamplerValue wrapT,
38            RsSamplerValue wrapR);
39
40    virtual ~Sampler();
41
42    void bind(Allocation *);
43    void setupGL();
44
45    void bindToContext(SamplerState *, uint32_t slot);
46    void unbindFromContext(SamplerState *);
47
48protected:
49    RsSamplerValue mMagFilter;
50    RsSamplerValue mMinFilter;
51    RsSamplerValue mWrapS;
52    RsSamplerValue mWrapT;
53    RsSamplerValue mWrapR;
54
55    int32_t mBoundSlot;
56
57private:
58    Sampler();
59
60};
61
62
63class SamplerState
64{
65public:
66
67    RsSamplerValue mMagFilter;
68    RsSamplerValue mMinFilter;
69    RsSamplerValue mWrapS;
70    RsSamplerValue mWrapT;
71    RsSamplerValue mWrapR;
72
73
74    ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
75
76    void setupGL();
77
78};
79
80
81
82}
83}
84#endif //ANDROID_RS_SAMPLER_H
85
86
87
88