diff --git a/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h b/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h index 10a2a0f958..4372bdda4d 100644 --- a/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h +++ b/modules/juce_graphics/native/juce_Direct2DGraphicsContextImpl_windows.h @@ -557,19 +557,6 @@ public: struct Direct2DGraphicsContext::Pimpl : private DxgiAdapterListener { -protected: - Direct2DGraphicsContext& owner; - SharedResourcePointer directX; - SharedResourcePointer directWrite; - - std::optional deviceResources; - - std::vector> savedClientStates; - - virtual bool prepare(); - virtual void teardown(); - virtual bool checkPaintReady(); - public: explicit Pimpl (Direct2DGraphicsContext& ownerIn); ~Pimpl() override; @@ -577,6 +564,15 @@ public: virtual SavedState* startFrame(); virtual HRESULT finishFrame(); + virtual bool prepare(); + virtual void teardown(); + virtual bool checkPaintReady(); + + virtual RectangleList getPaintAreas() const = 0; + virtual Rectangle getFrameSize() const = 0; + virtual ComSmartPtr getDeviceContext() const = 0; + virtual ComSmartPtr getDeviceContextTarget() const = 0; + SavedState* getCurrentSavedState() const; SavedState* pushFirstSavedState (Rectangle initialClipRegion); @@ -585,30 +581,30 @@ public: void popAllSavedStates(); - virtual RectangleList getPaintAreas() const = 0; - virtual Rectangle getFrameSize() const = 0; - virtual ComSmartPtr getDeviceContext() const = 0; - virtual ComSmartPtr getDeviceContextTarget() const = 0; - void setDeviceContextTransform (AffineTransform transform); void resetDeviceContextTransform(); - auto getDirect2DFactory() + DxgiAdapter::Ptr getDefaultAdapter() const + { + return directX->adapters.getDefaultAdapter(); + } + + auto getDirect2DFactory() const { return directX->getD2DFactory(); } - auto getDirectWriteFactory() + auto getDirectWriteFactory() const { return directWrite->getDWriteFactory(); } - auto getDirectWriteFactory4() + auto getDirectWriteFactory4() const { return directWrite->getDWriteFactory4(); } - auto& getFontCollection() + auto& getFontCollection() const { return directWrite->getFonts(); } @@ -662,6 +658,14 @@ private: void adapterCreated (DxgiAdapter::Ptr newAdapter) override; void adapterRemoved (DxgiAdapter::Ptr expiringAdapter) override; + Direct2DGraphicsContext& owner; + SharedResourcePointer directX; + SharedResourcePointer directWrite; + + std::optional deviceResources; + + std::vector> savedClientStates; + #if JUCE_DIRECT2D_METRICS int64 paintStartTicks = 0; #endif diff --git a/modules/juce_gui_basics/native/juce_Direct2DHwndContext_windows.cpp b/modules/juce_gui_basics/native/juce_Direct2DHwndContext_windows.cpp index 07b63c6155..398aebc6bd 100644 --- a/modules/juce_gui_basics/native/juce_Direct2DHwndContext_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Direct2DHwndContext_windows.cpp @@ -152,7 +152,7 @@ private: bool prepare() override { - const auto adapter = directX->adapters.getDefaultAdapter(); + const auto adapter = getDefaultAdapter(); if (adapter == nullptr) return false; @@ -163,10 +163,7 @@ private: if (deviceContext == nullptr) return false; - if (! deviceResources.has_value()) - deviceResources = Direct2DDeviceResources::create (deviceContext); - - if (! deviceResources.has_value()) + if (! Pimpl::prepare()) return false; if (! hwnd || getClientRect().isEmpty())