Bug 786449 - Add a place to explicitly initialize RasterImage on the main thread at startup. r=jlebar

This commit is contained in:
Joe Drew 2012-09-26 11:33:06 -04:00
parent 207a38707b
commit da4919a598
3 changed files with 14 additions and 6 deletions

View File

@ -96,6 +96,7 @@ static nsresult
imglib_Initialize()
{
mozilla::image::DiscardTracker::Initialize();
mozilla::image::RasterImage::Initialize();
imgLoader::GlobalInit();
return NS_OK;
}

View File

@ -53,7 +53,6 @@ static PRLogModuleInfo *gCompressedImageAccountingLog = PR_NewLogModule ("Compre
// Tweakable progressive decoding parameters. These are initialized to 0 here
// because otherwise, we have to initialize them in a static initializer, which
// makes us slower to start up.
static bool gInitializedPrefCaches = false;
static uint32_t gDecodeBytesAtATime = 0;
static uint32_t gMaxMSBeforeYield = 0;
@ -64,7 +63,6 @@ InitPrefCaches()
"image.mem.decode_bytes_at_a_time", 200000);
Preferences::AddUintVarCache(&gMaxMSBeforeYield,
"image.mem.max_ms_before_yield", 400);
gInitializedPrefCaches = true;
}
/* We define our own error checking macros here for 2 reasons:
@ -181,10 +179,6 @@ RasterImage::RasterImage(imgStatusTracker* aStatusTracker) :
// Statistics
num_containers++;
// Register our pref observers if we haven't yet.
if (NS_UNLIKELY(!gInitializedPrefCaches)) {
InitPrefCaches();
}
}
//******************************************************************************
@ -224,6 +218,16 @@ RasterImage::~RasterImage()
total_source_bytes -= mSourceData.Length();
}
void
RasterImage::Initialize()
{
InitPrefCaches();
// Create our singletons now, so we don't have to worry about what thread
// they're created on.
DecodeWorker::Singleton();
}
nsresult
RasterImage::Init(imgIDecoderObserver *aObserver,
const char* aMimeType,

View File

@ -308,6 +308,9 @@ public:
const char* GetURIString() { return mURIString.get();}
// Called from module startup. Sets up RasterImage to be used.
static void Initialize();
private:
struct Anim
{