fadb123a58b922ab99930808813d3a055a5d66ca
1 #ifndef NATIVEWINDOWBASE_H
2 #define NATIVEWINDOWBASE_H
6 #include <android/system/window.h>
20 * @brief A Class to do common ANativeBuffer initialization and thunk c-style
21 * callbacks into C++ method calls.
23 class BaseNativeWindowBuffer
: public ANativeWindowBuffer
26 BaseNativeWindowBuffer();
27 virtual ~BaseNativeWindowBuffer() ;
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;
35 unsigned int refcount
;
36 static void _decRef(struct android_native_base_t
* base
);
37 static void _incRef(struct android_native_base_t
* base
);
41 * @brief A Class to do common ANativeWindow initialization and thunk c-style
42 * callbacks into C++ method calls.
44 class BaseNativeWindow
: public ANativeWindow
47 operator EGLNativeWindowType()
49 EGLNativeWindowType ret
= reinterpret_cast<EGLNativeWindowType
>(static_cast<ANativeWindow
*>(this));
55 virtual ~BaseNativeWindow();
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
);
62 // these have to be implemented in the concrete implementation, eg. FBDEV or offscreen window
63 virtual int setSwapInterval(int interval
) = 0;
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
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;
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;
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
);