blob: 49463559427982bfb7b0e85929733f3ea4f9855d [file] [log] [blame]
Jason Sams326e0dd2009-05-22 14:03:28 -07001/*
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
Jason Sams326e0dd2009-05-22 14:03:28 -070020#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:
Jason Samse514b452009-09-25 14:51:22 -070034 Sampler(Context *,
35 RsSamplerValue magFilter,
Jason Sams326e0dd2009-05-22 14:03:28 -070036 RsSamplerValue minFilter,
37 RsSamplerValue wrapS,
38 RsSamplerValue wrapT,
Alex Sakhartchouk1103d8e2010-09-30 11:36:37 -070039 RsSamplerValue wrapR,
40 float aniso = 1.0f);
Jason Sams326e0dd2009-05-22 14:03:28 -070041
42 virtual ~Sampler();
43
44 void bind(Allocation *);
Jason Sams900f1612010-09-16 18:18:29 -070045 void setupGL(const Context *, const Allocation *);
Jason Sams326e0dd2009-05-22 14:03:28 -070046
47 void bindToContext(SamplerState *, uint32_t slot);
48 void unbindFromContext(SamplerState *);
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070049
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070050 virtual void serialize(OStream *stream) const;
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070051 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070052 static Sampler *createFromStream(Context *rsc, IStream *stream);
Jason Sams326e0dd2009-05-22 14:03:28 -070053
54protected:
55 RsSamplerValue mMagFilter;
56 RsSamplerValue mMinFilter;
57 RsSamplerValue mWrapS;
58 RsSamplerValue mWrapT;
59 RsSamplerValue mWrapR;
Alex Sakhartchouk1103d8e2010-09-30 11:36:37 -070060 float mAniso;
Jason Sams326e0dd2009-05-22 14:03:28 -070061
62 int32_t mBoundSlot;
63
64private:
Jason Samse514b452009-09-25 14:51:22 -070065 Sampler(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070066
67};
68
69
Jason Samse514b452009-09-25 14:51:22 -070070class SamplerState
Jason Sams326e0dd2009-05-22 14:03:28 -070071{
72public:
73
74 RsSamplerValue mMagFilter;
75 RsSamplerValue mMinFilter;
76 RsSamplerValue mWrapS;
77 RsSamplerValue mWrapT;
78 RsSamplerValue mWrapR;
Alex Sakhartchouk1103d8e2010-09-30 11:36:37 -070079 float mAniso;
Jason Sams326e0dd2009-05-22 14:03:28 -070080
81
82 ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
83
Jason Sams3eb28f02010-01-27 14:41:43 -080084 //void setupGL();
Jason Sams326e0dd2009-05-22 14:03:28 -070085
86};
87
88
89
90}
91}
92#endif //ANDROID_RS_SAMPLER_H
93
94
95