• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // WindowSurfaceVkWin32.cpp:
7 //    Implements the class methods for WindowSurfaceVkWin32.
8 //
9 
10 #include "libANGLE/renderer/vulkan/win32/WindowSurfaceVkWin32.h"
11 
12 #include "libANGLE/renderer/vulkan/RendererVk.h"
13 
14 namespace rx
15 {
16 
WindowSurfaceVkWin32(const egl::SurfaceState & surfaceState,EGLNativeWindowType window)17 WindowSurfaceVkWin32::WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState,
18                                            EGLNativeWindowType window)
19     : WindowSurfaceVk(surfaceState, window)
20 {}
21 
createSurfaceVk(vk::Context * context,gl::Extents * extentsOut)22 angle::Result WindowSurfaceVkWin32::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
23 {
24     VkWin32SurfaceCreateInfoKHR createInfo = {};
25 
26     createInfo.sType     = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
27     createInfo.flags     = 0;
28     createInfo.hinstance = GetModuleHandle(nullptr);
29     createInfo.hwnd      = mNativeWindowType;
30     ANGLE_VK_TRY(context, vkCreateWin32SurfaceKHR(context->getRenderer()->getInstance(),
31                                                   &createInfo, nullptr, &mSurface));
32 
33     return getCurrentWindowSize(context, extentsOut);
34 }
35 
getCurrentWindowSize(vk::Context * context,gl::Extents * extentsOut)36 angle::Result WindowSurfaceVkWin32::getCurrentWindowSize(vk::Context *context,
37                                                          gl::Extents *extentsOut)
38 {
39     RECT rect;
40     ANGLE_VK_CHECK(context, GetClientRect(mNativeWindowType, &rect) == TRUE,
41                    VK_ERROR_INITIALIZATION_FAILED);
42 
43     *extentsOut = gl::Extents(rect.right - rect.left, rect.bottom - rect.top, 1);
44     return angle::Result::Continue;
45 }
46 
47 }  // namespace rx
48