• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program Tester Core
3  * ----------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief EGL native display abstraction
22  *//*--------------------------------------------------------------------*/
23 
24 #include "egluNativeDisplay.hpp"
25 #include "eglwEnums.hpp"
26 
27 namespace eglu
28 {
29 namespace
30 {
31 static const NativeDisplay::Capability platformCapabilities =
32 	static_cast<NativeDisplay::Capability>(NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM | NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM_EXT);
33 }
34 
35 using namespace eglw;
36 
37 // NativeDisplay
38 
NativeDisplay(Capability capabilities,EGLenum platformType,const char * platformExtension)39 NativeDisplay::NativeDisplay (Capability capabilities, EGLenum platformType, const char* platformExtension)
40 	: m_capabilities		(capabilities)
41 	, m_platformType		(platformType)
42 	, m_platformExtension	(platformExtension)
43 {
44 	DE_ASSERT(platformType != EGL_NONE && platformExtension);
45 	DE_ASSERT(capabilities & platformCapabilities);
46 }
47 
NativeDisplay(Capability capabilities)48 NativeDisplay::NativeDisplay (Capability capabilities)
49 	: m_capabilities		(capabilities)
50 	, m_platformType		(EGL_NONE)
51 	, m_platformExtension	("")
52 {
53 	DE_ASSERT(!(capabilities & platformCapabilities));
54 	DE_ASSERT(capabilities & CAPABILITY_GET_DISPLAY_LEGACY);
55 }
56 
~NativeDisplay(void)57 NativeDisplay::~NativeDisplay (void)
58 {
59 }
60 
getLegacyNative(void)61 EGLNativeDisplayType NativeDisplay::getLegacyNative (void)
62 {
63 	// If NativeDisplay claims to support CAPABILITY_GET_DISPLAY_LEGACY then
64 	// this method must be implemented.
65 	TCU_CHECK_INTERNAL((m_capabilities & CAPABILITY_GET_DISPLAY_LEGACY) == 0);
66 	TCU_THROW(NotSupportedError, "eglu::NativeDisplay can't be used with eglGetDisplay()");
67 }
68 
getPlatformNative(void)69 void* NativeDisplay::getPlatformNative (void)
70 {
71 	// If NativeDisplay claims to support CAPABILITY_GET_DISPLAY_PLATFORM or CAPABILITY_GET_DISPLAY_PLATFORM_EXT
72 	// then this method must be implemented.
73 	TCU_CHECK_INTERNAL((m_capabilities & platformCapabilities) == 0);
74 	TCU_THROW(NotSupportedError, "eglu::NativeDisplay can't be used with eglGetPlatformDisplay or eglGetPlatformDisplayEXT()");
75 }
76 
getPlatformAttributes(void) const77 const EGLAttrib* NativeDisplay::getPlatformAttributes (void) const
78 {
79 	// If NativeDisplay claims to support CAPABILITY_GET_DISPLAY_PLATFORM or CAPABILITY_GET_DISPLAY_PLATFORM_EXT
80 	// then this method must be implemented.
81 	TCU_CHECK_INTERNAL((m_capabilities & platformCapabilities) == 0);
82 	TCU_THROW(NotSupportedError, "eglu::NativeDisplay can't be used with eglGetPlatformDisplay or eglGetPlatformDisplayEXT()");
83 }
84 
85 // NativeDisplayFactory
86 
NativeDisplayFactory(const std::string & name,const std::string & description,NativeDisplay::Capability capabilities,EGLenum platformType,const char * platformExtension)87 NativeDisplayFactory::NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, EGLenum platformType, const char* platformExtension)
88 	: FactoryBase			(name, description)
89 	, m_capabilities		(capabilities)
90 	, m_platformType		(platformType)
91 	, m_platformExtension	(platformExtension)
92 {
93 	DE_ASSERT(platformType != EGL_NONE && (platformExtension || (platformCapabilities & NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM)));
94 	DE_ASSERT(capabilities & platformCapabilities);
95 }
96 
NativeDisplayFactory(const std::string & name,const std::string & description,NativeDisplay::Capability capabilities)97 NativeDisplayFactory::NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities)
98 	: FactoryBase			(name, description)
99 	, m_capabilities		(capabilities)
100 	, m_platformType		(EGL_NONE)
101 	, m_platformExtension	("")
102 {
103 	DE_ASSERT(!(capabilities & platformCapabilities));
104 	DE_ASSERT(capabilities & NativeDisplay::CAPABILITY_GET_DISPLAY_LEGACY);
105 }
106 
~NativeDisplayFactory(void)107 NativeDisplayFactory::~NativeDisplayFactory (void)
108 {
109 }
110 
111 } // eglu
112