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