Add support for dynamic loading of EGL entry points
[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 protected:
66                                                                                 NativeDisplay                           (Capability capabilities, eglw::EGLenum platformType, const char* platformExtension);
67                                                                                 NativeDisplay                           (Capability capabilities);
68
69 private:
70                                                                                 NativeDisplay                           (const NativeDisplay&);
71         NativeDisplay&                                          operator=                                       (const NativeDisplay&);
72
73         const Capability                                        m_capabilities;
74         const eglw::EGLenum                                     m_platformType;                         //!< EGL platform type, or EGL_NONE if not supported.
75         const std::string                                       m_platformExtension;
76 };
77
78 class NativeDisplayFactory : public tcu::FactoryBase
79 {
80 public:
81         virtual                                                         ~NativeDisplayFactory           (void);
82
83         virtual NativeDisplay*                          createDisplay                           (const eglw::EGLAttrib* attribList = DE_NULL) const = 0;
84
85         NativeDisplay::Capability                       getCapabilities                         (void) const { return m_capabilities; }
86         eglw::EGLenum                                           getPlatformType                         (void) const { return m_platformType; }
87         const char*                                                     getPlatformExtensionName        (void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
88
89         const NativeWindowFactoryRegistry&      getNativeWindowRegistry         (void) const { return m_nativeWindowRegistry; }
90         const NativePixmapFactoryRegistry&      getNativePixmapRegistry         (void) const { return m_nativePixmapRegistry; }
91
92 protected:
93                                                                                 NativeDisplayFactory            (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities);
94                                                                                 NativeDisplayFactory            (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, eglw::EGLenum platformType, const char* platformExtension);
95
96         NativeWindowFactoryRegistry                     m_nativeWindowRegistry;
97         NativePixmapFactoryRegistry                     m_nativePixmapRegistry;
98
99 private:
100                                                                                 NativeDisplayFactory            (const NativeDisplayFactory&);
101         NativeDisplayFactory&                           operator=                                       (const NativeDisplayFactory&);
102
103         const NativeDisplay::Capability         m_capabilities;
104         const eglw::EGLenum                                     m_platformType;
105         const std::string                                       m_platformExtension;
106 };
107
108 typedef tcu::FactoryRegistry<NativeDisplayFactory> NativeDisplayFactoryRegistry;
109
110 } // eglu
111
112 #endif // _EGLUNATIVEDISPLAY_HPP