4#include <QtCore/qt_windows.h>
11#include <d2d1_1helper.h>
27 D3D_FEATURE_LEVEL
level;
29 D3D_DRIVER_TYPE typeAttempts[] = {
30 D3D_DRIVER_TYPE_HARDWARE,
33 const int ntypes = int(
sizeof(typeAttempts) /
sizeof(typeAttempts[0]));
35 for (
int i = 0;
i < ntypes;
i++) {
36 hr = D3D11CreateDevice(
nullptr,
39 D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_BGRA_SUPPORT,
52 qWarning(
"%s: Could not create Direct3D Device: %#lx", __FUNCTION__, hr);
61 qWarning(
"%s: DXGI Device interface query failed on D3D Device: %#lx", __FUNCTION__, hr);
66 dxgiDevice->SetMaximumFrameLatency(1);
68 hr = dxgiDevice->GetAdapter(&dxgiAdapter);
70 qWarning(
"%s: Failed to probe DXGI Device for parent DXGI Adapter: %#lx", __FUNCTION__, hr);
74 hr = dxgiAdapter->GetParent(IID_PPV_ARGS(&
dxgiFactory));
76 qWarning(
"%s: Failed to probe DXGI Adapter for parent DXGI Factory: %#lx", __FUNCTION__, hr);
80 D2D1_FACTORY_OPTIONS options = {};
82#ifdef QT_D2D_DEBUG_OUTPUT
83 qDebug(
"Turning on Direct2D debugging messages");
84 options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
87 hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, options,
d2dFactory.GetAddressOf());
89 qWarning(
"%s: Could not create Direct2D Factory: %#lx", __FUNCTION__, hr);
95 qWarning(
"%s: Could not create D2D Device: %#lx", __FUNCTION__, hr);
99 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
102 qWarning(
"%s: Could not create DirectWrite factory: %#lx", __FUNCTION__, hr);
108 qWarning(
"%s: Could not create DirectWrite GDI Interop: %#lx", __FUNCTION__, hr);
145 return d->d3dDevice.Get();
151 return d->d2dDevice.Get();
157 return d->d2dFactory.Get();
163 return d->dxgiFactory.Get();
169 return d->d3dDeviceContext.Get();
175 return d->directWriteFactory.Get();
181 return d->directWriteGdiInterop.Get();
ComPtr< IDWriteFactory > directWriteFactory
ComPtr< ID2D1Factory1 > d2dFactory
ComPtr< ID3D11Device > d3dDevice
ComPtr< ID2D1Device > d2dDevice
ComPtr< IDXGIFactory2 > dxgiFactory
ComPtr< IDWriteGdiInterop > directWriteGdiInterop
ComPtr< ID3D11DeviceContext > d3dDeviceContext
ID2D1Factory1 * d2dFactory() const
~QWindowsDirect2DContext()
ID3D11Device * d3dDevice() const
ID2D1Device * d2dDevice() const
IDXGIFactory2 * dxgiFactory() const
IDWriteGdiInterop * dwriteGdiInterop() const
QWindowsDirect2DContext()
ID3D11DeviceContext * d3dDeviceContext() const
IDWriteFactory * dwriteFactory() const
static QWindowsDirect2DContext * instance()
QWindowsDirect2DContext * direct2DContext() const
static QWindowsDirect2DIntegration * instance()
Combined button and popup list for selecting options.
GLenum GLuint GLint level