2002-09-12 05:07:28 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2002-09-12 05:07:28 +00:00
|
|
|
|
2014-04-08 22:51:34 +00:00
|
|
|
#include "nsImageModule.h"
|
|
|
|
|
2010-06-10 18:11:40 +00:00
|
|
|
#include "mozilla/ModuleUtils.h"
|
2002-09-12 05:07:28 +00:00
|
|
|
|
2015-01-18 09:27:16 +00:00
|
|
|
#include "DecodePool.h"
|
2013-09-28 18:28:42 +00:00
|
|
|
#include "ImageFactory.h"
|
2014-09-23 22:32:16 +00:00
|
|
|
#include "ShutdownTracker.h"
|
2013-10-22 11:37:59 +00:00
|
|
|
#include "SurfaceCache.h"
|
2010-07-28 21:51:37 +00:00
|
|
|
|
2002-09-12 05:07:28 +00:00
|
|
|
#include "imgLoader.h"
|
|
|
|
|
2012-01-06 16:02:27 +00:00
|
|
|
using namespace mozilla::image;
|
2002-09-12 05:07:28 +00:00
|
|
|
|
2014-04-08 22:51:34 +00:00
|
|
|
static bool sInitialized = false;
|
2016-05-19 12:31:15 +00:00
|
|
|
nsresult mozilla::image::EnsureModuleInitialized() {
|
2014-09-22 21:30:20 +00:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
2016-05-19 12:31:15 +00:00
|
|
|
|
|
|
|
if (sInitialized) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-09-23 22:32:16 +00:00
|
|
|
mozilla::image::ShutdownTracker::Initialize();
|
2013-09-28 18:28:42 +00:00
|
|
|
mozilla::image::ImageFactory::Initialize();
|
2015-01-18 09:27:16 +00:00
|
|
|
mozilla::image::DecodePool::Initialize();
|
2013-10-22 11:37:59 +00:00
|
|
|
mozilla::image::SurfaceCache::Initialize();
|
2012-06-26 04:20:12 +00:00
|
|
|
imgLoader::GlobalInit();
|
2014-04-08 22:51:34 +00:00
|
|
|
sInitialized = true;
|
2002-09-12 05:07:28 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-08 22:51:34 +00:00
|
|
|
void mozilla::image::ShutdownModule() {
|
|
|
|
if (!sInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
2008-09-04 23:00:42 +00:00
|
|
|
imgLoader::Shutdown();
|
2013-10-22 11:37:59 +00:00
|
|
|
mozilla::image::SurfaceCache::Shutdown();
|
2014-04-08 22:51:34 +00:00
|
|
|
sInitialized = false;
|
2002-09-12 05:07:28 +00:00
|
|
|
}
|