blob: aa2bfa4e21458a178892dd980d7b370a89e9dc89 [file] [log] [blame]
Cooper Partineeb1f532014-09-23 10:25:02 -07001//
Cooper Partin980eb8f2014-10-22 07:42:59 -07002// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
Cooper Partineeb1f532014-09-23 10:25:02 -07003// 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 Partin980eb8f2014-10-22 07:42:59 -070012namespace rx
13{
14bool IsValidEGLNativeWindowType(EGLNativeWindowType window)
Cooper Partineeb1f532014-09-23 10:25:02 -070015{
16 return (IsWindow(window) == TRUE);
17}
18
Cooper Partineeb1f532014-09-23 10:25:02 -070019NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
20{
21}
22
Cooper Partin88d3b8c2014-10-08 10:41:56 -070023bool NativeWindow::initialize()
24{
25 return true;
26}
27
28bool NativeWindow::getClientRect(LPRECT rect)
29{
30 return GetClientRect(mWindow, rect) == TRUE;
31}
32
33bool NativeWindow::isIconic()
34{
35 return IsIconic(mWindow) == TRUE;
36}
37
Cooper Partineeb1f532014-09-23 10:25:02 -070038HRESULT 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 Partin980eb8f2014-10-22 07:42:59 -070066}