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
30 using namespace eglw;
31
32 // NativeDisplay
33
NativeDisplay(Capability capabilities,EGLenum platformType,const char * platformExtension)34 NativeDisplay::NativeDisplay (Capability capabilities, EGLenum platformType, const char* platformExtension)
35 : m_capabilities (capabilities)
36 , m_platformType (platformType)
37 , m_platformExtension (platformExtension)
38 {
39 DE_ASSERT(platformType != EGL_NONE && platformExtension);
40 DE_ASSERT(capabilities & CAPABILITY_GET_DISPLAY_PLATFORM);
41 }
42
NativeDisplay(Capability capabilities)43 NativeDisplay::NativeDisplay (Capability capabilities)
44 : m_capabilities (capabilities)
45 , m_platformType (EGL_NONE)
46 , m_platformExtension ("")
47 {
48 DE_ASSERT(!(capabilities & CAPABILITY_GET_DISPLAY_PLATFORM));
49 DE_ASSERT(capabilities & CAPABILITY_GET_DISPLAY_LEGACY);
50 }
51
~NativeDisplay(void)52 NativeDisplay::~NativeDisplay (void)
53 {
54 }
55
getLegacyNative(void)56 EGLNativeDisplayType NativeDisplay::getLegacyNative (void)
57 {
58 // If NativeDisplay claims to support CAPABILITY_GET_DISPLAY_LEGACY then
59 // this method must be implemented.
60 TCU_CHECK_INTERNAL((m_capabilities & CAPABILITY_GET_DISPLAY_LEGACY) == 0);
61 TCU_THROW(NotSupportedError, "eglu::NativeDisplay can't be used with eglGetDisplay()");
62 }
63
getPlatformNative(void)64 void* NativeDisplay::getPlatformNative (void)
65 {
66 // If NativeDisplay claims to support CAPABILITY_GET_DISPLAY_PLATFORM then
67 // this method must be implemented.
68 TCU_CHECK_INTERNAL((m_capabilities & CAPABILITY_GET_DISPLAY_PLATFORM) == 0);
69 TCU_THROW(NotSupportedError, "eglu::NativeDisplay can't be used with eglGetPlatformDisplay()");
70 }
71
getPlatformAttributes(void) const72 const EGLAttrib* NativeDisplay::getPlatformAttributes (void) const
73 {
74 // If NativeDisplay claims to support CAPABILITY_GET_DISPLAY_PLATFORM then
75 // this method must be implemented.
76 TCU_CHECK_INTERNAL((m_capabilities & CAPABILITY_GET_DISPLAY_PLATFORM) == 0);
77 TCU_THROW(NotSupportedError, "eglu::NativeDisplay can't be used with eglGetPlatformDisplay()");
78 }
79
80 // NativeDisplayFactory
81
NativeDisplayFactory(const std::string & name,const std::string & description,NativeDisplay::Capability capabilities,EGLenum platformType,const char * platformExtension)82 NativeDisplayFactory::NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities, EGLenum platformType, const char* platformExtension)
83 : FactoryBase (name, description)
84 , m_capabilities (capabilities)
85 , m_platformType (platformType)
86 , m_platformExtension (platformExtension)
87 {
88 DE_ASSERT(platformType != EGL_NONE && platformExtension);
89 DE_ASSERT(capabilities & NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM);
90 }
91
NativeDisplayFactory(const std::string & name,const std::string & description,NativeDisplay::Capability capabilities)92 NativeDisplayFactory::NativeDisplayFactory (const std::string& name, const std::string& description, NativeDisplay::Capability capabilities)
93 : FactoryBase (name, description)
94 , m_capabilities (capabilities)
95 , m_platformType (EGL_NONE)
96 , m_platformExtension ("")
97 {
98 DE_ASSERT(!(capabilities & NativeDisplay::CAPABILITY_GET_DISPLAY_PLATFORM));
99 DE_ASSERT(capabilities & NativeDisplay::CAPABILITY_GET_DISPLAY_LEGACY);
100 }
101
~NativeDisplayFactory(void)102 NativeDisplayFactory::~NativeDisplayFactory (void)
103 {
104 }
105
106 } // eglu
107