Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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_FRAME_BUFFER_OBJECT_CACHE_H |
| 18 | #define ANDROID_FRAME_BUFFER_OBJECT_CACHE_H |
| 19 | |
| 20 | #include "rsObjectBase.h" |
| 21 | |
| 22 | // --------------------------------------------------------------------------- |
| 23 | namespace android { |
| 24 | namespace renderscript { |
| 25 | |
| 26 | class Allocation; |
| 27 | |
| 28 | class FBOCache { |
| 29 | public: |
| 30 | FBOCache(); |
| 31 | ~FBOCache(); |
| 32 | |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 33 | void init(Context *rsc); |
| 34 | void deinit(Context *rsc); |
| 35 | |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 36 | void bindColorTarget(Context *rsc, Allocation *a, uint32_t slot); |
| 37 | void bindDepthTarget(Context *, Allocation *a); |
| 38 | void resetAll(Context *); |
| 39 | |
Alex Sakhartchouk | c19ff01 | 2011-05-06 14:59:45 -0700 | [diff] [blame] | 40 | void setup(Context *); |
Alex Sakhartchouk | a544b63 | 2011-07-19 17:50:29 -0700 | [diff] [blame] | 41 | void updateSize() { mDirty = true; } |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 42 | |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 43 | struct Hal { |
| 44 | mutable void *drv; |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 45 | |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 46 | struct State { |
Alex Sakhartchouk | 064aa7e | 2011-10-18 10:54:29 -0700 | [diff] [blame] | 47 | Allocation **colorTargets; |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 48 | uint32_t colorTargetsCount; |
Alex Sakhartchouk | 064aa7e | 2011-10-18 10:54:29 -0700 | [diff] [blame] | 49 | Allocation *depthTarget; |
Alex Sakhartchouk | da6d34a | 2011-05-13 14:53:34 -0700 | [diff] [blame] | 50 | }; |
| 51 | State state; |
| 52 | }; |
| 53 | Hal mHal; |
| 54 | |
| 55 | protected: |
Alex Sakhartchouk | 064aa7e | 2011-10-18 10:54:29 -0700 | [diff] [blame] | 56 | ObjectBaseRef<Allocation> *mColorTargets; |
| 57 | ObjectBaseRef<Allocation> mDepthTarget; |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 58 | bool mDirty; |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 59 | void checkError(Context *); |
| 60 | void setColorAttachment(Context *rsc); |
| 61 | void setDepthAttachment(Context *rsc); |
| 62 | bool renderToFramebuffer(); |
Alex Sakhartchouk | 7d9c5ff | 2011-04-01 14:19:01 -0700 | [diff] [blame] | 63 | |
| 64 | }; |
| 65 | |
| 66 | } // renderscript |
| 67 | } // android |
| 68 | |
| 69 | #endif //ANDROID_FRAME_BUFFER_OBJECT_CACHE_H |