Add tests for VK_KHR_incremental_present
[platform/upstream/VK-GL-CTS.git] / framework / platform / X11 / tcuX11.hpp
1 #ifndef _TCUX11_HPP
2 #define _TCUX11_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program Tester Core
5  * ----------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief X11 utilities.
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuDefs.hpp"
27 #include "gluRenderConfig.hpp"
28 #include "gluPlatform.hpp"
29 #include "deMutex.hpp"
30
31 #include <X11/Xlib.h>
32 #include <X11/Xutil.h>
33 #include <X11/keysym.h>
34 #include <X11/Xatom.h>
35
36 namespace tcu
37 {
38 namespace x11
39 {
40 enum
41 {
42         DEFAULT_WINDOW_WIDTH    = 400,
43         DEFAULT_WINDOW_HEIGHT   = 300
44 };
45
46 class EventState
47 {
48 public:
49                                 EventState      (void);
50         virtual         ~EventState     (void);
51         void            setQuitFlag     (bool quit);
52         bool            getQuitFlag     (void);
53
54 protected:
55         de::Mutex       m_mutex;
56         bool            m_quit;
57
58 private:
59                                 EventState      (const EventState&);
60         EventState&     operator=       (const EventState&);
61 };
62
63 class DisplayBase
64 {
65 public:
66                                         DisplayBase             (EventState& platform);
67         virtual                 ~DisplayBase    (void);
68         virtual void    processEvents   (void) = 0;
69
70 protected:
71         EventState&             m_eventState;
72
73 private:
74                                         DisplayBase             (const DisplayBase&);
75         DisplayBase&    operator=               (const DisplayBase&);
76 };
77
78 class WindowBase
79 {
80 public:
81                                                         WindowBase              (void);
82         virtual                                 ~WindowBase             (void);
83
84         virtual void                    setVisibility   (bool visible) = 0;
85
86         virtual void                    processEvents   (void) = 0;
87         virtual DisplayBase&    getDisplay              (void) = 0;
88
89         virtual void                    getDimensions   (int* width, int* height) const = 0;
90         virtual void                    setDimensions   (int width, int height) = 0;
91
92 protected:
93         bool                                    m_visible;
94
95 private:
96                                                         WindowBase              (const WindowBase&);
97         WindowBase&                             operator=               (const WindowBase&);
98 };
99
100 class XlibDisplay : public DisplayBase
101 {
102 public:
103                                         XlibDisplay             (EventState& platform, const char* name);
104         virtual                 ~XlibDisplay    (void);
105
106         ::Display*              getXDisplay             (void) { return m_display;              }
107         Atom                    getDeleteAtom   (void) { return m_deleteAtom;   }
108
109         ::Visual*               getVisual               (VisualID visualID);
110         bool                    getVisualInfo   (VisualID visualID, XVisualInfo& dst);
111         void                    processEvents   (void);
112
113 protected:
114         ::Display*              m_display;
115         Atom                    m_deleteAtom;
116
117 private:
118                                         XlibDisplay             (const XlibDisplay&);
119         XlibDisplay&    operator=               (const XlibDisplay&);
120 };
121
122 class XlibWindow : public WindowBase
123 {
124 public:
125                                         XlibWindow                      (XlibDisplay& display, int width, int height,
126                                                                                 ::Visual* visual);
127                                         ~XlibWindow                     (void);
128
129         void                    setVisibility   (bool visible);
130
131         void                    processEvents   (void);
132         DisplayBase&    getDisplay              (void) { return (DisplayBase&)m_display; }
133         ::Window&               getXID                  (void) { return m_window; }
134
135         void                    getDimensions   (int* width, int* height) const;
136         void                    setDimensions   (int width, int height);
137
138 protected:
139         XlibDisplay&    m_display;
140         ::Colormap              m_colormap;
141         ::Window                m_window;
142
143 private:
144                                         XlibWindow              (const XlibWindow&);
145         XlibWindow&             operator=               (const XlibWindow&);
146 };
147
148 } // x11
149 } // tcu
150
151 #endif // _TCUX11_HPP