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 
33     void init(Context *rsc);
34     void deinit(Context *rsc);
35 
36     void bindColorTarget(Context *rsc, Allocation *a, uint32_t slot);
37     void bindDepthTarget(Context *, Allocation *a);
38     void resetAll(Context *);
39 
40     void setup(Context *);
updateSize()41     void updateSize() { mDirty = true; }
42 
43     struct Hal {
44         mutable void *drv;
45 
46         struct State {
47             Allocation **colorTargets;
48             uint32_t colorTargetsCount;
49             Allocation *depthTarget;
50         };
51         State state;
52     };
53     Hal mHal;
54 
55 protected:
56     ObjectBaseRef<Allocation> *mColorTargets;
57     ObjectBaseRef<Allocation> mDepthTarget;
58     bool mDirty;
59     void checkError(Context *);
60     void setColorAttachment(Context *rsc);
61     void setDepthAttachment(Context *rsc);
62     bool renderToFramebuffer();
63 
64 };
65 
66 } // namespace renderscript
67 } // namespace android
68 
69 #endif //ANDROID_FRAME_BUFFER_OBJECT_CACHE_H
70