xref: /aosp_15_r20/frameworks/rs/driver/rsdFrameBufferObj.h (revision e1eccf28f96817838ad6867f7f39d2351ec11f56)
1*e1eccf28SAndroid Build Coastguard Worker /*
2*e1eccf28SAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*e1eccf28SAndroid Build Coastguard Worker  *
4*e1eccf28SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*e1eccf28SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*e1eccf28SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*e1eccf28SAndroid Build Coastguard Worker  *
8*e1eccf28SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*e1eccf28SAndroid Build Coastguard Worker  *
10*e1eccf28SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*e1eccf28SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*e1eccf28SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e1eccf28SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*e1eccf28SAndroid Build Coastguard Worker  * limitations under the License.
15*e1eccf28SAndroid Build Coastguard Worker  */
16*e1eccf28SAndroid Build Coastguard Worker 
17*e1eccf28SAndroid Build Coastguard Worker #ifndef _RSD_FRAMEBUFFER_OBJ_H_
18*e1eccf28SAndroid Build Coastguard Worker #define _RSD_FRAMEBUFFER_OBJ_H_
19*e1eccf28SAndroid Build Coastguard Worker 
20*e1eccf28SAndroid Build Coastguard Worker #include <rsContext.h>
21*e1eccf28SAndroid Build Coastguard Worker 
22*e1eccf28SAndroid Build Coastguard Worker struct DrvAllocation;
23*e1eccf28SAndroid Build Coastguard Worker 
24*e1eccf28SAndroid Build Coastguard Worker class RsdFrameBufferObj {
25*e1eccf28SAndroid Build Coastguard Worker public:
26*e1eccf28SAndroid Build Coastguard Worker     RsdFrameBufferObj();
27*e1eccf28SAndroid Build Coastguard Worker     ~RsdFrameBufferObj();
28*e1eccf28SAndroid Build Coastguard Worker 
29*e1eccf28SAndroid Build Coastguard Worker     void setActive(const android::renderscript::Context *rsc);
setColorTarget(DrvAllocation * color,uint32_t index)30*e1eccf28SAndroid Build Coastguard Worker     void setColorTarget(DrvAllocation *color, uint32_t index) {
31*e1eccf28SAndroid Build Coastguard Worker         mColorTargets[index] = color;
32*e1eccf28SAndroid Build Coastguard Worker         mDirty = true;
33*e1eccf28SAndroid Build Coastguard Worker     }
setDepthTarget(DrvAllocation * depth)34*e1eccf28SAndroid Build Coastguard Worker     void setDepthTarget(DrvAllocation *depth) {
35*e1eccf28SAndroid Build Coastguard Worker         mDepthTarget = depth;
36*e1eccf28SAndroid Build Coastguard Worker         mDirty = true;
37*e1eccf28SAndroid Build Coastguard Worker     }
setDimensions(uint32_t width,uint32_t height)38*e1eccf28SAndroid Build Coastguard Worker     void setDimensions(uint32_t width, uint32_t height) {
39*e1eccf28SAndroid Build Coastguard Worker         mWidth = width;
40*e1eccf28SAndroid Build Coastguard Worker         mHeight = height;
41*e1eccf28SAndroid Build Coastguard Worker     }
42*e1eccf28SAndroid Build Coastguard Worker protected:
43*e1eccf28SAndroid Build Coastguard Worker     uint32_t mFBOId;
44*e1eccf28SAndroid Build Coastguard Worker     DrvAllocation **mColorTargets;
45*e1eccf28SAndroid Build Coastguard Worker     uint32_t mColorTargetsCount;
46*e1eccf28SAndroid Build Coastguard Worker     DrvAllocation *mDepthTarget;
47*e1eccf28SAndroid Build Coastguard Worker 
48*e1eccf28SAndroid Build Coastguard Worker     uint32_t mWidth;
49*e1eccf28SAndroid Build Coastguard Worker     uint32_t mHeight;
50*e1eccf28SAndroid Build Coastguard Worker 
51*e1eccf28SAndroid Build Coastguard Worker     bool mDirty;
52*e1eccf28SAndroid Build Coastguard Worker 
53*e1eccf28SAndroid Build Coastguard Worker     bool renderToFramebuffer();
54*e1eccf28SAndroid Build Coastguard Worker     void checkError(const android::renderscript::Context *rsc);
55*e1eccf28SAndroid Build Coastguard Worker     void setColorAttachment();
56*e1eccf28SAndroid Build Coastguard Worker     void setDepthAttachment();
57*e1eccf28SAndroid Build Coastguard Worker };
58*e1eccf28SAndroid Build Coastguard Worker 
59*e1eccf28SAndroid Build Coastguard Worker #endif //_RSD_FRAMEBUFFER_STATE_H_
60