blob: abb84de0c83fd78f69a31a3d8d56729a176e25f5 [file] [log] [blame]
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -07001/*
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// ---------------------------------------------------------------------------
23namespace android {
24namespace renderscript {
25
26class Allocation;
27
28class FBOCache {
29public:
30 FBOCache();
31 ~FBOCache();
32
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070033 void init(Context *rsc);
34 void deinit(Context *rsc);
35
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070036 void bindColorTarget(Context *rsc, Allocation *a, uint32_t slot);
37 void bindDepthTarget(Context *, Allocation *a);
38 void resetAll(Context *);
39
Alex Sakhartchoukc19ff012011-05-06 14:59:45 -070040 void setup(Context *);
Alex Sakhartchouka544b632011-07-19 17:50:29 -070041 void updateSize() { mDirty = true; }
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070042
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070043 struct Hal {
44 mutable void *drv;
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070045
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070046 struct State {
Alex Sakhartchouk064aa7e2011-10-18 10:54:29 -070047 Allocation **colorTargets;
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070048 uint32_t colorTargetsCount;
Alex Sakhartchouk064aa7e2011-10-18 10:54:29 -070049 Allocation *depthTarget;
Alex Sakhartchoukda6d34a2011-05-13 14:53:34 -070050 };
51 State state;
52 };
53 Hal mHal;
54
55protected:
Alex Sakhartchouk064aa7e2011-10-18 10:54:29 -070056 ObjectBaseRef<Allocation> *mColorTargets;
57 ObjectBaseRef<Allocation> mDepthTarget;
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070058 bool mDirty;
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070059 void checkError(Context *);
60 void setColorAttachment(Context *rsc);
61 void setDepthAttachment(Context *rsc);
62 bool renderToFramebuffer();
Alex Sakhartchouk7d9c5ff2011-04-01 14:19:01 -070063
64};
65
66} // renderscript
67} // android
68
69#endif //ANDROID_FRAME_BUFFER_OBJECT_CACHE_H