1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Direct2D: Remove redundant adapter member from Direct2DGraphicsContext

This commit is contained in:
reuk 2024-08-12 18:46:52 +01:00
parent 45305dbfa7
commit e2b9dd9a05
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
5 changed files with 21 additions and 36 deletions

View file

@ -549,7 +549,6 @@ protected:
SharedResourcePointer<Direct2DFactories> directWrite;
RectangleList<int> paintAreas;
DxgiAdapter::Ptr adapter;
std::optional<Direct2DDeviceResources> deviceResources;
std::vector<std::unique_ptr<Direct2DGraphicsContext::SavedState>> savedClientStates;
@ -557,7 +556,7 @@ protected:
virtual HRESULT prepare()
{
if (! deviceResources.has_value())
deviceResources = Direct2DDeviceResources::create (adapter);
deviceResources = Direct2DDeviceResources::create (directX->adapters.getDefaultAdapter());
return deviceResources.has_value() ? S_OK : E_FAIL;
}
@ -701,11 +700,6 @@ public:
popSavedState();
}
DxgiAdapter& getAdapter() const noexcept
{
return *adapter;
}
ComSmartPtr<ID2D1DeviceContext1> getDeviceContext() const noexcept
{
return deviceResources->deviceContext;
@ -860,24 +854,28 @@ private:
context->SetTransform (D2DUtilities::transformToMatrix (newTransform));
}
DxgiAdapter::Ptr findAdapter() const
{
if (! deviceResources.has_value())
return {};
return deviceResources->findAdapter (directX->adapters);
}
void adapterCreated (DxgiAdapter::Ptr newAdapter) override
{
if (! adapter || adapter->uniqueIDMatches (newAdapter))
{
teardown();
const auto adapter = findAdapter();
adapter = newAdapter;
}
if (adapter == nullptr || ! adapter->uniqueIDMatches (newAdapter))
teardown();
}
void adapterRemoved (DxgiAdapter::Ptr expiringAdapter) override
{
if (adapter && adapter->uniqueIDMatches (expiringAdapter))
{
teardown();
const auto adapter = findAdapter();
adapter = nullptr;
}
if (adapter != nullptr && adapter->uniqueIDMatches (expiringAdapter))
teardown();
}
HWND hwnd = nullptr;