Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 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 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 20 | #include "rsAllocation.h" |
| 21 | #include "RenderScript.h" |
| 22 | |
| 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
| 27 | const static uint32_t RS_MAX_SAMPLER_SLOT = 16; |
| 28 | |
| 29 | class SamplerState; |
| 30 | |
| 31 | class Sampler : public ObjectBase |
| 32 | { |
| 33 | public: |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 34 | Sampler(Context *, |
| 35 | RsSamplerValue magFilter, |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 36 | RsSamplerValue minFilter, |
| 37 | RsSamplerValue wrapS, |
| 38 | RsSamplerValue wrapT, |
| 39 | RsSamplerValue wrapR); |
| 40 | |
| 41 | virtual ~Sampler(); |
| 42 | |
| 43 | void bind(Allocation *); |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 44 | void setupGL(const Context *, bool npot); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 45 | |
| 46 | void bindToContext(SamplerState *, uint32_t slot); |
| 47 | void unbindFromContext(SamplerState *); |
| 48 | |
| 49 | protected: |
| 50 | RsSamplerValue mMagFilter; |
| 51 | RsSamplerValue mMinFilter; |
| 52 | RsSamplerValue mWrapS; |
| 53 | RsSamplerValue mWrapT; |
| 54 | RsSamplerValue mWrapR; |
| 55 | |
| 56 | int32_t mBoundSlot; |
| 57 | |
| 58 | private: |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 59 | Sampler(Context *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 60 | |
| 61 | }; |
| 62 | |
| 63 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 64 | class SamplerState |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 65 | { |
| 66 | public: |
| 67 | |
| 68 | RsSamplerValue mMagFilter; |
| 69 | RsSamplerValue mMinFilter; |
| 70 | RsSamplerValue mWrapS; |
| 71 | RsSamplerValue mWrapT; |
| 72 | RsSamplerValue mWrapR; |
| 73 | |
| 74 | |
| 75 | ObjectBaseRef<Sampler> mSamplers[RS_MAX_SAMPLER_SLOT]; |
| 76 | |
Jason Sams | 5dbfe93 | 2010-01-27 14:41:43 -0800 | [diff] [blame] | 77 | //void setupGL(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 78 | |
| 79 | }; |
| 80 | |
| 81 | |
| 82 | |
| 83 | } |
| 84 | } |
| 85 | #endif //ANDROID_RS_SAMPLER_H |
| 86 | |
| 87 | |
| 88 | |