summaryrefslogtreecommitdiffstats
path: root/win8/metro_driver/direct3d_helper.h
blob: 863a1469c92b0085f026a146abce5c7adabaad58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WIN8_METRO_DRIVER_DIRECT3D_HELPER_
#define WIN8_METRO_DRIVER_DIRECT3D_HELPER_


#include <windows.ui.core.h>
#include <windows.foundation.h>
#include <d3d11_1.h>

#include "base/macros.h"

namespace metro_driver {

// We need to initalize a Direct3D device and swapchain so that the browser
// can Present to our HWND. This class takes care of creating and keeping the
// swapchain up to date.
class Direct3DHelper {
 public:
  Direct3DHelper();
  ~Direct3DHelper();

  void Initialize(winui::Core::ICoreWindow* window);

 private:
  void CreateDeviceResources();
  void CreateWindowSizeDependentResources();

  winui::Core::ICoreWindow* window_;

  mswr::ComPtr<ID3D11Device1> d3d_device_;
  mswr::ComPtr<ID3D11DeviceContext1> d3d_context_;
  mswr::ComPtr<IDXGISwapChain1> swap_chain_;
  D3D_FEATURE_LEVEL feature_level_;

  ABI::Windows::Foundation::Rect window_bounds_;

  DISALLOW_COPY_AND_ASSIGN(Direct3DHelper);
};

}  // namespace metro_driver

#endif  // WIN8_METRO_DRIVER_DIRECT3D_HELPER_