1e5c31af7Sopenharmony_ci#ifndef _VKWSIPLATFORM_HPP 2e5c31af7Sopenharmony_ci#define _VKWSIPLATFORM_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci * Vulkan CTS Framework 5e5c31af7Sopenharmony_ci * -------------------- 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright (c) 2016 Google Inc. 8e5c31af7Sopenharmony_ci * 9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci * 15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci * limitations under the License. 20e5c31af7Sopenharmony_ci * 21e5c31af7Sopenharmony_ci *//*! 22e5c31af7Sopenharmony_ci * \file 23e5c31af7Sopenharmony_ci * \brief WSI Platform Abstraction. 24e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci#include "vkDefs.hpp" 27e5c31af7Sopenharmony_ci#include "tcuCommandLine.hpp" 28e5c31af7Sopenharmony_ci#include "tcuVector.hpp" 29e5c31af7Sopenharmony_ci#include "tcuMaybe.hpp" 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_cinamespace vk 32e5c31af7Sopenharmony_ci{ 33e5c31af7Sopenharmony_cinamespace wsi 34e5c31af7Sopenharmony_ci{ 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ciclass Window 37e5c31af7Sopenharmony_ci{ 38e5c31af7Sopenharmony_cipublic: 39e5c31af7Sopenharmony_ci virtual ~Window (void) {} 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ci virtual void setVisible (bool visible); 42e5c31af7Sopenharmony_ci virtual void setForeground (void); 43e5c31af7Sopenharmony_ci virtual void resize (const tcu::UVec2& newSize); 44e5c31af7Sopenharmony_ci virtual void setMinimized (bool minized); 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_ciprotected: 47e5c31af7Sopenharmony_ci Window (void) {} 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ciprivate: 50e5c31af7Sopenharmony_ci Window (const Window&); // Not allowed 51e5c31af7Sopenharmony_ci Window& operator= (const Window&); // Not allowed 52e5c31af7Sopenharmony_ci}; 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_ciclass Display 55e5c31af7Sopenharmony_ci{ 56e5c31af7Sopenharmony_cipublic: 57e5c31af7Sopenharmony_ci virtual ~Display (void) {} 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_ci virtual Window* createWindow (const tcu::Maybe<tcu::UVec2>& initialSize = tcu::Nothing) const = 0; 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_ciprotected: 62e5c31af7Sopenharmony_ci Display (void) {} 63e5c31af7Sopenharmony_ci 64e5c31af7Sopenharmony_ciprivate: 65e5c31af7Sopenharmony_ci Display (const Display&); // Not allowed 66e5c31af7Sopenharmony_ci Display& operator= (const Display&); // Not allowed 67e5c31af7Sopenharmony_ci}; 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ci// WSI implementation-specific APIs 70e5c31af7Sopenharmony_ci 71e5c31af7Sopenharmony_citemplate<int WsiType> 72e5c31af7Sopenharmony_cistruct TypeTraits; 73e5c31af7Sopenharmony_ci// { 74e5c31af7Sopenharmony_ci// typedef <NativeDisplayType> NativeDisplayType; 75e5c31af7Sopenharmony_ci// typedef <NativeWindowType> NativeWindowType; 76e5c31af7Sopenharmony_ci// }; 77e5c31af7Sopenharmony_ci 78e5c31af7Sopenharmony_citemplate<int WsiType> 79e5c31af7Sopenharmony_cistruct DisplayInterface : public Display 80e5c31af7Sopenharmony_ci{ 81e5c31af7Sopenharmony_cipublic: 82e5c31af7Sopenharmony_ci typedef typename TypeTraits<WsiType>::NativeDisplayType NativeType; 83e5c31af7Sopenharmony_ci 84e5c31af7Sopenharmony_ci NativeType getNative (void) const { return m_native; } 85e5c31af7Sopenharmony_ci 86e5c31af7Sopenharmony_ciprotected: 87e5c31af7Sopenharmony_ci DisplayInterface (NativeType nativeDisplay) 88e5c31af7Sopenharmony_ci : m_native(nativeDisplay) 89e5c31af7Sopenharmony_ci {} 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_ci const NativeType m_native; 92e5c31af7Sopenharmony_ci}; 93e5c31af7Sopenharmony_ci 94e5c31af7Sopenharmony_citemplate<int WsiType> 95e5c31af7Sopenharmony_cistruct WindowInterface : public Window 96e5c31af7Sopenharmony_ci{ 97e5c31af7Sopenharmony_cipublic: 98e5c31af7Sopenharmony_ci typedef typename TypeTraits<WsiType>::NativeWindowType NativeType; 99e5c31af7Sopenharmony_ci 100e5c31af7Sopenharmony_ci NativeType getNative (void) const { return m_native; } 101e5c31af7Sopenharmony_ci 102e5c31af7Sopenharmony_ciprotected: 103e5c31af7Sopenharmony_ci WindowInterface (NativeType nativeDisplay) 104e5c31af7Sopenharmony_ci : m_native(nativeDisplay) 105e5c31af7Sopenharmony_ci {} 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ci const NativeType m_native; 108e5c31af7Sopenharmony_ci}; 109e5c31af7Sopenharmony_ci 110e5c31af7Sopenharmony_ci// VK_KHR_xlib_surface 111e5c31af7Sopenharmony_ci 112e5c31af7Sopenharmony_citemplate<> 113e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_XLIB> 114e5c31af7Sopenharmony_ci{ 115e5c31af7Sopenharmony_ci typedef pt::XlibDisplayPtr NativeDisplayType; 116e5c31af7Sopenharmony_ci typedef pt::XlibWindow NativeWindowType; 117e5c31af7Sopenharmony_ci}; 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_citypedef DisplayInterface<TYPE_XLIB> XlibDisplayInterface; 120e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_XLIB> XlibWindowInterface; 121e5c31af7Sopenharmony_ci 122e5c31af7Sopenharmony_ci// VK_KHR_xcb_surface 123e5c31af7Sopenharmony_ci 124e5c31af7Sopenharmony_citemplate<> 125e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_XCB> 126e5c31af7Sopenharmony_ci{ 127e5c31af7Sopenharmony_ci typedef pt::XcbConnectionPtr NativeDisplayType; 128e5c31af7Sopenharmony_ci typedef pt::XcbWindow NativeWindowType; 129e5c31af7Sopenharmony_ci}; 130e5c31af7Sopenharmony_ci 131e5c31af7Sopenharmony_citypedef DisplayInterface<TYPE_XCB> XcbDisplayInterface; 132e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_XCB> XcbWindowInterface; 133e5c31af7Sopenharmony_ci 134e5c31af7Sopenharmony_ci// VK_KHR_wayland_surface 135e5c31af7Sopenharmony_ci 136e5c31af7Sopenharmony_citemplate<> 137e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_WAYLAND> 138e5c31af7Sopenharmony_ci{ 139e5c31af7Sopenharmony_ci typedef pt::WaylandDisplayPtr NativeDisplayType; 140e5c31af7Sopenharmony_ci typedef pt::WaylandSurfacePtr NativeWindowType; 141e5c31af7Sopenharmony_ci}; 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_citypedef DisplayInterface<TYPE_WAYLAND> WaylandDisplayInterface; 144e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_WAYLAND> WaylandWindowInterface; 145e5c31af7Sopenharmony_ci 146e5c31af7Sopenharmony_ci// VK_EXT_acquire_drm_display 147e5c31af7Sopenharmony_ci 148e5c31af7Sopenharmony_citemplate<> 149e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_DIRECT_DRM> 150e5c31af7Sopenharmony_ci{ 151e5c31af7Sopenharmony_ci typedef VkDisplayKHR NativeDisplayType; 152e5c31af7Sopenharmony_ci}; 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_cistruct DirectDrmDisplayInterface : public DisplayInterface<TYPE_DIRECT_DRM> 155e5c31af7Sopenharmony_ci{ 156e5c31af7Sopenharmony_cipublic: 157e5c31af7Sopenharmony_ci DirectDrmDisplayInterface (void) 158e5c31af7Sopenharmony_ci : DisplayInterface(DE_NULL) 159e5c31af7Sopenharmony_ci {} 160e5c31af7Sopenharmony_ci virtual void initializeDisplay (const InstanceInterface& vki, VkInstance instance, const tcu::CommandLine& cmdLine) 161e5c31af7Sopenharmony_ci { 162e5c31af7Sopenharmony_ci DE_UNREF(vki); 163e5c31af7Sopenharmony_ci DE_UNREF(instance); 164e5c31af7Sopenharmony_ci DE_UNREF(cmdLine); 165e5c31af7Sopenharmony_ci } 166e5c31af7Sopenharmony_ci}; 167e5c31af7Sopenharmony_ci 168e5c31af7Sopenharmony_ci// VK_KHR_mir_surface 169e5c31af7Sopenharmony_ci 170e5c31af7Sopenharmony_ci// VK_KHR_android_surface 171e5c31af7Sopenharmony_ci 172e5c31af7Sopenharmony_citemplate<> 173e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_ANDROID> 174e5c31af7Sopenharmony_ci{ 175e5c31af7Sopenharmony_ci typedef pt::AndroidNativeWindowPtr NativeWindowType; 176e5c31af7Sopenharmony_ci}; 177e5c31af7Sopenharmony_ci 178e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_ANDROID> AndroidWindowInterface; 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci// VK_KHR_win32_surface 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_citemplate<> 183e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_WIN32> 184e5c31af7Sopenharmony_ci{ 185e5c31af7Sopenharmony_ci typedef pt::Win32InstanceHandle NativeDisplayType; 186e5c31af7Sopenharmony_ci typedef pt::Win32WindowHandle NativeWindowType; 187e5c31af7Sopenharmony_ci}; 188e5c31af7Sopenharmony_ci 189e5c31af7Sopenharmony_citypedef DisplayInterface<TYPE_WIN32> Win32DisplayInterface; 190e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_WIN32> Win32WindowInterface; 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ci// VK_MVK_macos_surface 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_citemplate<> 195e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_MACOS> 196e5c31af7Sopenharmony_ci{ 197e5c31af7Sopenharmony_ci typedef void* NativeWindowType; 198e5c31af7Sopenharmony_ci}; 199e5c31af7Sopenharmony_ci 200e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_MACOS> MacOSWindowInterface; 201e5c31af7Sopenharmony_ci 202e5c31af7Sopenharmony_ci// VK_OHOS_surface 203e5c31af7Sopenharmony_ci 204e5c31af7Sopenharmony_citemplate<> 205e5c31af7Sopenharmony_cistruct TypeTraits<TYPE_OHOS> 206e5c31af7Sopenharmony_ci{ 207e5c31af7Sopenharmony_ci typedef pt::OhosNativeWindowPtr NativeWindowType; 208e5c31af7Sopenharmony_ci}; 209e5c31af7Sopenharmony_ci 210e5c31af7Sopenharmony_citypedef WindowInterface<TYPE_OHOS> OhosWindowInterface; 211e5c31af7Sopenharmony_ci 212e5c31af7Sopenharmony_ci} // wsi 213e5c31af7Sopenharmony_ci} // vk 214e5c31af7Sopenharmony_ci 215e5c31af7Sopenharmony_ci#endif // _VKWSIPLATFORM_HPP 216