diff options
author | crupest <crupest@outlook.com> | 2019-12-16 00:09:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-12-16 00:09:52 +0800 |
commit | 6ad6638adf64d958cdae44ce1df6a8a3787fed84 (patch) | |
tree | 030af9ca6e19bebc6250a8d278e46af7065fcd2f /include/cru/win/graph | |
parent | 221c62de313ad811ca2b3ae8ba43996c96c347bc (diff) | |
download | cru-6ad6638adf64d958cdae44ce1df6a8a3787fed84.tar.gz cru-6ad6638adf64d958cdae44ce1df6a8a3787fed84.tar.bz2 cru-6ad6638adf64d958cdae44ce1df6a8a3787fed84.zip |
...
Diffstat (limited to 'include/cru/win/graph')
-rw-r--r-- | include/cru/win/graph/direct/factory.hpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/include/cru/win/graph/direct/factory.hpp b/include/cru/win/graph/direct/factory.hpp index 4c106f54..cf5ccaee 100644 --- a/include/cru/win/graph/direct/factory.hpp +++ b/include/cru/win/graph/direct/factory.hpp @@ -11,14 +11,12 @@ class DirectGraphFactory : public DirectResource, public virtual IGraphFactory { CRU_DELETE_COPY(DirectGraphFactory) CRU_DELETE_MOVE(DirectGraphFactory) - ~DirectGraphFactory() override = default; + ~DirectGraphFactory() override; public: - ID2D1Factory1* GetD2D1Factory() const { return d2d1_factory_.Get(); } - ID2D1DeviceContext* GetD2D1DeviceContext() const { - return d2d1_device_context_.Get(); - } ID3D11Device* GetD3D11Device() const { return d3d11_device_.Get(); } + ID2D1Factory1* GetD2D1Factory() const { return d2d1_factory_.Get(); } + ID2D1Device* GetD2D1Device() const { return d2d1_device_.Get(); } IDXGIFactory2* GetDxgiFactory() const { return dxgi_factory_.Get(); } IDWriteFactory* GetDWriteFactory() const { return dwrite_factory_.Get(); } IDWriteFontCollection* GetSystemFontCollection() const { @@ -26,6 +24,16 @@ class DirectGraphFactory : public DirectResource, public virtual IGraphFactory { } public: + Microsoft::WRL::ComPtr<ID2D1DeviceContext> CreateD2D1DeviceContext(); + + // This context should only be used to create graphic resources like brush. + // Because graphic resources can be shared if they are created in the same + // device. + ID2D1DeviceContext* GetDefaultD2D1DeviceContext() { + return d2d1_device_context_.Get(); + } + + public: std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush() override; std::unique_ptr<IGeometryBuilder> CreateGeometryBuilder() override; @@ -38,7 +46,10 @@ class DirectGraphFactory : public DirectResource, public virtual IGraphFactory { private: Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_; + // ID2D1Factory1 is a interface only available in Windows 8 and Windows 7 with + // update. It is d2d v1.1. Microsoft::WRL::ComPtr<ID2D1Factory1> d2d1_factory_; + Microsoft::WRL::ComPtr<ID2D1Device> d2d1_device_; Microsoft::WRL::ComPtr<ID2D1DeviceContext> d2d1_device_context_; Microsoft::WRL::ComPtr<IDXGIFactory2> dxgi_factory_; Microsoft::WRL::ComPtr<IDWriteFactory> dwrite_factory_; |