Bug 913138 - Shut down gfx at the end of layout shutdown. r=bsmedberg
authorBobby Holley <bobbyholley@gmail.com>
Wed, 09 Apr 2014 09:20:15 -0700
changeset 183682 6899f7b4f57c
parent 183681 64fcbdc63ed7
child 183683 58786efcdbbb
push id3446
push usernalexander@mozilla.com
push date2014-04-09 16:21 +0000
Treeherderresults
reviewersbsmedberg
bugs913138
milestone29.0
Bug 913138 - Shut down gfx at the end of layout shutdown. r=bsmedberg
gfx/src/nsThebesGfxFactory.cpp
gfx/thebes/gfxPlatform.cpp
layout/build/nsLayoutModule.cpp
--- a/gfx/src/nsThebesGfxFactory.cpp
+++ b/gfx/src/nsThebesGfxFactory.cpp
@@ -13,30 +13,16 @@
 #include "nsError.h"                    // for NS_ERROR_NO_AGGREGATION, etc
 #include "nsGfxCIID.h"                  // for NS_FONT_ENUMERATOR_CID, etc
 #include "nsID.h"                       // for NS_DEFINE_NAMED_CID, etc
 #include "nsIScriptableRegion.h"        // for nsIScriptableRegion
 #include "nsISupports.h"                // for NS_DECL_ISUPPORTS, etc
 #include "nsScriptableRegion.h"         // for nsScriptableRegion
 #include "nsThebesFontEnumerator.h"     // for nsThebesFontEnumerator
 
-// This class doesn't do anything; its only purpose is to give
-// gfxPlatform::Init a way to force this component to be registered,
-// so that gfxPlatform::Shutdown will be called at an appropriate
-// time.  (Component teardown is the only shutdown hook that runs
-// late enough; see bug 651498.)
-
-namespace {
-class GfxInitialization MOZ_FINAL : public nsISupports {
-    NS_DECL_ISUPPORTS
-};
-
-NS_IMPL_ISUPPORTS0(GfxInitialization)
-}
-
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
 
 static nsresult
 nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
 {
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
@@ -44,45 +30,34 @@ nsScriptableRegionConstructor(nsISupport
   if (aOuter) {
     return NS_ERROR_NO_AGGREGATION;
   }
 
   nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion();
   return scriptableRgn->QueryInterface(aIID, aResult);
 }
 
-NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization)
-
 NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
 NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID);
-NS_DEFINE_NAMED_CID(NS_GFX_INITIALIZATION_CID);
 
 static const mozilla::Module::CIDEntry kThebesCIDs[] = {
     { &kNS_FONT_ENUMERATOR_CID, false, nullptr, nsThebesFontEnumeratorConstructor },
     { &kNS_SCRIPTABLE_REGION_CID, false, nullptr, nsScriptableRegionConstructor },
-    { &kNS_GFX_INITIALIZATION_CID, false, nullptr, GfxInitializationConstructor },
     { nullptr }
 };
 
 static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
     { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID },
     { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
-    { "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID },
     { nullptr }
 };
 
-static void
-nsThebesGfxModuleDtor()
-{
-    gfxPlatform::Shutdown();
-}
-
 static const mozilla::Module kThebesModule = {
     mozilla::Module::kVersion,
     kThebesCIDs,
     kThebesContracts,
     nullptr,
     nullptr,
     nullptr,
-    nsThebesGfxModuleDtor
+    nullptr
 };
 
 NSMODULE_DEFN(nsGfxModule) = &kThebesModule;
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -480,21 +480,16 @@ gfxPlatform::Init()
 
     mozilla::gl::GLContext::PlatformStartup();
 
 #ifdef MOZ_WIDGET_ANDROID
     // Texture pool init
     mozilla::gl::TexturePoolOGL::Init();
 #endif
 
-    // Force registration of the gfx component, thus arranging for
-    // ::Shutdown to be called.
-    nsCOMPtr<nsISupports> forceReg
-        = do_CreateInstance("@mozilla.org/gfx/init;1");
-
     Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording", nullptr);
 
     gPlatform->mOrientationSyncMillis = Preferences::GetUint("layers.orientation.sync.timeout", (uint32_t)0);
 
     mozilla::Preferences::AddBoolVarCache(&sDrawFrameCounter,
                                           "layers.frame-counter",
                                           false);
 
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -65,16 +65,17 @@
 
 // view stuff
 #include "nsContentCreatorFunctions.h"
 
 // DOM includes
 #include "nsDOMBlobBuilder.h"
 #include "nsDOMFileReader.h"
 
+#include "gfxPlatform.h"
 #include "nsFormData.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsHostObjectURI.h"
 #include "nsGlobalWindowCommands.h"
 #include "nsIControllerCommandTable.h"
 #include "nsJSProtocolHandler.h"
 #include "nsScriptNameSpaceManager.h"
 #include "nsIControllerContext.h"
@@ -1249,16 +1250,20 @@ static const mozilla::Module::CategoryEn
 
 static void
 LayoutModuleDtor()
 {
   Shutdown();
   nsContentUtils::XPCOMShutdown();
   nsScriptSecurityManager::Shutdown();
   xpcModuleDtor();
+
+  // Layout depends heavily on gfx, so we want to make sure that gfx is shut
+  // down after all the layout cleanup runs.
+  gfxPlatform::Shutdown();
 }
 
 static const mozilla::Module kLayoutModule = {
   mozilla::Module::kVersion,
   kLayoutCIDs,
   kLayoutContracts,
   kLayoutCategories,
   nullptr,