Commit | Line | Data |
---|---|---|
d42e7319 JB |
1 | #ifndef NATIVEWINDOWBASE_H |
2 | #define NATIVEWINDOWBASE_H | |
3 | ||
4 | /* for ICS window.h */ | |
5 | #include <string.h> | |
6 | #include <android/system/window.h> | |
7 | #include <EGL/egl.h> | |
8 | #include "support.h" | |
9 | #include <stdarg.h> | |
10 | #include <assert.h> | |
11 | ||
12 | #ifdef DEBUG | |
13 | #include <stdio.h> | |
14 | #endif | |
15 | ||
16 | #define NO_ERROR 0L | |
17 | #define BAD_VALUE -1 | |
18 | ||
19 | /** | |
20 | * @brief A Class to do common ANativeBuffer initialization and thunk c-style | |
21 | * callbacks into C++ method calls. | |
22 | **/ | |
23 | class BaseNativeWindowBuffer : public ANativeWindowBuffer | |
24 | { | |
25 | protected: | |
26 | BaseNativeWindowBuffer(); | |
27 | virtual ~BaseNativeWindowBuffer() ; | |
28 | ||
29 | public: | |
30 | /* When passing the buffer to EGL functions it's required to pass always the native | |
31 | * buffer. This method takes care about proper casting. */ | |
32 | ANativeWindowBuffer* getNativeBuffer() const; | |
33 | ||
34 | private: | |
35 | unsigned int refcount; | |
36 | static void _decRef(struct android_native_base_t* base); | |
37 | static void _incRef(struct android_native_base_t* base); | |
38 | }; | |
39 | ||
40 | /** | |
41 | * @brief A Class to do common ANativeWindow initialization and thunk c-style | |
42 | * callbacks into C++ method calls. | |
43 | **/ | |
44 | class BaseNativeWindow : public ANativeWindow | |
45 | { | |
46 | public: | |
47 | operator EGLNativeWindowType() | |
48 | { | |
49 | EGLNativeWindowType ret = reinterpret_cast<EGLNativeWindowType>(static_cast<ANativeWindow *>(this)); | |
50 | return ret; | |
51 | } | |
52 | ||
53 | protected: | |
54 | BaseNativeWindow(); | |
55 | virtual ~BaseNativeWindow(); | |
56 | ||
57 | // does this require more magic? | |
58 | unsigned int refcount; | |
59 | static void _decRef(struct android_native_base_t* base); | |
60 | static void _incRef(struct android_native_base_t* base); | |
61 | ||
62 | // these have to be implemented in the concrete implementation, eg. FBDEV or offscreen window | |
63 | virtual int setSwapInterval(int interval) = 0; | |
64 | ||
65 | virtual int dequeueBuffer(BaseNativeWindowBuffer **buffer, int *fenceFd) = 0; | |
66 | virtual int queueBuffer(BaseNativeWindowBuffer *buffer, int fenceFd) = 0; | |
67 | virtual int cancelBuffer(BaseNativeWindowBuffer *buffer, int fenceFd) = 0; | |
68 | virtual int lockBuffer(BaseNativeWindowBuffer *buffer) = 0; // DEPRECATED | |
69 | ||
70 | virtual unsigned int type() const = 0; | |
71 | virtual unsigned int width() const = 0; | |
72 | virtual unsigned int height() const = 0; | |
73 | virtual unsigned int format() const = 0; | |
74 | virtual unsigned int defaultWidth() const = 0; | |
75 | virtual unsigned int defaultHeight() const = 0; | |
76 | virtual unsigned int queueLength() const = 0; | |
77 | virtual unsigned int transformHint() const = 0; | |
78 | //perform interfaces | |
79 | virtual int setBuffersFormat(int format) = 0; | |
80 | virtual int setBuffersDimensions(int width, int height) = 0; | |
81 | virtual int setUsage(int usage) = 0; | |
82 | virtual int setBufferCount(int cnt) = 0; | |
83 | private: | |
84 | static int _setSwapInterval(struct ANativeWindow* window, int interval); | |
85 | static int _dequeueBuffer_DEPRECATED(ANativeWindow* window, ANativeWindowBuffer** buffer); | |
86 | static const char *_native_window_operation(int what); | |
87 | static const char *_native_query_operation(int what); | |
88 | static int _lockBuffer_DEPRECATED(struct ANativeWindow* window, ANativeWindowBuffer* buffer); | |
89 | static int _queueBuffer_DEPRECATED(struct ANativeWindow* window, ANativeWindowBuffer* buffer); | |
90 | static int _query(const struct ANativeWindow* window, int what, int* value); | |
91 | static int _perform(struct ANativeWindow* window, int operation, ... ); | |
92 | static int _cancelBuffer_DEPRECATED(struct ANativeWindow* window, ANativeWindowBuffer* buffer); | |
93 | static int _queueBuffer(struct ANativeWindow *window, ANativeWindowBuffer *buffer, int fenceFd); | |
94 | static int _dequeueBuffer(struct ANativeWindow *window, ANativeWindowBuffer **buffer, int *fenceFd); | |
95 | static int _cancelBuffer(struct ANativeWindow *window, ANativeWindowBuffer *buffer, int fenceFd); | |
96 | }; | |
97 | ||
98 | #endif |