Imported Upstream version 0.1.0+git20131207+e452e83
[deb_libhybris.git] / hybris / egl / platforms / fbdev / fbdev_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 FbDevNativeWindowBuffer : public BaseNativeWindowBuffer {
28 friend class FbDevNativeWindow;
29
30 protected:
31 FbDevNativeWindowBuffer(alloc_device_t* alloc,
32 unsigned int width,
33 unsigned int height,
34 unsigned int format,
35 unsigned int usage) ;
36 virtual ~FbDevNativeWindowBuffer() ;
37
38 protected:
39 int busy;
40 int status;
41 alloc_device_t* m_alloc;
42 };
43
44
45 class FbDevNativeWindow : public BaseNativeWindow {
46 public:
47 FbDevNativeWindow(gralloc_module_t* gralloc, alloc_device_t* alloc,
48 framebuffer_device_t* fbDev);
49 ~FbDevNativeWindow();
50
51 protected:
52 // overloads from BaseNativeWindow
53 virtual int setSwapInterval(int interval);
54
55 virtual int dequeueBuffer(BaseNativeWindowBuffer** buffer, int* fenceFd);
56 virtual int queueBuffer(BaseNativeWindowBuffer* buffer, int fenceFd);
57 virtual int cancelBuffer(BaseNativeWindowBuffer* buffer, int fenceFd);
58 virtual int lockBuffer(BaseNativeWindowBuffer* buffer);
59
60 virtual unsigned int type() const;
61 virtual unsigned int width() const;
62 virtual unsigned int height() const;
63 virtual unsigned int format() const;
64 virtual unsigned int defaultWidth() const;
65 virtual unsigned int defaultHeight() const;
66 virtual unsigned int queueLength() const;
67 virtual unsigned int transformHint() const;
68 // perform calls
69 virtual int setUsage(int usage);
70 virtual int setBuffersFormat(int format);
71 virtual int setBuffersDimensions(int width, int height);
72 virtual int setBufferCount(int cnt);
73
74 private:
75 void destroyBuffers();
76
77 private:
78 framebuffer_device_t* m_fbDev;
79 alloc_device_t* m_alloc;
80 unsigned int m_usage;
81 unsigned int m_bufFormat;
82 int m_freeBufs;
83 std::list<FbDevNativeWindowBuffer*> m_bufList;
84 FbDevNativeWindowBuffer* m_frontBuf;
85 };
86
87 #endif
88 // vim: noai:ts=4:sw=4:ss=4:expandtab