• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _TCULNXWAYLAND_HPP
2 #define _TCULNXWAYLAND_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright (c) 2014 The Android Open Source Project
8  * Copyright (c) 2016 The Khronos Group Inc.
9  * Copyright (c) 2016 Mun Gwan-gyeong <elongbug@gmail.com>
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  *      http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  *//*!
24  * \file
25  * \brief wayland utilities.
26  *//*--------------------------------------------------------------------*/
27 
28 #include "tcuDefs.hpp"
29 #include "gluRenderConfig.hpp"
30 #include "gluPlatform.hpp"
31 #include "tcuLnx.hpp"
32 
33 #include <wayland-client.h>
34 #include <wayland-egl.h>
35 
36 namespace tcu
37 {
38 namespace lnx
39 {
40 namespace wayland
41 {
42 
43 class Display
44 {
45 public:
46 							Display					(EventState& platform, const char* name);
47 	virtual					~Display				(void);
48 
getDisplay(void)49 	struct wl_display*		getDisplay				(void) { return m_display;		}
getCompositor(void)50 	struct wl_compositor*	getCompositor			(void) { return m_compositor;	}
getShell(void)51 	struct wl_shell*		getShell				(void) { return m_shell;		}
52 
53 	void					processEvents			(void);
54 	static bool				hasDisplay			(const char* name);
55 
56 	enum DisplayState
57 	{
58 		DISPLAY_STATE_UNKNOWN = -1,
59 		DISPLAY_STATE_UNAVAILABLE,
60 		DISPLAY_STATE_AVAILABLE
61 	};
62 	static DisplayState		s_displayState;
63 
64 protected:
65 	EventState&				m_eventState;
66 	struct wl_display*		m_display;
67 	struct wl_registry*		m_registry;
68 	struct wl_compositor*	m_compositor;
69 	struct wl_shell*		m_shell;
70 
71 private:
72 							Display					(const Display&);
73 	Display&				operator=				(const Display&);
74 
75 	static const struct wl_registry_listener		s_registryListener;
76 
77 	static void				handleGlobal			(void* data, struct wl_registry* registry, uint32_t id, const char* interface, uint32_t version);
78 	static void				handleGlobalRemove		(void* data, struct wl_registry* registry, uint32_t name);
79 };
80 
81 class Window
82 {
83 public:
84 							Window					(Display& display, int width, int height);
85 							~Window					(void);
86 
87 	void					setVisibility			(bool visible);
88 
89 	void					processEvents			(void);
getDisplay(void)90 	Display&				getDisplay				(void) { return m_display; }
getSurface(void)91 	void*					getSurface				(void) { return m_surface; }
getWindow(void)92 	void*					getWindow				(void) { return m_window; }
93 
94 	void					getDimensions			(int* width, int* height) const;
95 	void					setDimensions			(int width, int height);
96 
97 protected:
98 
99 	Display&					m_display;
100 	struct wl_egl_window*		m_window;
101 	struct wl_surface*			m_surface;
102 	struct wl_shell_surface*	m_shellSurface;
103 	bool						m_visible;
104 
105 private:
106 							Window					(const Window&);
107 	Window&					operator=				(const Window&);
108 
109 	static const struct wl_shell_surface_listener	s_shellSurfaceListener;
110 
111 	static void				handlePing				(void* data, struct wl_shell_surface* shellSurface, uint32_t serial);
112 	static void				handleConfigure			(void* data, struct wl_shell_surface* shellSurface, uint32_t edges, int32_t width, int32_t height);
113 	static void				handlePopupDone			(void* data, struct wl_shell_surface* shellSurface);
114 };
115 
116 } // wayland
117 } // lnx
118 } // tcu
119 
120 #endif // _TCULNXWAYLAND_HPP
121