Home | History | Annotate | Download | only in egl
      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 "egluHeaderWrapper.hpp"
     31 
     32 #include <string>
     33 
     34 namespace eglu
     35 {
     36 
     37 class NativeDisplay
     38 {
     39 public:
     40 	enum Capability
     41 	{
     42 		CAPABILITY_GET_DISPLAY_LEGACY	= (1<<0),	//!< Query EGL display using eglGetDisplay()
     43 		CAPABILITY_GET_DISPLAY_PLATFORM	= (1<<1)	//!< Query EGL display using eglGetPlatformDisplay()
     44 	};
     45 
     46 	virtual								~NativeDisplay				(void);
     47 
     48 	Capability							getCapabilities				(void) const { return m_capabilities; }
     49 	EGLenum								getPlatformType				(void) const { return m_platformType; }
     50 	const char*							getPlatformExtensionName	(void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
     51 
     52 	//! Get EGLNativeDisplayType that can be used with eglGetDisplay(). Default implementation throws tcu::NotSupportedError().
     53 	virtual EGLNativeDisplayType		getLegacyNative				(void);
     54 
     55 	//! Return display pointer that can be used with eglGetPlatformDisplay(). Default implementations throw tcu::NotSupportedError()
     56 	virtual void*						getPlatformNative			(void);
     57 
     58 protected:
     59 										NativeDisplay				(Capability capabilities, EGLenum platformType, const char* platformExtension);
     60 										NativeDisplay				(Capability capabilities);
     61 
     62 private:
     63 										NativeDisplay				(const NativeDisplay&);
     64 	NativeDisplay&						operator=					(const NativeDisplay&);
     65 
     66 	const Capability					m_capabilities;
     67 	const EGLenum						m_platformType;				//!< EGL platform type, or EGL_NONE if not supported.
     68 	const std::string					m_platformExtension;
     69 };
     70 
     71 class NativeDisplayFactory : public tcu::FactoryBase
     72 {
     73 public:
     74 	virtual								~NativeDisplayFactory		(void);
     75 
     76 	virtual NativeDisplay*				createDisplay				(const EGLAttrib* attribList = DE_NULL) const = 0;
     77 
     78 	NativeDisplay::Capability			getCapabilities				(void) const { return m_capabilities; }
     79 	EGLenum								getPlatformType				(void) const { return m_platformType; }
     80 	const char*							getPlatformExtensionName	(void) const { return (m_platformExtension.empty() ? DE_NULL : m_platformExtension.c_str()); }
     81 
     82 	const NativeWindowFactoryRegistry&	getNativeWindowRegistry		(void) const { return m_nativeWindowRegistry; }
     83 	const NativePixmapFactoryRegistry&	getNativePixmapRegistry		(void) const { return m_nativePixmapRegistry; }
     84 
     85 protected:
     86 										NativeDisplayFactory		(const std::string& name, const std::string& description, NativeDisplay::Capability capabilities);
     87 										NativeDisplayFactory		(const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, EGLenum platformType, const char* platformExtension);
     88 
     89 	NativeWindowFactoryRegistry			m_nativeWindowRegistry;
     90 	NativePixmapFactoryRegistry			m_nativePixmapRegistry;
     91 
     92 private:
     93 										NativeDisplayFactory		(const NativeDisplayFactory&);
     94 	NativeDisplayFactory&				operator=					(const NativeDisplayFactory&);
     95 
     96 	const NativeDisplay::Capability		m_capabilities;
     97 	const EGLenum						m_platformType;
     98 	const std::string					m_platformExtension;
     99 };
    100 
    101 typedef tcu::FactoryRegistry<NativeDisplayFactory> NativeDisplayFactoryRegistry;
    102 
    103 } // eglu
    104 
    105 #endif // _EGLUNATIVEDISPLAY_HPP
    106