blob: 403f9bc3e68a908eedbfbf5fc61a907dbf3d7815 [file] [log] [blame]
Cooper Partineeb1f532014-09-23 10:25:02 -07001//
2// Copyright (c) 2002-2014 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
7// NativeWindow.cpp: Handler for managing HWND native window types.
8
9#include "common/NativeWindow.h"
10#include "common/debug.h"
11
12bool isValidEGLNativeWindowType(EGLNativeWindowType window)
13{
14 return (IsWindow(window) == TRUE);
15}
16
17namespace rx
18{
19NativeWindow::NativeWindow(EGLNativeWindowType window) : mWindow(window)
20{
21}
22
Cooper Partineeb1f532014-09-23 10:25:02 -070023HRESULT NativeWindow::createSwapChain(ID3D11Device* device, DXGIFactory* factory,
24 DXGI_FORMAT format, unsigned int width, unsigned int height,
25 DXGISwapChain** swapChain)
26{
27 if (device == NULL || factory == NULL || swapChain == NULL || width == 0 || height == 0)
28 {
29 return E_INVALIDARG;
30 }
31
32 DXGI_SWAP_CHAIN_DESC swapChainDesc = { 0 };
33 swapChainDesc.BufferCount = 1;
34 swapChainDesc.BufferDesc.Format = format;
35 swapChainDesc.BufferDesc.Width = width;
36 swapChainDesc.BufferDesc.Height = height;
37 swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
38 swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
39 swapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
40 swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
41 swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_BACK_BUFFER;
42 swapChainDesc.Flags = 0;
43 swapChainDesc.OutputWindow = mWindow;
44 swapChainDesc.SampleDesc.Count = 1;
45 swapChainDesc.SampleDesc.Quality = 0;
46 swapChainDesc.Windowed = TRUE;
47 swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
48
49 return factory->CreateSwapChain(device, &swapChainDesc, swapChain);
50}
51};