Cooper Partin | eeb1f53 | 2014-09-23 10:25:02 -0700 | [diff] [blame] | 1 | // |
Cooper Partin | 980eb8f | 2014-10-22 07:42:59 -0700 | [diff] [blame] | 2 | // Copyright (c) 2014 The ANGLE Project Authors. All rights reserved. |
Cooper Partin | eeb1f53 | 2014-09-23 10:25:02 -0700 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // NativeWindow.cpp: Handler for managing HWND native window types. |
| 8 | |
| 9 | #include "common/NativeWindow.h" |
| 10 | #include "common/debug.h" |
| 11 | |
Cooper Partin | 980eb8f | 2014-10-22 07:42:59 -0700 | [diff] [blame] | 12 | namespace rx |
| 13 | { |
| 14 | bool IsValidEGLNativeWindowType(EGLNativeWindowType window) |
Cooper Partin | eeb1f53 | 2014-09-23 10:25:02 -0700 | [diff] [blame] | 15 | { |
| 16 | return (IsWindow(window) == TRUE); |
| 17 | } |
| 18 | |
Cooper Partin | eeb1f53 | 2014-09-23 10:25:02 -0700 | [diff] [blame] | 19 | NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window) |
| 20 | { |
| 21 | } |
| 22 | |
Cooper Partin | 88d3b8c | 2014-10-08 10:41:56 -0700 | [diff] [blame] | 23 | bool NativeWindow::initialize() |
| 24 | { |
| 25 | return true; |
| 26 | } |
| 27 | |
| 28 | bool NativeWindow::getClientRect(LPRECT rect) |
| 29 | { |
| 30 | return GetClientRect(mWindow, rect) == TRUE; |
| 31 | } |
| 32 | |
| 33 | bool NativeWindow::isIconic() |
| 34 | { |
| 35 | return IsIconic(mWindow) == TRUE; |
| 36 | } |
| 37 | |
Cooper Partin | eeb1f53 | 2014-09-23 10:25:02 -0700 | [diff] [blame] | 38 | HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory, |
| 39 | DXGI_FORMAT format, unsigned int width, unsigned int height, |
| 40 | DXGISwapChain** swapChain) |
| 41 | { |
| 42 | if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0) |
| 43 | { |
| 44 | return E_INVALIDARG; |
| 45 | } |
| 46 | |
| 47 | DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 }; |
| 48 | swapChainDesc.BufferCount = 1; |
| 49 | swapChainDesc.BufferDesc.Format = format; |
| 50 | swapChainDesc.BufferDesc.Width = width; |
| 51 | swapChainDesc.BufferDesc.Height = height; |
| 52 | swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; |
| 53 | swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; |
| 54 | swapChainDesc.BufferDesc.RefreshRate.Numerator = 0; |
| 55 | swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; |
| 56 | swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER; |
| 57 | swapChainDesc.Flags = 0; |
| 58 | swapChainDesc.OutputWindow = mWindow; |
| 59 | swapChainDesc.SampleDesc.Count = 1; |
| 60 | swapChainDesc.SampleDesc.Quality = 0; |
| 61 | swapChainDesc.Windowed = TRUE; |
| 62 | swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; |
| 63 | |
| 64 | return factory->CreateSwapChain(device, &swapChainDesc, swapChain); |
| 65 | } |
Cooper Partin | 980eb8f | 2014-10-22 07:42:59 -0700 | [diff] [blame] | 66 | } |