Backed out changeset ad0d9f62c29c (bug 206659) for B2G desktop mochitest orange.
[gecko.git] / image / src / ImageFactory.h
blobe47e218c7f54733ad57e4697c76216c70f5926db
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_IMAGELIB_IMAGEFACTORY_H_
8 #define MOZILLA_IMAGELIB_IMAGEFACTORY_H_
10 #include "nsCOMPtr.h"
11 #include "nsProxyRelease.h"
13 class nsCString;
14 class nsIRequest;
15 class imgStatusTracker;
17 namespace mozilla {
18 namespace image {
20 class Image;
21 class ImageURL;
23 class ImageFactory
25 public:
26 /**
27 * Registers vars with Preferences. Should only be called on the main thread.
29 static void Initialize();
31 /**
32 * Creates a new image with the given properties.
33 * Can be called on or off the main thread.
35 * @param aRequest The associated request.
36 * @param aStatusTracker A status tracker for the image to use.
37 * @param aMimeType The mimetype of the image.
38 * @param aURI The URI of the image.
39 * @param aIsMultiPart Whether the image is part of a multipart request.
40 * @param aInnerWindowId The window this image belongs to.
42 static already_AddRefed<Image> CreateImage(nsIRequest* aRequest,
43 imgStatusTracker* aStatusTracker,
44 const nsCString& aMimeType,
45 ImageURL* aURI,
46 bool aIsMultiPart,
47 uint32_t aInnerWindowId);
48 /**
49 * Creates a new image which isn't associated with a URI or loaded through
50 * the usual image loading mechanism.
52 * @param aMimeType The mimetype of the image.
54 static already_AddRefed<Image> CreateAnonymousImage(const nsCString& aMimeType);
56 private:
57 // Factory functions that create specific types of image containers.
58 static already_AddRefed<Image> CreateRasterImage(nsIRequest* aRequest,
59 imgStatusTracker* aStatusTracker,
60 const nsCString& aMimeType,
61 ImageURL* aURI,
62 uint32_t aImageFlags,
63 uint32_t aInnerWindowId);
65 static already_AddRefed<Image> CreateVectorImage(nsIRequest* aRequest,
66 imgStatusTracker* aStatusTracker,
67 const nsCString& aMimeType,
68 ImageURL* aURI,
69 uint32_t aImageFlags,
70 uint32_t aInnerWindowId);
72 // This is a static factory class, so disallow instantiation.
73 virtual ~ImageFactory() = 0;
76 } // namespace image
77 } // namespace mozilla
79 #endif // MOZILLA_IMAGELIB_IMAGEFACTORY_H_