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 { return m_capabilities; } getPlatformType(void) const57 eglw::EGLenum getPlatformType (void) const { return m_platformType; } getPlatformExtensionName(void) const58 const char* getPlatformExtensionName (void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); } 59 60 //! Get EGLNativeDisplayType that can be used with eglGetDisplay(). Default implementation throws tcu::NotSupportedError(). 61 virtual eglw::EGLNativeDisplayType getLegacyNative (void); 62 63 //! Return display pointer that can be used with eglGetPlatformDisplay(). Default implementations throw tcu::NotSupportedError() 64 virtual void* getPlatformNative (void); 65 66 //! Attributes to pass to eglGetPlatformDisplay(EXT) 67 virtual const eglw::EGLAttrib* getPlatformAttributes (void) const; 68 69 protected: 70 NativeDisplay (Capability capabilities, eglw::EGLenum platformType, const char* platformExtension); 71 NativeDisplay (Capability capabilities); 72 73 private: 74 NativeDisplay (const NativeDisplay&); 75 NativeDisplay& operator= (const NativeDisplay&); 76 77 const Capability m_capabilities; 78 const eglw::EGLenum m_platformType; //!< EGL platform type, or EGL_NONE if not supported. 79 const std::string m_platformExtension; 80 }; 81 82 class NativeDisplayFactory : public tcu::FactoryBase 83 { 84 public: 85 virtual ~NativeDisplayFactory (void); 86 87 virtual NativeDisplay* createDisplay (const eglw::EGLAttrib* attribList = DE_NULL) const = 0; 88 getCapabilities(void) const89 NativeDisplay::Capability getCapabilities (void) const { return m_capabilities; } getPlatformType(void) const90 eglw::EGLenum getPlatformType (void) const { return m_platformType; } getPlatformExtensionName(void) const91 const char* getPlatformExtensionName (void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); } 92 getNativeWindowRegistry(void) const93 const NativeWindowFactoryRegistry& getNativeWindowRegistry (void) const { return m_nativeWindowRegistry; } getNativePixmapRegistry(void) const94 const NativePixmapFactoryRegistry& getNativePixmapRegistry (void) const { return m_nativePixmapRegistry; } 95 96 protected: 97 NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities); 98 NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, eglw::EGLenum platformType, const char* platformExtension); 99 100 NativeWindowFactoryRegistry m_nativeWindowRegistry; 101 NativePixmapFactoryRegistry m_nativePixmapRegistry; 102 103 private: 104 NativeDisplayFactory (const NativeDisplayFactory&); 105 NativeDisplayFactory& operator= (const NativeDisplayFactory&); 106 107 const NativeDisplay::Capability m_capabilities; 108 const eglw::EGLenum m_platformType; 109 const std::string m_platformExtension; 110 }; 111 112 typedef tcu::FactoryRegistry<NativeDisplayFactory> NativeDisplayFactoryRegistry; 113 114 } // eglu 115 116 #endif // _EGLUNATIVEDISPLAY_HPP 117