1*35238bceSAndroid Build Coastguard Worker #ifndef _EGLUNATIVEDISPLAY_HPP 2*35238bceSAndroid Build Coastguard Worker #define _EGLUNATIVEDISPLAY_HPP 3*35238bceSAndroid Build Coastguard Worker /*------------------------------------------------------------------------- 4*35238bceSAndroid Build Coastguard Worker * drawElements Quality Program Tester Core 5*35238bceSAndroid Build Coastguard Worker * ---------------------------------------- 6*35238bceSAndroid Build Coastguard Worker * 7*35238bceSAndroid Build Coastguard Worker * Copyright 2014 The Android Open Source Project 8*35238bceSAndroid Build Coastguard Worker * 9*35238bceSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 10*35238bceSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 11*35238bceSAndroid Build Coastguard Worker * You may obtain a copy of the License at 12*35238bceSAndroid Build Coastguard Worker * 13*35238bceSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 14*35238bceSAndroid Build Coastguard Worker * 15*35238bceSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 16*35238bceSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 17*35238bceSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18*35238bceSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 19*35238bceSAndroid Build Coastguard Worker * limitations under the License. 20*35238bceSAndroid Build Coastguard Worker * 21*35238bceSAndroid Build Coastguard Worker *//*! 22*35238bceSAndroid Build Coastguard Worker * \file 23*35238bceSAndroid Build Coastguard Worker * \brief EGL native display abstraction 24*35238bceSAndroid Build Coastguard Worker *//*--------------------------------------------------------------------*/ 25*35238bceSAndroid Build Coastguard Worker 26*35238bceSAndroid Build Coastguard Worker #include "tcuDefs.hpp" 27*35238bceSAndroid Build Coastguard Worker #include "tcuFactoryRegistry.hpp" 28*35238bceSAndroid Build Coastguard Worker #include "egluNativeWindow.hpp" 29*35238bceSAndroid Build Coastguard Worker #include "egluNativePixmap.hpp" 30*35238bceSAndroid Build Coastguard Worker #include "eglwDefs.hpp" 31*35238bceSAndroid Build Coastguard Worker 32*35238bceSAndroid Build Coastguard Worker #include <string> 33*35238bceSAndroid Build Coastguard Worker 34*35238bceSAndroid Build Coastguard Worker namespace eglw 35*35238bceSAndroid Build Coastguard Worker { 36*35238bceSAndroid Build Coastguard Worker class Library; 37*35238bceSAndroid Build Coastguard Worker } 38*35238bceSAndroid Build Coastguard Worker 39*35238bceSAndroid Build Coastguard Worker namespace eglu 40*35238bceSAndroid Build Coastguard Worker { 41*35238bceSAndroid Build Coastguard Worker 42*35238bceSAndroid Build Coastguard Worker class NativeDisplay 43*35238bceSAndroid Build Coastguard Worker { 44*35238bceSAndroid Build Coastguard Worker public: 45*35238bceSAndroid Build Coastguard Worker enum Capability 46*35238bceSAndroid Build Coastguard Worker { 47*35238bceSAndroid Build Coastguard Worker CAPABILITY_GET_DISPLAY_LEGACY = (1 << 0), //!< Query EGL display using eglGetDisplay() 48*35238bceSAndroid Build Coastguard Worker CAPABILITY_GET_DISPLAY_PLATFORM = (1 << 1), //!< Query EGL display using eglGetPlatformDisplay() 49*35238bceSAndroid Build Coastguard Worker CAPABILITY_GET_DISPLAY_PLATFORM_EXT = (1 << 2) //!< Query EGL display using eglGetPlatformDisplayEXT() 50*35238bceSAndroid Build Coastguard Worker }; 51*35238bceSAndroid Build Coastguard Worker 52*35238bceSAndroid Build Coastguard Worker virtual ~NativeDisplay(void); 53*35238bceSAndroid Build Coastguard Worker 54*35238bceSAndroid Build Coastguard Worker virtual const eglw::Library &getLibrary(void) const = 0; 55*35238bceSAndroid Build Coastguard Worker getCapabilities(void) const56*35238bceSAndroid Build Coastguard Worker Capability getCapabilities(void) const 57*35238bceSAndroid Build Coastguard Worker { 58*35238bceSAndroid Build Coastguard Worker return m_capabilities; 59*35238bceSAndroid Build Coastguard Worker } getPlatformType(void) const60*35238bceSAndroid Build Coastguard Worker eglw::EGLenum getPlatformType(void) const 61*35238bceSAndroid Build Coastguard Worker { 62*35238bceSAndroid Build Coastguard Worker return m_platformType; 63*35238bceSAndroid Build Coastguard Worker } getPlatformExtensionName(void) const64*35238bceSAndroid Build Coastguard Worker const char *getPlatformExtensionName(void) const 65*35238bceSAndroid Build Coastguard Worker { 66*35238bceSAndroid Build Coastguard Worker return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); 67*35238bceSAndroid Build Coastguard Worker } 68*35238bceSAndroid Build Coastguard Worker 69*35238bceSAndroid Build Coastguard Worker //! Get EGLNativeDisplayType that can be used with eglGetDisplay(). Default implementation throws tcu::NotSupportedError(). 70*35238bceSAndroid Build Coastguard Worker virtual eglw::EGLNativeDisplayType getLegacyNative(void); 71*35238bceSAndroid Build Coastguard Worker 72*35238bceSAndroid Build Coastguard Worker //! Return display pointer that can be used with eglGetPlatformDisplay(). Default implementations throw tcu::NotSupportedError() 73*35238bceSAndroid Build Coastguard Worker virtual void *getPlatformNative(void); 74*35238bceSAndroid Build Coastguard Worker 75*35238bceSAndroid Build Coastguard Worker //! Attributes to pass to eglGetPlatformDisplay(EXT) 76*35238bceSAndroid Build Coastguard Worker virtual const eglw::EGLAttrib *getPlatformAttributes(void) const; 77*35238bceSAndroid Build Coastguard Worker 78*35238bceSAndroid Build Coastguard Worker protected: 79*35238bceSAndroid Build Coastguard Worker NativeDisplay(Capability capabilities, eglw::EGLenum platformType, const char *platformExtension); 80*35238bceSAndroid Build Coastguard Worker NativeDisplay(Capability capabilities); 81*35238bceSAndroid Build Coastguard Worker 82*35238bceSAndroid Build Coastguard Worker private: 83*35238bceSAndroid Build Coastguard Worker NativeDisplay(const NativeDisplay &); 84*35238bceSAndroid Build Coastguard Worker NativeDisplay &operator=(const NativeDisplay &); 85*35238bceSAndroid Build Coastguard Worker 86*35238bceSAndroid Build Coastguard Worker const Capability m_capabilities; 87*35238bceSAndroid Build Coastguard Worker const eglw::EGLenum m_platformType; //!< EGL platform type, or EGL_NONE if not supported. 88*35238bceSAndroid Build Coastguard Worker const std::string m_platformExtension; 89*35238bceSAndroid Build Coastguard Worker }; 90*35238bceSAndroid Build Coastguard Worker 91*35238bceSAndroid Build Coastguard Worker class NativeDisplayFactory : public tcu::FactoryBase 92*35238bceSAndroid Build Coastguard Worker { 93*35238bceSAndroid Build Coastguard Worker public: 94*35238bceSAndroid Build Coastguard Worker virtual ~NativeDisplayFactory(void); 95*35238bceSAndroid Build Coastguard Worker 96*35238bceSAndroid Build Coastguard Worker virtual NativeDisplay *createDisplay(const eglw::EGLAttrib *attribList = DE_NULL) const = 0; 97*35238bceSAndroid Build Coastguard Worker getCapabilities(void) const98*35238bceSAndroid Build Coastguard Worker NativeDisplay::Capability getCapabilities(void) const 99*35238bceSAndroid Build Coastguard Worker { 100*35238bceSAndroid Build Coastguard Worker return m_capabilities; 101*35238bceSAndroid Build Coastguard Worker } getPlatformType(void) const102*35238bceSAndroid Build Coastguard Worker eglw::EGLenum getPlatformType(void) const 103*35238bceSAndroid Build Coastguard Worker { 104*35238bceSAndroid Build Coastguard Worker return m_platformType; 105*35238bceSAndroid Build Coastguard Worker } getPlatformExtensionName(void) const106*35238bceSAndroid Build Coastguard Worker const char *getPlatformExtensionName(void) const 107*35238bceSAndroid Build Coastguard Worker { 108*35238bceSAndroid Build Coastguard Worker return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); 109*35238bceSAndroid Build Coastguard Worker } 110*35238bceSAndroid Build Coastguard Worker getNativeWindowRegistry(void) const111*35238bceSAndroid Build Coastguard Worker const NativeWindowFactoryRegistry &getNativeWindowRegistry(void) const 112*35238bceSAndroid Build Coastguard Worker { 113*35238bceSAndroid Build Coastguard Worker return m_nativeWindowRegistry; 114*35238bceSAndroid Build Coastguard Worker } getNativePixmapRegistry(void) const115*35238bceSAndroid Build Coastguard Worker const NativePixmapFactoryRegistry &getNativePixmapRegistry(void) const 116*35238bceSAndroid Build Coastguard Worker { 117*35238bceSAndroid Build Coastguard Worker return m_nativePixmapRegistry; 118*35238bceSAndroid Build Coastguard Worker } 119*35238bceSAndroid Build Coastguard Worker 120*35238bceSAndroid Build Coastguard Worker protected: 121*35238bceSAndroid Build Coastguard Worker NativeDisplayFactory(const std::string &name, const std::string &description, 122*35238bceSAndroid Build Coastguard Worker NativeDisplay::Capability capabilities); 123*35238bceSAndroid Build Coastguard Worker NativeDisplayFactory(const std::string &name, const std::string &description, 124*35238bceSAndroid Build Coastguard Worker NativeDisplay::Capability capabilities, eglw::EGLenum platformType, 125*35238bceSAndroid Build Coastguard Worker const char *platformExtension); 126*35238bceSAndroid Build Coastguard Worker 127*35238bceSAndroid Build Coastguard Worker NativeWindowFactoryRegistry m_nativeWindowRegistry; 128*35238bceSAndroid Build Coastguard Worker NativePixmapFactoryRegistry m_nativePixmapRegistry; 129*35238bceSAndroid Build Coastguard Worker 130*35238bceSAndroid Build Coastguard Worker private: 131*35238bceSAndroid Build Coastguard Worker NativeDisplayFactory(const NativeDisplayFactory &); 132*35238bceSAndroid Build Coastguard Worker NativeDisplayFactory &operator=(const NativeDisplayFactory &); 133*35238bceSAndroid Build Coastguard Worker 134*35238bceSAndroid Build Coastguard Worker const NativeDisplay::Capability m_capabilities; 135*35238bceSAndroid Build Coastguard Worker const eglw::EGLenum m_platformType; 136*35238bceSAndroid Build Coastguard Worker const std::string m_platformExtension; 137*35238bceSAndroid Build Coastguard Worker }; 138*35238bceSAndroid Build Coastguard Worker 139*35238bceSAndroid Build Coastguard Worker typedef tcu::FactoryRegistry<NativeDisplayFactory> NativeDisplayFactoryRegistry; 140*35238bceSAndroid Build Coastguard Worker 141*35238bceSAndroid Build Coastguard Worker } // namespace eglu 142*35238bceSAndroid Build Coastguard Worker 143*35238bceSAndroid Build Coastguard Worker #endif // _EGLUNATIVEDISPLAY_HPP 144