blob: 90b6082c139d62c0085583c0fadccd512dafa1b2 [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
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080031class Sampler : public ObjectBase {
Jason Sams326e0dd2009-05-22 14:03:28 -070032public:
Jason Samse514b452009-09-25 14:51:22 -070033 Sampler(Context *,
34 RsSamplerValue magFilter,
Jason Sams326e0dd2009-05-22 14:03:28 -070035 RsSamplerValue minFilter,
36 RsSamplerValue wrapS,
37 RsSamplerValue wrapT,
Alex Sakhartchouk1103d8e2010-09-30 11:36:37 -070038 RsSamplerValue wrapR,
39 float aniso = 1.0f);
Jason Sams326e0dd2009-05-22 14:03:28 -070040
41 virtual ~Sampler();
42
Jason Sams326e0dd2009-05-22 14:03:28 -070043 void bindToContext(SamplerState *, uint32_t slot);
44 void unbindFromContext(SamplerState *);
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070045
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070046 virtual void serialize(OStream *stream) const;
Alex Sakhartchoukb825f672010-06-04 10:06:50 -070047 virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
Alex Sakhartchoukfb6b6142010-05-21 12:53:13 -070048 static Sampler *createFromStream(Context *rsc, IStream *stream);
Jason Sams326e0dd2009-05-22 14:03:28 -070049
Alex Sakhartchoukc2c02a82011-05-04 17:45:36 -070050 struct Hal {
51 mutable void *drv;
Jason Sams326e0dd2009-05-22 14:03:28 -070052
Alex Sakhartchoukc2c02a82011-05-04 17:45:36 -070053 struct State {
54 RsSamplerValue magFilter;
55 RsSamplerValue minFilter;
56 RsSamplerValue wrapS;
57 RsSamplerValue wrapT;
58 RsSamplerValue wrapR;
59 float aniso;
60 };
61 State state;
62 };
63 Hal mHal;
64
65protected:
Jason Sams326e0dd2009-05-22 14:03:28 -070066 int32_t mBoundSlot;
67
68private:
Jason Samse514b452009-09-25 14:51:22 -070069 Sampler(Context *);
Jason Sams326e0dd2009-05-22 14:03:28 -070070};
71
72
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080073class SamplerState {
Jason Sams326e0dd2009-05-22 14:03:28 -070074public:
Jason Sams326e0dd2009-05-22 14:03:28 -070075 ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT];
Jason Sams326e0dd2009-05-22 14:03:28 -070076};
77
Jason Sams326e0dd2009-05-22 14:03:28 -070078}
79}
80#endif //ANDROID_RS_SAMPLER_H
81
82
83