Bug 651017, part 2: wrap gfxPlatform::Init/Shutdown in a service and register it for app-startup. Also prune some dead CIDs from nsGfxCIID.h.

--HG--
extra : rebase_source : d296ac53c4c60d79f7e2d6904dd54ce930099bbd
This commit is contained in:
Zack Weinberg 2011-04-16 18:22:41 -07:00
Родитель f8bc216403
Коммит bd454f49fa
5 изменённых файлов: 34 добавлений и 22 удалений

Просмотреть файл

@ -38,14 +38,6 @@
#ifndef nsGfxCIID_h__
#define nsGfxCIID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
#define NS_IMAGE_CID \
{ 0x6049b260, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_CID \
{ 0x6049b262, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
@ -62,8 +54,8 @@
{ 0xda5b130a, 0x1dd1, 0x11b2, \
{ 0xad, 0x47, 0xf4, 0x55, 0xb1, 0x81, 0x4a, 0x78 } }
#define NS_DRAWING_SURFACE_CID \
{ 0x199c7040, 0xcab0, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_GFX_INITIALIZATION_CID \
{ 0x67c41576, 0x9664, 0x4ed5, \
{ 0x90, 0xc1, 0xf6, 0x68, 0x3f, 0xd5, 0x2c, 0x8f } }
#endif

Просмотреть файл

@ -47,9 +47,25 @@
#include "nsThebesFontEnumerator.h"
#include "gfxPlatform.h"
// This service doesn't do anything; its only purpose is to force the
// gfx module constructor to be called (and hence gfxPlatform::Init).
// It's invoked at app-startup time and may also be invoked directly
// (as do_GetService("@mozilla.org/gfx/init;1")) from code (like the
// libpr0n module constructor) that wants to make sure gfx is
// initialized.
namespace {
class GfxInitialization : public nsISupports {
NS_DECL_ISUPPORTS
};
NS_IMPL_ISUPPORTS0(GfxInitialization)
}
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesDeviceContext)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization)
static nsresult
nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
@ -96,12 +112,14 @@ NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_CID);
NS_DEFINE_NAMED_CID(NS_REGION_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, NULL, nsThebesFontEnumeratorConstructor },
{ &kNS_DEVICE_CONTEXT_CID, false, NULL, nsThebesDeviceContextConstructor },
{ &kNS_REGION_CID, false, NULL, nsThebesRegionConstructor },
{ &kNS_SCRIPTABLE_REGION_CID, false, NULL, nsScriptableRegionConstructor },
{ &kNS_GFX_INITIALIZATION_CID, false, NULL, GfxInitializationConstructor },
{ NULL }
};
@ -110,6 +128,12 @@ static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
{ "@mozilla.org/gfx/devicecontext;1", &kNS_DEVICE_CONTEXT_CID },
{ "@mozilla.org/gfx/region/nsThebes;1", &kNS_REGION_CID },
{ "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
{ "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID },
{ NULL }
};
static const mozilla::Module::CategoryEntry kThebesCategories[] = {
{ "app-startup", "Gfx Initialization", "service,@mozilla.org/gfx/init;1" },
{ NULL }
};
@ -130,7 +154,7 @@ static const mozilla::Module kThebesModule = {
mozilla::Module::kVersion,
kThebesCIDs,
kThebesContracts,
NULL,
kThebesCategories,
NULL,
nsThebesGfxModuleCtor,
nsThebesGfxModuleDtor

Просмотреть файл

@ -272,9 +272,9 @@ gfxPlatform::Init()
gPlatform = new gfxOS2Platform;
#elif defined(ANDROID)
gPlatform = new gfxAndroidPlatform;
#else
#error "No gfxPlatform implementation available"
#endif
if (!gPlatform)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv;

Просмотреть файл

@ -37,10 +37,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDeviceContext.h"
#include "mozilla/ModuleUtils.h"
#include "nsXPCOMCID.h"
#include "nsServiceManagerUtils.h"
#include "RasterImage.h"
@ -121,11 +118,9 @@ static const mozilla::Module::CategoryEntry kImageCategories[] = {
static nsresult
imglib_Initialize()
{
// Hack: We need the gfx module to be initialized because we use gfxPlatform
// in imgFrame. Request something from the gfx module to ensure that
// everything's set up for us.
nsCOMPtr<nsIDeviceContext> devctx =
do_CreateInstance("@mozilla.org/gfx/devicecontext;1");
// We need the gfx module to be initialized because we use gfxPlatform
// in imgFrame. It should have happened by now, but make sure.
nsCOMPtr<nsISupports> dummy = do_GetService("@mozilla.org/gfx/init;1");
imgLoader::InitCache();
return NS_OK;

Просмотреть файл

@ -47,6 +47,7 @@
#include "prmem.h"
#include "imgIEncoder.h"
#include "nsLiteralString.h"
#include "nsComponentManagerUtils.h"
/* Things To Do 11/8/00