Bug 1101130: Make Direct2D 1.1 clean up its resources on shutdown. r=jrmuizel

This commit is contained in:
Bas Schouten 2014-11-20 00:16:48 +00:00
parent 3e8aa86ac8
commit d648e9fd93
4 changed files with 27 additions and 0 deletions

View File

@ -850,6 +850,16 @@ DrawTargetD2D1::factory()
return mFactory;
}
void
DrawTargetD2D1::CleanupD2D()
{
if (mFactory) {
RadialGradientEffectD2D1::Unregister(mFactory);
mFactory->Release();
mFactory = nullptr;
}
}
void
DrawTargetD2D1::MarkChanged()
{

View File

@ -609,6 +609,11 @@ Factory::SetDirect3D11Device(ID3D11Device *aDevice)
{
mD3D11Device = aDevice;
if (mD2D1Device) {
mD2D1Device->Release();
mD2D1Device = nullptr;
}
RefPtr<ID2D1Factory1> factory = D2DFactory1();
RefPtr<IDXGIDevice> device;
@ -656,7 +661,12 @@ Factory::GetD2DVRAMUsageSourceSurface()
void
Factory::D2DCleanup()
{
if (mD2D1Device) {
mD2D1Device->Release();
mD2D1Device = nullptr;
}
DrawTargetD2D::CleanupD2D();
DrawTargetD2D1::CleanupD2D();
}
#endif // XP_WIN

View File

@ -284,6 +284,12 @@ RadialGradientEffectD2D1::Register(ID2D1Factory1 *aFactory)
return hr;
}
void
RadialGradientEffectD2D1::Unregister(ID2D1Factory1 *aFactory)
{
aFactory->UnregisterEffect(CLSID_RadialGradientEffect);
}
HRESULT __stdcall
RadialGradientEffectD2D1::CreateEffect(IUnknown **aEffectImpl)
{

View File

@ -72,6 +72,7 @@ public:
IFACEMETHODIMP SetDrawInfo(ID2D1DrawInfo *pDrawInfo);
static HRESULT Register(ID2D1Factory1* aFactory);
static void Unregister(ID2D1Factory1* aFactory);
static HRESULT __stdcall CreateEffect(IUnknown** aEffectImpl);
HRESULT SetStopCollection(IUnknown *aStopCollection);