Fix build when enabling wxD2D_DEVICE_CONTEXT_SUPPORTED

Add missing GUID and function for dynamic linking.
This commit is contained in:
Maarten Bent
2018-11-04 16:34:25 +01:00
parent e1e5169e4b
commit 9554cb49d8

View File

@@ -23,6 +23,9 @@
#define D2D1MakeSkewMatrix wxD2D1MakeSkewMatrix #define D2D1MakeSkewMatrix wxD2D1MakeSkewMatrix
#define D2D1IsMatrixInvertible wxD2D1IsMatrixInvertible #define D2D1IsMatrixInvertible wxD2D1IsMatrixInvertible
#define D2D1InvertMatrix wxD2D1InvertMatrix #define D2D1InvertMatrix wxD2D1InvertMatrix
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
#define D3D11CreateDevice wxD3D11CreateDevice
#endif
// There are clashes between the names of the member fields and parameters // There are clashes between the names of the member fields and parameters
// in the standard d2d1helper.h header resulting in C4458 with VC14, // in the standard d2d1helper.h header resulting in C4458 with VC14,
@@ -42,9 +45,9 @@
#endif #endif
#if wxD2D_DEVICE_CONTEXT_SUPPORTED #if wxD2D_DEVICE_CONTEXT_SUPPORTED
#include <D3D11.h> #include <d3d11.h>
#include <D2d1_1.h> #include <d2d1_1.h>
#include <DXGI1_2.h> #include <dxgi1_2.h>
#endif #endif
#ifdef __VISUALC__ #ifdef __VISUALC__
@@ -155,6 +158,11 @@ private:
if ( !m_dllDirectWrite.Load(wxT("dwrite.dll"), wxDL_VERBATIM | wxDL_QUIET) ) if ( !m_dllDirectWrite.Load(wxT("dwrite.dll"), wxDL_VERBATIM | wxDL_QUIET) )
return false; return false;
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
if (!m_dllDirect3d.Load(wxT("d3d11.dll"), wxDL_VERBATIM | wxDL_QUIET))
return false;
#endif
#define wxLOAD_FUNC(dll, name) \ #define wxLOAD_FUNC(dll, name) \
name = (name##_t)dll.RawGetSymbol(#name); \ name = (name##_t)dll.RawGetSymbol(#name); \
if ( !name ) \ if ( !name ) \
@@ -167,6 +175,10 @@ private:
wxLOAD_FUNC(m_dllDirect2d, D2D1InvertMatrix); wxLOAD_FUNC(m_dllDirect2d, D2D1InvertMatrix);
wxLOAD_FUNC(m_dllDirectWrite, DWriteCreateFactory); wxLOAD_FUNC(m_dllDirectWrite, DWriteCreateFactory);
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
wxLOAD_FUNC(m_dllDirect3d, D3D11CreateDevice);
#endif
m_D2DRuntimeVersion = wxD2D_VERSION_1_0; m_D2DRuntimeVersion = wxD2D_VERSION_1_0;
return true; return true;
@@ -191,6 +203,11 @@ public:
typedef HRESULT (WINAPI *DWriteCreateFactory_t)(DWRITE_FACTORY_TYPE, REFIID, IUnknown**); typedef HRESULT (WINAPI *DWriteCreateFactory_t)(DWRITE_FACTORY_TYPE, REFIID, IUnknown**);
static DWriteCreateFactory_t DWriteCreateFactory; static DWriteCreateFactory_t DWriteCreateFactory;
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
typedef HRESULT (WINAPI *D3D11CreateDevice_t)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT, CONST D3D_FEATURE_LEVEL*, UINT, UINT, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext**);
static D3D11CreateDevice_t D3D11CreateDevice;
#endif
private: private:
static bool m_initialized; static bool m_initialized;
static bool m_hasDirect2DSupport; static bool m_hasDirect2DSupport;
@@ -198,6 +215,9 @@ private:
static wxDynamicLibrary m_dllDirect2d; static wxDynamicLibrary m_dllDirect2d;
static wxDynamicLibrary m_dllDirectWrite; static wxDynamicLibrary m_dllDirectWrite;
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
static wxDynamicLibrary m_dllDirect3d;
#endif
}; };
// define the members // define the members
@@ -207,6 +227,9 @@ wxDirect2D::wxD2DVersion wxDirect2D::m_D2DRuntimeVersion = wxD2D_VERSION_NONE;
wxDynamicLibrary wxDirect2D::m_dllDirect2d; wxDynamicLibrary wxDirect2D::m_dllDirect2d;
wxDynamicLibrary wxDirect2D::m_dllDirectWrite; wxDynamicLibrary wxDirect2D::m_dllDirectWrite;
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
wxDynamicLibrary wxDirect2D::m_dllDirect3d;
#endif
// define the (not yet imported) functions // define the (not yet imported) functions
wxDirect2D::D2D1CreateFactory_t wxDirect2D::D2D1CreateFactory = NULL; wxDirect2D::D2D1CreateFactory_t wxDirect2D::D2D1CreateFactory = NULL;
@@ -216,6 +239,10 @@ wxDirect2D::D2D1IsMatrixInvertible_t wxDirect2D::D2D1IsMatrixInvertible = NULL;
wxDirect2D::D2D1InvertMatrix_t wxDirect2D::D2D1InvertMatrix = NULL; wxDirect2D::D2D1InvertMatrix_t wxDirect2D::D2D1InvertMatrix = NULL;
wxDirect2D::DWriteCreateFactory_t wxDirect2D::DWriteCreateFactory = NULL; wxDirect2D::DWriteCreateFactory_t wxDirect2D::DWriteCreateFactory = NULL;
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
wxDirect2D::D3D11CreateDevice_t wxDirect2D::D3D11CreateDevice = NULL;
#endif
// define the interface GUIDs // define the interface GUIDs
DEFINE_GUID(wxIID_IWICImagingFactory, DEFINE_GUID(wxIID_IWICImagingFactory,
0xec5ec8a9, 0xc395, 0x4314, 0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70); 0xec5ec8a9, 0xc395, 0x4314, 0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70);
@@ -235,6 +262,11 @@ DEFINE_GUID(GUID_WICPixelFormat32bppPBGRA,
DEFINE_GUID(GUID_WICPixelFormat32bppBGR, DEFINE_GUID(GUID_WICPixelFormat32bppBGR,
0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0e); 0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0e);
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
DEFINE_GUID(IID_IDXGIDevice,
0x54ec77fa, 0x1377, 0x44e6, 0x8c, 0x32, 0x88, 0xfd, 0x5f, 0x44, 0xc8, 0x4c);
#endif
#ifndef CLSID_WICImagingFactory #ifndef CLSID_WICImagingFactory
DEFINE_GUID(CLSID_WICImagingFactory, DEFINE_GUID(CLSID_WICImagingFactory,
0xcacaf262, 0x9370, 0x4615, 0xa1, 0x3b, 0x9f, 0x55, 0x39, 0xda, 0x4c, 0xa); 0xcacaf262, 0x9370, 0x4615, 0xa1, 0x3b, 0x9f, 0x55, 0x39, 0xda, 0x4c, 0xa);
@@ -298,6 +330,36 @@ BOOL WINAPI wxD2D1InvertMatrix(
return wxDirect2D::D2D1InvertMatrix(matrix); return wxDirect2D::D2D1InvertMatrix(matrix);
} }
#if wxD2D_DEVICE_CONTEXT_SUPPORTED
HRESULT WINAPI wxD3D11CreateDevice(
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
CONST D3D_FEATURE_LEVEL* pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
ID3D11Device** ppDevice,
D3D_FEATURE_LEVEL* pFeatureLevel,
ID3D11DeviceContext** ppImmediateContext)
{
if (!wxDirect2D::Initialize())
return S_FALSE;
return wxDirect2D::D3D11CreateDevice(
pAdapter,
DriverType,
Software,
Flags,
pFeatureLevels,
FeatureLevels,
SDKVersion,
ppDevice,
pFeatureLevel,
ppImmediateContext);
}
#endif
static IWICImagingFactory* gs_WICImagingFactory = NULL; static IWICImagingFactory* gs_WICImagingFactory = NULL;
IWICImagingFactory* wxWICImagingFactory() IWICImagingFactory* wxWICImagingFactory()
@@ -401,7 +463,7 @@ public:
// was not previously acquired // was not previously acquired
virtual void* GetResource() = 0; virtual void* GetResource() = 0;
virtual ~wxResourceHolder(){}; virtual ~wxResourceHolder() {}
}; };
class wxD2DResourceManager; class wxD2DResourceManager;
@@ -414,13 +476,13 @@ public:
virtual bool IsBound() = 0; virtual bool IsBound() = 0;
virtual wxD2DResourceManager* GetManager() = 0; virtual wxD2DResourceManager* GetManager() = 0;
virtual ~wxD2DManagedObject() {}; virtual ~wxD2DManagedObject() {}
}; };
class wxManagedResourceHolder : public wxResourceHolder, public wxD2DManagedObject class wxManagedResourceHolder : public wxResourceHolder, public wxD2DManagedObject
{ {
public: public:
virtual ~wxManagedResourceHolder() {}; virtual ~wxManagedResourceHolder() {}
}; };
// A Direct2D resource manager handles the device-dependent // A Direct2D resource manager handles the device-dependent
@@ -594,7 +656,7 @@ public:
virtual wxD2DManagedObject* GetManagedObject() = 0; virtual wxD2DManagedObject* GetManagedObject() = 0;
~wxD2DManagedGraphicsData() {}; ~wxD2DManagedGraphicsData() {}
}; };
D2D1_CAP_STYLE wxD2DConvertPenCap(wxPenCap cap) D2D1_CAP_STYLE wxD2DConvertPenCap(wxPenCap cap)
@@ -1115,7 +1177,7 @@ public :
void* GetNativePath() const wxOVERRIDE; void* GetNativePath() const wxOVERRIDE;
// give the native path returned by GetNativePath() back (there might be some deallocations necessary) // give the native path returned by GetNativePath() back (there might be some deallocations necessary)
void UnGetNativePath(void* WXUNUSED(p)) const wxOVERRIDE {}; void UnGetNativePath(void* WXUNUSED(p)) const wxOVERRIDE {}
// transforms each point of this path by the matrix // transforms each point of this path by the matrix
void Transform(const wxGraphicsMatrixData* matrix) wxOVERRIDE; void Transform(const wxGraphicsMatrixData* matrix) wxOVERRIDE;
@@ -2199,7 +2261,7 @@ public:
wxGraphicsBitmapData(renderer), m_bitmapHolder(bitmap) {} wxGraphicsBitmapData(renderer), m_bitmapHolder(bitmap) {}
wxD2DBitmapData(wxGraphicsRenderer* renderer, const void* pseudoNativeBitmap) : wxD2DBitmapData(wxGraphicsRenderer* renderer, const void* pseudoNativeBitmap) :
wxGraphicsBitmapData(renderer), m_bitmapHolder(*static_cast<const NativeType*>(pseudoNativeBitmap)) {}; wxGraphicsBitmapData(renderer), m_bitmapHolder(*static_cast<const NativeType*>(pseudoNativeBitmap)) {}
// returns the native representation // returns the native representation
void* GetNativeBitmap() const wxOVERRIDE; void* GetNativeBitmap() const wxOVERRIDE;
@@ -2268,8 +2330,8 @@ template <typename B>
class wxD2DBrushResourceHolder : public wxD2DResourceHolder<B> class wxD2DBrushResourceHolder : public wxD2DResourceHolder<B>
{ {
public: public:
wxD2DBrushResourceHolder(const wxBrush& brush) : m_sourceBrush(brush) {}; wxD2DBrushResourceHolder(const wxBrush& brush) : m_sourceBrush(brush) {}
virtual ~wxD2DBrushResourceHolder() {}; virtual ~wxD2DBrushResourceHolder() {}
protected: protected:
const wxBrush m_sourceBrush; const wxBrush m_sourceBrush;
}; };
@@ -2645,7 +2707,7 @@ public:
wxCOMPtr<IDWriteTextFormat> GetTextFormat() const { return m_textFormat; } wxCOMPtr<IDWriteTextFormat> GetTextFormat() const { return m_textFormat; }
wxCOMPtr<IDWriteFont> GetFont() { return m_font; }; wxCOMPtr<IDWriteFont> GetFont() { return m_font; }
private: private:
// The native, device-independent font object // The native, device-independent font object