From 6247c94cd0e053c1fb21a9d3a7baca5faa69ca29 Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Sun, 25 Nov 2012 14:00:31 -0500 Subject: [PATCH] Bug 793719 - Fix for D2D error on shutdown with VS2012. r=bas --- gfx/2d/2D.h | 1 + gfx/2d/DrawTargetD2D.cpp | 9 +++++++++ gfx/2d/DrawTargetD2D.h | 1 + gfx/2d/Factory.cpp | 6 ++++++ gfx/thebes/gfxWindowsPlatform.cpp | 2 ++ 5 files changed, 19 insertions(+) diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index 9e1c7f973cad..c780cb1aa621 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -926,6 +926,7 @@ public: static uint64_t GetD2DVRAMUsageDrawTarget(); static uint64_t GetD2DVRAMUsageSourceSurface(); + static void D2DCleanup(); private: static ID3D10Device1 *mD3D10Device; diff --git a/gfx/2d/DrawTargetD2D.cpp b/gfx/2d/DrawTargetD2D.cpp index 2113435dfb0e..d82a5c9a5115 100644 --- a/gfx/2d/DrawTargetD2D.cpp +++ b/gfx/2d/DrawTargetD2D.cpp @@ -2686,6 +2686,15 @@ DrawTargetD2D::factory() return mFactory; } +void +DrawTargetD2D::CleanupD2D() +{ + if (mFactory) { + mFactory->Release(); + mFactory = nullptr; + } +} + IDWriteFactory* DrawTargetD2D::GetDWriteFactory() { diff --git a/gfx/2d/DrawTargetD2D.h b/gfx/2d/DrawTargetD2D.h index 4575214beb11..1e8ed6350d7c 100644 --- a/gfx/2d/DrawTargetD2D.h +++ b/gfx/2d/DrawTargetD2D.h @@ -128,6 +128,7 @@ public: void PopCachedLayer(ID2D1RenderTarget *aRT); static ID2D1Factory *factory(); + static void CleanupD2D(); static TemporaryRef CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions); static IDWriteFactory *GetDWriteFactory(); diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 8ebbf2527b30..f20ec2ffef50 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -441,6 +441,12 @@ Factory::GetD2DVRAMUsageSourceSurface() return DrawTargetD2D::mVRAMUsageSS; } +void +Factory::D2DCleanup() +{ + DrawTargetD2D::CleanupD2D(); +} + #endif // XP_WIN TemporaryRef diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index acc433934818..acb2479e9352 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -385,6 +385,8 @@ gfxWindowsPlatform::~gfxWindowsPlatform() } #endif + mozilla::gfx::Factory::D2DCleanup(); + /* * Uninitialize COM */