1/*------------------------------------------------------------------------- 2 * drawElements Quality Program Tester Core 3 * ---------------------------------------- 4 * 5 * Copyright 2016 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 Win32 platform port. 22 *//*--------------------------------------------------------------------*/ 23 24#include "tcuWin32Platform.hpp" 25#include "tcuWGLContextFactory.hpp" 26#include "tcuWin32EGLNativeDisplayFactory.hpp" 27#include "egluGLContextFactory.hpp" 28 29// MinGW doesn't define this in its headers, but 30// still has the export in the libs. 31#if defined(__MINGW32__) 32extern "C" WINUSERAPI WINBOOL WINAPI SetProcessDPIAware(VOID); 33#endif 34 35namespace tcu 36{ 37namespace win32 38{ 39 40Platform::Platform (void) 41 : m_instance (GetModuleHandle(NULL)) 42 , m_vulkanPlatform (m_instance) 43{ 44 // Set process priority to lower. 45 SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); 46 47 48 // Set process to be DPI aware 49 // This is requried for VK tests that manually enter exclusive mode 50 // using VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT 51 if (SetProcessDPIAware() == 0) 52 { 53 TCU_FAIL("SetProcessDPIAware function failed"); 54 } 55 56 { 57 wgl::ContextFactory* factory = DE_NULL; 58 59 try 60 { 61 factory = new wgl::ContextFactory(m_instance); 62 } 63 catch (const std::exception& e) 64 { 65 print("Warning: WGL not supported: %s\n", e.what()); 66 } 67 68 if (factory) 69 { 70 try 71 { 72 m_contextFactoryRegistry.registerFactory(factory); 73 } 74 catch (...) 75 { 76 delete factory; 77 throw; 78 } 79 } 80 } 81 82 m_nativeDisplayFactoryRegistry.registerFactory(new win32::EGLNativeDisplayFactory(m_instance)); 83 m_contextFactoryRegistry.registerFactory(new eglu::GLContextFactory(m_nativeDisplayFactoryRegistry)); 84} 85 86Platform::~Platform (void) 87{ 88} 89 90bool Platform::processEvents (void) 91{ 92 MSG msg; 93 while (PeekMessage(&msg, (HWND)-1, 0, 0, PM_REMOVE)) 94 { 95 DispatchMessage(&msg); 96 if (msg.message == WM_QUIT) 97 return false; 98 } 99 return true; 100} 101 102} // win32 103} // tcu 104 105// Create platform 106tcu::Platform* createPlatform (void) 107{ 108 return new tcu::win32::Platform(); 109} 110