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 CAPABILITY_GET_DISPLAY_PLATFORM_EXT = (1 << 2) //!< Query EGL display using eglGetPlatformDisplayEXT() 50 }; 51 52 virtual ~NativeDisplay(void); 53 54 virtual const eglw::Library &getLibrary(void) const = 0; 55 getCapabilities(void) const56 Capability getCapabilities(void) const 57 { 58 return m_capabilities; 59 } getPlatformType(void) const60 eglw::EGLenum getPlatformType(void) const 61 { 62 return m_platformType; 63 } getPlatformExtensionName(void) const64 const char *getPlatformExtensionName(void) const 65 { 66 return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); 67 } 68 69 //! Get EGLNativeDisplayType that can be used with eglGetDisplay(). Default implementation throws tcu::NotSupportedError(). 70 virtual eglw::EGLNativeDisplayType getLegacyNative(void); 71 72 //! Return display pointer that can be used with eglGetPlatformDisplay(). Default implementations throw tcu::NotSupportedError() 73 virtual void *getPlatformNative(void); 74 75 //! Attributes to pass to eglGetPlatformDisplay(EXT) 76 virtual const eglw::EGLAttrib *getPlatformAttributes(void) const; 77 78 protected: 79 NativeDisplay(Capability capabilities, eglw::EGLenum platformType, const char *platformExtension); 80 NativeDisplay(Capability capabilities); 81 82 private: 83 NativeDisplay(const NativeDisplay &); 84 NativeDisplay &operator=(const NativeDisplay &); 85 86 const Capability m_capabilities; 87 const eglw::EGLenum m_platformType; //!< EGL platform type, or EGL_NONE if not supported. 88 const std::string m_platformExtension; 89 }; 90 91 class NativeDisplayFactory : public tcu::FactoryBase 92 { 93 public: 94 virtual ~NativeDisplayFactory(void); 95 96 virtual NativeDisplay *createDisplay(const eglw::EGLAttrib *attribList = DE_NULL) const = 0; 97 getCapabilities(void) const98 NativeDisplay::Capability getCapabilities(void) const 99 { 100 return m_capabilities; 101 } getPlatformType(void) const102 eglw::EGLenum getPlatformType(void) const 103 { 104 return m_platformType; 105 } getPlatformExtensionName(void) const106 const char *getPlatformExtensionName(void) const 107 { 108 return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); 109 } 110 getNativeWindowRegistry(void) const111 const NativeWindowFactoryRegistry &getNativeWindowRegistry(void) const 112 { 113 return m_nativeWindowRegistry; 114 } getNativePixmapRegistry(void) const115 const NativePixmapFactoryRegistry &getNativePixmapRegistry(void) const 116 { 117 return m_nativePixmapRegistry; 118 } 119 120 protected: 121 NativeDisplayFactory(const std::string &name, const std::string &description, 122 NativeDisplay::Capability capabilities); 123 NativeDisplayFactory(const std::string &name, const std::string &description, 124 NativeDisplay::Capability capabilities, eglw::EGLenum platformType, 125 const char *platformExtension); 126 127 NativeWindowFactoryRegistry m_nativeWindowRegistry; 128 NativePixmapFactoryRegistry m_nativePixmapRegistry; 129 130 private: 131 NativeDisplayFactory(const NativeDisplayFactory &); 132 NativeDisplayFactory &operator=(const NativeDisplayFactory &); 133 134 const NativeDisplay::Capability m_capabilities; 135 const eglw::EGLenum m_platformType; 136 const std::string m_platformExtension; 137 }; 138 139 typedef tcu::FactoryRegistry<NativeDisplayFactory> NativeDisplayFactoryRegistry; 140 141 } // namespace eglu 142 143 #endif // _EGLUNATIVEDISPLAY_HPP 144