1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : *
3 : * ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is mozilla.org code.
17 : *
18 : * The Initial Developer of the Original Code is
19 : * Netscape Communications Corporation.
20 : * Portions created by the Initial Developer are Copyright (C) 2001
21 : * the Initial Developer. All Rights Reserved.
22 : *
23 : * Contributor(s):
24 : * Stuart Parmenter <pavlov@netscape.com>
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #include "mozilla/ModuleUtils.h"
41 :
42 : #include "RasterImage.h"
43 :
44 : /* We end up pulling in windows.h because we eventually hit gfxWindowsSurface;
45 : * windows.h defines LoadImage, so we have to #undef it or imgLoader::LoadImage
46 : * gets changed.
47 : * This #undef needs to be in multiple places because we don't always pull
48 : * headers in in the same order.
49 : */
50 : #undef LoadImage
51 :
52 : #include "imgLoader.h"
53 : #include "imgRequest.h"
54 : #include "imgRequestProxy.h"
55 : #include "imgTools.h"
56 : #include "DiscardTracker.h"
57 :
58 : #include "nsICOEncoder.h"
59 : #include "nsPNGEncoder.h"
60 : #include "nsJPEGEncoder.h"
61 : #include "nsBMPEncoder.h"
62 :
63 : // objects that just require generic constructors
64 : namespace mozilla {
65 : namespace image {
66 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(RasterImage)
67 : }
68 : }
69 : using namespace mozilla::image;
70 :
71 180 : NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(imgLoader, Init)
72 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequestProxy)
73 16 : NS_GENERIC_FACTORY_CONSTRUCTOR(imgTools)
74 8 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsICOEncoder)
75 6 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsJPEGEncoder)
76 52 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsPNGEncoder)
77 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(nsBMPEncoder)
78 : NS_DEFINE_NAMED_CID(NS_IMGLOADER_CID);
79 : NS_DEFINE_NAMED_CID(NS_IMGREQUESTPROXY_CID);
80 : NS_DEFINE_NAMED_CID(NS_IMGTOOLS_CID);
81 : NS_DEFINE_NAMED_CID(NS_RASTERIMAGE_CID);
82 : NS_DEFINE_NAMED_CID(NS_ICOENCODER_CID);
83 : NS_DEFINE_NAMED_CID(NS_JPEGENCODER_CID);
84 : NS_DEFINE_NAMED_CID(NS_PNGENCODER_CID);
85 : NS_DEFINE_NAMED_CID(NS_BMPENCODER_CID);
86 :
87 : static const mozilla::Module::CIDEntry kImageCIDs[] = {
88 : { &kNS_IMGLOADER_CID, false, NULL, imgLoaderConstructor, },
89 : { &kNS_IMGREQUESTPROXY_CID, false, NULL, imgRequestProxyConstructor, },
90 : { &kNS_IMGTOOLS_CID, false, NULL, imgToolsConstructor, },
91 : { &kNS_RASTERIMAGE_CID, false, NULL, RasterImageConstructor, },
92 : { &kNS_ICOENCODER_CID, false, NULL, nsICOEncoderConstructor, },
93 : { &kNS_JPEGENCODER_CID, false, NULL, nsJPEGEncoderConstructor, },
94 : { &kNS_PNGENCODER_CID, false, NULL, nsPNGEncoderConstructor, },
95 : { &kNS_BMPENCODER_CID, false, NULL, nsBMPEncoderConstructor, },
96 : { NULL }
97 : };
98 :
99 : static const mozilla::Module::ContractIDEntry kImageContracts[] = {
100 : { "@mozilla.org/image/cache;1", &kNS_IMGLOADER_CID },
101 : { "@mozilla.org/image/loader;1", &kNS_IMGLOADER_CID },
102 : { "@mozilla.org/image/request;1", &kNS_IMGREQUESTPROXY_CID },
103 : { "@mozilla.org/image/tools;1", &kNS_IMGTOOLS_CID },
104 : { "@mozilla.org/image/rasterimage;1", &kNS_RASTERIMAGE_CID },
105 : { "@mozilla.org/image/encoder;2?type=image/vnd.microsoft.icon", &kNS_ICOENCODER_CID },
106 : { "@mozilla.org/image/encoder;2?type=image/jpeg", &kNS_JPEGENCODER_CID },
107 : { "@mozilla.org/image/encoder;2?type=image/png", &kNS_PNGENCODER_CID },
108 : { "@mozilla.org/image/encoder;2?type=image/bmp", &kNS_BMPENCODER_CID },
109 : { NULL }
110 : };
111 :
112 : static const mozilla::Module::CategoryEntry kImageCategories[] = {
113 : { "Gecko-Content-Viewers", "image/gif", "@mozilla.org/content/document-loader-factory;1" },
114 : { "Gecko-Content-Viewers", "image/jpeg", "@mozilla.org/content/document-loader-factory;1" },
115 : { "Gecko-Content-Viewers", "image/pjpeg", "@mozilla.org/content/document-loader-factory;1" },
116 : { "Gecko-Content-Viewers", "image/jpg", "@mozilla.org/content/document-loader-factory;1" },
117 : { "Gecko-Content-Viewers", "image/x-icon", "@mozilla.org/content/document-loader-factory;1" },
118 : { "Gecko-Content-Viewers", "image/vnd.microsoft.icon", "@mozilla.org/content/document-loader-factory;1" },
119 : { "Gecko-Content-Viewers", "image/bmp", "@mozilla.org/content/document-loader-factory;1" },
120 : { "Gecko-Content-Viewers", "image/x-ms-bmp", "@mozilla.org/content/document-loader-factory;1" },
121 : { "Gecko-Content-Viewers", "image/icon", "@mozilla.org/content/document-loader-factory;1" },
122 : { "Gecko-Content-Viewers", "image/png", "@mozilla.org/content/document-loader-factory;1" },
123 : { "Gecko-Content-Viewers", "image/x-png", "@mozilla.org/content/document-loader-factory;1" },
124 : { "content-sniffing-services", "@mozilla.org/image/loader;1", "@mozilla.org/image/loader;1" },
125 : { NULL }
126 : };
127 :
128 : static nsresult
129 93 : imglib_Initialize()
130 : {
131 93 : imgLoader::InitCache();
132 93 : return NS_OK;
133 : }
134 :
135 : static void
136 93 : imglib_Shutdown()
137 : {
138 93 : imgLoader::Shutdown();
139 93 : mozilla::image::DiscardTracker::Shutdown();
140 93 : }
141 :
142 : static const mozilla::Module kImageModule = {
143 : mozilla::Module::kVersion,
144 : kImageCIDs,
145 : kImageContracts,
146 : kImageCategories,
147 : NULL,
148 : imglib_Initialize,
149 : imglib_Shutdown
150 : };
151 :
152 : NSMODULE_DEFN(nsImageLib2Module) = &kImageModule;
|