1#ifndef _VKWSIPLATFORM_HPP 2#define _VKWSIPLATFORM_HPP 3/*------------------------------------------------------------------------- 4 * Vulkan CTS Framework 5 * -------------------- 6 * 7 * Copyright (c) 2016 Google Inc. 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 WSI Platform Abstraction. 24 *//*--------------------------------------------------------------------*/ 25 26#include "vkDefs.hpp" 27#include "tcuVector.hpp" 28#include "tcuMaybe.hpp" 29 30namespace vk 31{ 32namespace wsi 33{ 34 35class Window 36{ 37public: 38 virtual ~Window (void) {} 39 40 virtual void resize (const tcu::UVec2& newSize); 41 42protected: 43 Window (void) {} 44 45private: 46 Window (const Window&); // Not allowed 47 Window& operator= (const Window&); // Not allowed 48}; 49 50class Display 51{ 52public: 53 virtual ~Display (void) {} 54 55 virtual Window* createWindow (const tcu::Maybe<tcu::UVec2>& initialSize = tcu::nothing<tcu::UVec2>()) const = 0; 56 57protected: 58 Display (void) {} 59 60private: 61 Display (const Display&); // Not allowed 62 Display& operator= (const Display&); // Not allowed 63}; 64 65// WSI implementation-specific APIs 66 67template<int WsiType> 68struct TypeTraits; 69// { 70// typedef <NativeDisplayType> NativeDisplayType; 71// typedef <NativeWindowType> NativeWindowType; 72// }; 73 74template<int WsiType> 75struct DisplayInterface : public Display 76{ 77public: 78 typedef typename TypeTraits<WsiType>::NativeDisplayType NativeType; 79 80 NativeType getNative (void) const { return m_native; } 81 82protected: 83 DisplayInterface (NativeType nativeDisplay) 84 : m_native(nativeDisplay) 85 {} 86 87 const NativeType m_native; 88}; 89 90template<int WsiType> 91struct WindowInterface : public Window 92{ 93public: 94 typedef typename TypeTraits<WsiType>::NativeWindowType NativeType; 95 96 NativeType getNative (void) const { return m_native; } 97 98protected: 99 WindowInterface (NativeType nativeDisplay) 100 : m_native(nativeDisplay) 101 {} 102 103 const NativeType m_native; 104}; 105 106// VK_KHR_xlib_surface 107 108template<> 109struct TypeTraits<TYPE_XLIB> 110{ 111 typedef pt::XlibDisplayPtr NativeDisplayType; 112 typedef pt::XlibWindow NativeWindowType; 113}; 114 115typedef DisplayInterface<TYPE_XLIB> XlibDisplayInterface; 116typedef WindowInterface<TYPE_XLIB> XlibWindowInterface; 117 118// VK_KHR_xcb_surface 119 120template<> 121struct TypeTraits<TYPE_XCB> 122{ 123 typedef pt::XcbConnectionPtr NativeDisplayType; 124 typedef pt::XcbWindow NativeWindowType; 125}; 126 127typedef DisplayInterface<TYPE_XCB> XcbDisplayInterface; 128typedef WindowInterface<TYPE_XCB> XcbWindowInterface; 129 130// VK_KHR_wayland_surface 131 132template<> 133struct TypeTraits<TYPE_WAYLAND> 134{ 135 typedef pt::WaylandDisplayPtr NativeDisplayType; 136 typedef pt::WaylandSurfacePtr NativeWindowType; 137}; 138 139typedef DisplayInterface<TYPE_WAYLAND> WaylandDisplayInterface; 140typedef WindowInterface<TYPE_WAYLAND> WaylandWindowInterface; 141 142// VK_KHR_mir_surface 143 144template<> 145struct TypeTraits<TYPE_MIR> 146{ 147 typedef pt::MirConnectionPtr NativeDisplayType; 148 typedef pt::MirSurfacePtr NativeWindowType; 149}; 150 151typedef DisplayInterface<TYPE_MIR> MirDisplayInterface; 152typedef WindowInterface<TYPE_MIR> MirWindowInterface; 153 154// VK_KHR_android_surface 155 156template<> 157struct TypeTraits<TYPE_ANDROID> 158{ 159 typedef pt::AndroidNativeWindowPtr NativeWindowType; 160}; 161 162typedef WindowInterface<TYPE_ANDROID> AndroidWindowInterface; 163 164// VK_KHR_win32_surface 165 166template<> 167struct TypeTraits<TYPE_WIN32> 168{ 169 typedef pt::Win32InstanceHandle NativeDisplayType; 170 typedef pt::Win32WindowHandle NativeWindowType; 171}; 172 173typedef DisplayInterface<TYPE_WIN32> Win32DisplayInterface; 174typedef WindowInterface<TYPE_WIN32> Win32WindowInterface; 175 176} // wsi 177} // vk 178 179#endif // _VKWSIPLATFORM_HPP 180