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_image_ImageFactory_h
8 #define mozilla_image_ImageFactory_h
11 #include "nsProxyRelease.h"
12 #include "nsStringFwd.h"
22 class ProgressTracker
;
27 * Registers vars with Preferences. Should only be called on the main thread.
29 static void Initialize();
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 aProgressTracker 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 ProgressTracker
* aProgressTracker
,
44 const nsCString
& aMimeType
,
45 nsIURI
* aURI
, bool aIsMultiPart
,
46 uint32_t aInnerWindowId
);
48 * Creates a new image which isn't associated with a URI or loaded through
49 * the usual image loading mechanism.
51 * @param aMimeType The mimetype of the image.
52 * @param aSizeHint The length of the source data for the image.
54 static already_AddRefed
<Image
> CreateAnonymousImage(
55 const nsCString
& aMimeType
, uint32_t aSizeHint
= 0);
58 * Creates a new multipart/x-mixed-replace image wrapper, and initializes it
59 * with the first part. Subsequent parts should be passed to the existing
60 * MultipartImage via MultipartImage::BeginTransitionToPart().
62 * @param aFirstPart An image containing the first part of the multipart
64 * @param aProgressTracker A progress tracker for the multipart image.
66 static already_AddRefed
<MultipartImage
> CreateMultipartImage(
67 Image
* aFirstPart
, ProgressTracker
* aProgressTracker
);
70 // Factory functions that create specific types of image containers.
71 static already_AddRefed
<Image
> CreateRasterImage(
72 nsIRequest
* aRequest
, ProgressTracker
* aProgressTracker
,
73 const nsCString
& aMimeType
, nsIURI
* aURI
, uint32_t aImageFlags
,
74 uint32_t aInnerWindowId
);
76 static already_AddRefed
<Image
> CreateVectorImage(
77 nsIRequest
* aRequest
, ProgressTracker
* aProgressTracker
,
78 const nsCString
& aMimeType
, nsIURI
* aURI
, uint32_t aImageFlags
,
79 uint32_t aInnerWindowId
);
81 // This is a static factory class, so disallow instantiation.
82 virtual ~ImageFactory() = 0;
86 } // namespace mozilla
88 #endif // mozilla_image_ImageFactory_h