Imported Upstream version 0.1.0+git20131207+e452e83
[deb_libhybris.git] / hybris / egl / platforms / hwcomposer / hwcomposer_window.h
1 /*
2 * Copyright (C) 2013 libhybris
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 FBDEV_WINDOW_H
18 #define FBDEV_WINDOW_H
19
20 #include "nativewindowbase.h"
21 #include <linux/fb.h>
22 #include <android/hardware/gralloc.h>
23
24 #include <list>
25
26
27 class HWComposerNativeWindowBuffer : public BaseNativeWindowBuffer {
28 friend class HWComposerNativeWindow;
29
30 protected:
31 HWComposerNativeWindowBuffer(alloc_device_t* alloc,
32 unsigned int width,
33 unsigned int height,
34 unsigned int format,
35 unsigned int usage) ;
36 virtual ~HWComposerNativeWindowBuffer() ;
37
38 protected:
39 int busy;
40 int fenceFd;
41 int status;
42 alloc_device_t* m_alloc;
43 };
44
45
46 class HWComposerNativeWindow : public BaseNativeWindow {
47 public:
48 HWComposerNativeWindow(unsigned int width, unsigned int height, unsigned int format);
49 ~HWComposerNativeWindow();
50 void setup(gralloc_module_t* gralloc, alloc_device_t* alloc);
51
52
53 void lockFrontBuffer(HWComposerNativeWindowBuffer **buffer);
54 void unlockFrontBuffer(HWComposerNativeWindowBuffer *buffer);
55
56 protected:
57 // overloads from BaseNativeWindow
58 virtual int setSwapInterval(int interval);
59
60 virtual int dequeueBuffer(BaseNativeWindowBuffer** buffer, int* fenceFd);
61 virtual int queueBuffer(BaseNativeWindowBuffer* buffer, int fenceFd);
62 virtual int cancelBuffer(BaseNativeWindowBuffer* buffer, int fenceFd);
63 virtual int lockBuffer(BaseNativeWindowBuffer* buffer);
64
65 virtual unsigned int type() const;
66 virtual unsigned int width() const;
67 virtual unsigned int height() const;
68 virtual unsigned int format() const;
69 virtual unsigned int defaultWidth() const;
70 virtual unsigned int defaultHeight() const;
71 virtual unsigned int queueLength() const;
72 virtual unsigned int transformHint() const;
73 // perform calls
74 virtual int setUsage(int usage);
75 virtual int setBuffersFormat(int format);
76 virtual int setBuffersDimensions(int width, int height);
77 virtual int setBufferCount(int cnt);
78
79 private:
80 void destroyBuffers();
81
82 private:
83 framebuffer_device_t* m_fbDev;
84 alloc_device_t* m_alloc;
85 unsigned int m_usage;
86 unsigned int m_bufFormat;
87 int m_freeBufs;
88 std::list<HWComposerNativeWindowBuffer*> m_bufList;
89 HWComposerNativeWindowBuffer* m_frontBuf;
90
91 int m_width;
92 int m_height;
93
94 };
95
96 #endif
97 // vim: noai:ts=4:sw=4:ss=4:expandtab