Merge vk-gl-cts/opengl-es-cts-3.2.3 into vk-gl-cts/opengl-es-cts-3.2.4
[platform/upstream/VK-GL-CTS.git] / framework / egl / egluNativeDisplay.hpp
1 #ifndef _EGLUNATIVEDISPLAY_HPP
2 #define _EGLUNATIVEDISPLAY_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 EGL native display abstraction
24  *//*--------------------------------------------------------------------*/
25
26 #include "tcuDefs.hpp"
27 #include "tcuFactoryRegistry.hpp"
28 #include "egluNativeWindow.hpp"
29 #include "egluNativePixmap.hpp"
30 #include "eglwDefs.hpp"
31
32 #include <string>
33
34 namespace eglw
35 {
36 class Library;
37 }
38
39 namespace eglu
40 {
41
42 class NativeDisplay
43 {
44 public:
45         enum Capability
46         {
47                 CAPABILITY_GET_DISPLAY_LEGACY   = (1<<0),       //!< Query EGL display using eglGetDisplay()
48                 CAPABILITY_GET_DISPLAY_PLATFORM = (1<<1)        //!< Query EGL display using eglGetPlatformDisplay()
49         };
50
51         virtual                                                         ~NativeDisplay                          (void);
52
53         virtual const eglw::Library&            getLibrary                                      (void) const = 0;
54
55         Capability                                                      getCapabilities                         (void) const { return m_capabilities; }
56         eglw::EGLenum                                           getPlatformType                         (void) const { return m_platformType; }
57         const char*                                                     getPlatformExtensionName        (void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
58
59         //! Get EGLNativeDisplayType that can be used with eglGetDisplay(). Default implementation throws tcu::NotSupportedError().
60         virtual eglw::EGLNativeDisplayType      getLegacyNative                         (void);
61
62         //! Return display pointer that can be used with eglGetPlatformDisplay(). Default implementations throw tcu::NotSupportedError()
63         virtual void*                                           getPlatformNative                       (void);
64
65         //! Attributes to pass to eglGetPlatformDisplay(EXT)
66         virtual const eglw::EGLAttrib*          getPlatformAttributes           (void) const;
67
68 protected:
69                                                                                 NativeDisplay                           (Capability capabilities, eglw::EGLenum platformType, const char* platformExtension);
70                                                                                 NativeDisplay                           (Capability capabilities);
71
72 private:
73                                                                                 NativeDisplay                           (const NativeDisplay&);
74         NativeDisplay&                                          operator=                                       (const NativeDisplay&);
75
76         const Capability                                        m_capabilities;
77         const eglw::EGLenum                                     m_platformType;                         //!< EGL platform type, or EGL_NONE if not supported.
78         const std::string                                       m_platformExtension;
79 };
80
81 class NativeDisplayFactory : public tcu::FactoryBase
82 {
83 public:
84         virtual                                                         ~NativeDisplayFactory           (void);
85
86         virtual NativeDisplay*                          createDisplay                           (const eglw::EGLAttrib* attribList = DE_NULL) const = 0;
87
88         NativeDisplay::Capability                       getCapabilities                         (void) const { return m_capabilities; }
89         eglw::EGLenum                                           getPlatformType                         (void) const { return m_platformType; }
90         const char*                                                     getPlatformExtensionName        (void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
91
92         const NativeWindowFactoryRegistry&      getNativeWindowRegistry         (void) const { return m_nativeWindowRegistry; }
93         const NativePixmapFactoryRegistry&      getNativePixmapRegistry         (void) const { return m_nativePixmapRegistry; }
94
95 protected:
96                                                                                 NativeDisplayFactory            (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities);
97                                                                                 NativeDisplayFactory            (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, eglw::EGLenum platformType, const char* platformExtension);
98
99         NativeWindowFactoryRegistry                     m_nativeWindowRegistry;
100         NativePixmapFactoryRegistry                     m_nativePixmapRegistry;
101
102 private:
103                                                                                 NativeDisplayFactory            (const NativeDisplayFactory&);
104         NativeDisplayFactory&                           operator=                                       (const NativeDisplayFactory&);
105
106         const NativeDisplay::Capability         m_capabilities;
107         const eglw::EGLenum                                     m_platformType;
108         const std::string                                       m_platformExtension;
109 };
110
111 typedef tcu::FactoryRegistry<NativeDisplayFactory> NativeDisplayFactoryRegistry;
112
113 } // eglu
114
115 #endif // _EGLUNATIVEDISPLAY_HPP