2001-03-10 01:11:54 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2002-10-07 21:49:33 +00:00
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2002-10-07 21:49:33 +00:00
|
|
|
*
|
2001-03-10 01:11:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
2002-10-07 21:49:33 +00:00
|
|
|
*
|
2004-04-18 22:01:16 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2002-10-07 21:49:33 +00:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2001-03-10 01:11:54 +00:00
|
|
|
* Stuart Parmenter <pavlov@netscape.com>
|
|
|
|
* Chris Saari <saari@netscape.com>
|
2007-10-19 00:36:34 +00:00
|
|
|
* Federico Mena-Quintero <federico@novell.com>
|
2009-09-12 22:44:18 +00:00
|
|
|
* Bobby Holley <bobbyholley@gmail.com>
|
2004-04-18 22:01:16 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-03-10 01:11:54 +00:00
|
|
|
|
2007-03-20 23:56:50 +00:00
|
|
|
/** @file
|
2010-08-14 04:09:49 +00:00
|
|
|
* This file declares the RasterImage class, which
|
|
|
|
* handles static and animated rasterized images.
|
2007-03-20 23:56:50 +00:00
|
|
|
*
|
|
|
|
* @author Stuart Parmenter <pavlov@netscape.com>
|
|
|
|
* @author Chris Saari <saari@netscape.com>
|
|
|
|
* @author Arron Mogge <paper@animecity.nu>
|
|
|
|
* @author Andrew Smith <asmith15@learn.senecac.on.ca>
|
|
|
|
*/
|
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
#ifndef mozilla_imagelib_RasterImage_h_
|
|
|
|
#define mozilla_imagelib_RasterImage_h_
|
2001-03-10 01:11:54 +00:00
|
|
|
|
2010-08-14 04:09:48 +00:00
|
|
|
#include "Image.h"
|
2007-03-20 23:56:50 +00:00
|
|
|
#include "nsCOMArray.h"
|
2001-03-10 01:11:54 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2002-10-07 21:49:33 +00:00
|
|
|
#include "imgIContainer.h"
|
2005-01-12 20:16:07 +00:00
|
|
|
#include "nsIProperties.h"
|
2007-03-20 23:56:50 +00:00
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsWeakReference.h"
|
2007-10-19 00:36:34 +00:00
|
|
|
#include "nsTArray.h"
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
#include "imgFrame.h"
|
2009-09-12 22:44:18 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2010-08-14 04:09:49 +00:00
|
|
|
#include "DiscardTracker.h"
|
2011-08-04 20:25:12 +00:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2011-09-22 20:25:56 +00:00
|
|
|
#include "mozilla/Telemetry.h"
|
2010-09-08 00:34:18 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
#include "imgIContainerDebug.h"
|
|
|
|
#endif
|
2001-03-27 02:42:51 +00:00
|
|
|
|
2010-08-14 04:09:48 +00:00
|
|
|
class imgIDecoder;
|
|
|
|
class nsIInputStream;
|
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
#define NS_RASTERIMAGE_CID \
|
2010-08-05 14:53:43 +00:00
|
|
|
{ /* 376ff2c1-9bf6-418a-b143-3340c00112f7 */ \
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
0x376ff2c1, \
|
|
|
|
0x9bf6, \
|
|
|
|
0x418a, \
|
|
|
|
{0xb1, 0x43, 0x33, 0x40, 0xc0, 0x01, 0x12, 0xf7} \
|
2001-03-10 01:11:54 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 23:56:50 +00:00
|
|
|
/**
|
|
|
|
* Handles static and animated image containers.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @par A Quick Walk Through
|
|
|
|
* The decoder initializes this class and calls AppendFrame() to add a frame.
|
2010-08-14 04:09:49 +00:00
|
|
|
* Once RasterImage detects more than one frame, it starts the animation
|
2011-11-03 00:11:01 +00:00
|
|
|
* with StartAnimation().
|
2007-03-20 23:56:50 +00:00
|
|
|
*
|
|
|
|
* @par
|
2011-11-03 00:11:01 +00:00
|
|
|
* StartAnimation() creates a timer. The timer calls Notify when the
|
|
|
|
* specified frame delay time is up.
|
2007-03-20 23:56:50 +00:00
|
|
|
*
|
|
|
|
* @par
|
2011-11-03 00:11:01 +00:00
|
|
|
* Notify() moves on to the next frame, sets up the new timer delay, destroys
|
|
|
|
* the old frame, and forces a redraw via observer->FrameChanged().
|
2007-03-20 23:56:50 +00:00
|
|
|
*
|
|
|
|
* @par
|
|
|
|
* Each frame can have a different method of removing itself. These are
|
|
|
|
* listed as imgIContainer::cDispose... constants. Notify() calls
|
|
|
|
* DoComposite() to handle any special frame destruction.
|
|
|
|
*
|
|
|
|
* @par
|
|
|
|
* The basic path through DoComposite() is:
|
|
|
|
* 1) Calculate Area that needs updating, which is at least the area of
|
|
|
|
* aNextFrame.
|
|
|
|
* 2) Dispose of previous frame.
|
|
|
|
* 3) Draw new image onto compositingFrame.
|
|
|
|
* See comments in DoComposite() for more information and optimizations.
|
|
|
|
*
|
|
|
|
* @par
|
2010-08-14 04:09:49 +00:00
|
|
|
* The rest of the RasterImage specific functions are used by DoComposite to
|
2007-03-20 23:56:50 +00:00
|
|
|
* destroy the old frame and build the new one.
|
|
|
|
*
|
|
|
|
* @note
|
2010-05-13 12:19:50 +00:00
|
|
|
* <li> "Mask", "Alpha", and "Alpha Level" are interchangeable phrases in
|
2010-08-14 04:09:49 +00:00
|
|
|
* respects to RasterImage.
|
2007-03-20 23:56:50 +00:00
|
|
|
*
|
|
|
|
* @par
|
|
|
|
* <li> GIFs never have more than a 1 bit alpha.
|
|
|
|
* <li> APNGs may have a full alpha channel.
|
|
|
|
*
|
|
|
|
* @par
|
|
|
|
* <li> Background color specified in GIF is ignored by web browsers.
|
|
|
|
*
|
|
|
|
* @par
|
|
|
|
* <li> If Frame 3 wants to dispose by restoring previous, what it wants is to
|
|
|
|
* restore the composition up to and including Frame 2, as well as Frame 2s
|
|
|
|
* disposal. So, in the middle of DoComposite when composing Frame 3, right
|
|
|
|
* after destroying Frame 2's area, we copy compositingFrame to
|
|
|
|
* prevCompositingFrame. When DoComposite gets called to do Frame 4, we
|
|
|
|
* copy prevCompositingFrame back, and then draw Frame 4 on top.
|
|
|
|
*
|
|
|
|
* @par
|
|
|
|
* The mAnim structure has members only needed for animated images, so
|
|
|
|
* it's not allocated until the second frame is added.
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
* mAnimationMode, mLoopCount and mObserver are not in the mAnim structure
|
|
|
|
* because the first two have public setters and the observer we only get
|
|
|
|
* in Init().
|
|
|
|
*/
|
2010-08-14 04:09:49 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2011-11-09 03:14:41 +00:00
|
|
|
namespace layers {
|
|
|
|
class LayerManager;
|
|
|
|
class ImageContainer;
|
|
|
|
}
|
2010-08-14 04:09:49 +00:00
|
|
|
namespace imagelib {
|
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
class imgDecodeWorker;
|
2010-08-23 02:30:46 +00:00
|
|
|
class Decoder;
|
2010-08-14 04:09:49 +00:00
|
|
|
|
2011-08-04 21:34:19 +00:00
|
|
|
class RasterImage : public Image
|
2011-11-03 00:11:01 +00:00
|
|
|
, public nsITimerCallback
|
2010-09-08 00:34:18 +00:00
|
|
|
, public nsIProperties
|
|
|
|
, public nsSupportsWeakReference
|
|
|
|
#ifdef DEBUG
|
|
|
|
, public imgIContainerDebug
|
|
|
|
#endif
|
2001-03-10 01:11:54 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2011-11-03 00:11:01 +00:00
|
|
|
NS_DECL_NSITIMERCALLBACK
|
2007-06-21 20:45:49 +00:00
|
|
|
NS_DECL_NSIPROPERTIES
|
2010-09-08 00:34:18 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_DECL_IMGICONTAINERDEBUG
|
|
|
|
#endif
|
2001-03-10 01:11:54 +00:00
|
|
|
|
2010-11-17 20:39:23 +00:00
|
|
|
// BEGIN NS_DECL_IMGICONTAINER (minus GetAnimationMode/SetAnimationMode)
|
2010-11-17 20:37:08 +00:00
|
|
|
// ** Don't edit this chunk except to mirror changes in imgIContainer.idl **
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD GetWidth(PRInt32 *aWidth);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD GetHeight(PRInt32 *aHeight);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD GetType(PRUint16 *aType);
|
2010-12-07 18:40:28 +00:00
|
|
|
NS_IMETHOD_(PRUint16) GetType(void);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_SCRIPTABLE NS_IMETHOD GetAnimated(bool *aAnimated);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD GetCurrentFrameIsOpaque(bool *aCurrentFrameIsOpaque);
|
2010-11-17 20:37:08 +00:00
|
|
|
NS_IMETHOD GetFrame(PRUint32 aWhichFrame, PRUint32 aFlags, gfxASurface **_retval NS_OUTPARAM);
|
2011-11-09 03:14:41 +00:00
|
|
|
NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, mozilla::layers::ImageContainer **_retval NS_OUTPARAM);
|
2010-11-17 20:37:08 +00:00
|
|
|
NS_IMETHOD CopyFrame(PRUint32 aWhichFrame, PRUint32 aFlags, gfxImageSurface **_retval NS_OUTPARAM);
|
|
|
|
NS_IMETHOD ExtractFrame(PRUint32 aWhichFrame, const nsIntRect & aRect, PRUint32 aFlags, imgIContainer **_retval NS_OUTPARAM);
|
|
|
|
NS_IMETHOD Draw(gfxContext *aContext, gfxPattern::GraphicsFilter aFilter, const gfxMatrix & aUserSpaceToImageSpace, const gfxRect & aFill, const nsIntRect & aSubimage, const nsIntSize & aViewportSize, PRUint32 aFlags);
|
|
|
|
NS_IMETHOD_(nsIFrame *) GetRootLayoutFrame(void);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD RequestDecode(void);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD LockImage(void);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD UnlockImage(void);
|
|
|
|
NS_SCRIPTABLE NS_IMETHOD ResetAnimation(void);
|
2011-11-09 21:39:15 +00:00
|
|
|
NS_IMETHOD_(void) RequestRefresh(const mozilla::TimeStamp& aTime);
|
2010-11-17 20:37:08 +00:00
|
|
|
// END NS_DECL_IMGICONTAINER
|
|
|
|
|
2010-08-23 22:44:07 +00:00
|
|
|
RasterImage(imgStatusTracker* aStatusTracker = nsnull);
|
2010-08-14 04:09:49 +00:00
|
|
|
virtual ~RasterImage();
|
2001-03-10 01:11:54 +00:00
|
|
|
|
2010-09-08 00:33:02 +00:00
|
|
|
virtual nsresult StartAnimation();
|
|
|
|
virtual nsresult StopAnimation();
|
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
// Methods inherited from Image
|
2010-08-23 22:44:07 +00:00
|
|
|
nsresult Init(imgIDecoderObserver* aObserver,
|
2010-08-14 04:09:49 +00:00
|
|
|
const char* aMimeType,
|
2010-09-12 15:22:26 +00:00
|
|
|
const char* aURIString,
|
2010-08-14 04:09:49 +00:00
|
|
|
PRUint32 aFlags);
|
2010-08-23 22:44:07 +00:00
|
|
|
void GetCurrentFrameRect(nsIntRect& aRect);
|
2010-08-14 04:09:49 +00:00
|
|
|
|
|
|
|
// Raster-specific methods
|
2010-08-14 04:09:51 +00:00
|
|
|
static NS_METHOD WriteToRasterImage(nsIInputStream* aIn, void* aClosure,
|
|
|
|
const char* aFromRawSegment,
|
|
|
|
PRUint32 aToOffset, PRUint32 aCount,
|
|
|
|
PRUint32* aWriteCount);
|
2009-09-12 22:44:18 +00:00
|
|
|
|
2010-08-23 22:44:07 +00:00
|
|
|
/* The index of the current frame that would be drawn if the image was to be
|
|
|
|
* drawn now. */
|
|
|
|
PRUint32 GetCurrentFrameIndex();
|
|
|
|
|
|
|
|
/* The total number of frames in this image. */
|
|
|
|
PRUint32 GetNumFrames();
|
|
|
|
|
2011-07-18 13:20:27 +00:00
|
|
|
virtual PRUint32 GetDecodedHeapSize();
|
|
|
|
virtual PRUint32 GetDecodedNonheapSize();
|
|
|
|
virtual PRUint32 GetDecodedOutOfProcessSize();
|
|
|
|
virtual PRUint32 GetSourceHeapSize();
|
2010-05-22 04:10:14 +00:00
|
|
|
|
2010-07-01 17:39:44 +00:00
|
|
|
/* Triggers discarding. */
|
2011-01-13 01:45:13 +00:00
|
|
|
void Discard(bool force = false);
|
|
|
|
void ForceDiscard() { Discard(/* force = */ true); }
|
2010-07-01 17:39:44 +00:00
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
/* Callbacks for decoders */
|
|
|
|
nsresult SetFrameDisposalMethod(PRUint32 aFrameNum,
|
|
|
|
PRInt32 aDisposalMethod);
|
|
|
|
nsresult SetFrameTimeout(PRUint32 aFrameNum, PRInt32 aTimeout);
|
|
|
|
nsresult SetFrameBlendMethod(PRUint32 aFrameNum, PRInt32 aBlendMethod);
|
|
|
|
nsresult SetFrameHasNoAlpha(PRUint32 aFrameNum);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the size of the container. This should only be called by the
|
|
|
|
* decoder. This function may be called multiple times, but will throw an
|
|
|
|
* error if subsequent calls do not match the first.
|
|
|
|
*/
|
|
|
|
nsresult SetSize(PRInt32 aWidth, PRInt32 aHeight);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2011-07-14 18:47:43 +00:00
|
|
|
* Ensures that a given frame number exists with the given parameters, and
|
|
|
|
* returns pointers to the data storage for that frame.
|
|
|
|
* It is not possible to create sparse frame arrays; you can only append
|
|
|
|
* frames to the current frame array.
|
2010-08-14 04:09:49 +00:00
|
|
|
*/
|
2011-07-14 18:47:43 +00:00
|
|
|
nsresult EnsureFrame(PRUint32 aFramenum, PRInt32 aX, PRInt32 aY,
|
2010-08-14 04:09:49 +00:00
|
|
|
PRInt32 aWidth, PRInt32 aHeight,
|
|
|
|
gfxASurface::gfxImageFormat aFormat,
|
2011-07-14 18:47:43 +00:00
|
|
|
PRUint8 aPaletteDepth,
|
2010-08-14 04:09:49 +00:00
|
|
|
PRUint8** imageData,
|
2011-07-14 18:47:43 +00:00
|
|
|
PRUint32* imageLength,
|
|
|
|
PRUint32** paletteData,
|
|
|
|
PRUint32* paletteLength);
|
2010-08-14 04:09:49 +00:00
|
|
|
|
2011-07-14 18:47:43 +00:00
|
|
|
/**
|
|
|
|
* A shorthand for EnsureFrame, above, with aPaletteDepth = 0 and paletteData
|
|
|
|
* and paletteLength set to null.
|
|
|
|
*/
|
|
|
|
nsresult EnsureFrame(PRUint32 aFramenum, PRInt32 aX, PRInt32 aY,
|
|
|
|
PRInt32 aWidth, PRInt32 aHeight,
|
|
|
|
gfxASurface::gfxImageFormat aFormat,
|
|
|
|
PRUint8** imageData,
|
|
|
|
PRUint32* imageLength);
|
2010-08-14 04:09:49 +00:00
|
|
|
|
2010-08-24 21:12:04 +00:00
|
|
|
void FrameUpdated(PRUint32 aFrameNum, nsIntRect& aUpdatedRect);
|
2010-08-14 04:09:49 +00:00
|
|
|
|
|
|
|
/* notification that the entire image has been decoded */
|
|
|
|
nsresult DecodingComplete();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of times to loop the image.
|
|
|
|
* @note -1 means forever.
|
|
|
|
*/
|
|
|
|
void SetLoopCount(PRInt32 aLoopCount);
|
|
|
|
|
|
|
|
/* Add compressed source data to the imgContainer.
|
|
|
|
*
|
|
|
|
* The decoder will use this data, either immediately or at draw time, to
|
|
|
|
* decode the image.
|
|
|
|
*
|
|
|
|
* XXX This method's only caller (WriteToContainer) ignores the return
|
|
|
|
* value. Should this just return void?
|
|
|
|
*/
|
|
|
|
nsresult AddSourceData(const char *aBuffer, PRUint32 aCount);
|
|
|
|
|
|
|
|
/* Called after the all the source data has been added with addSourceData. */
|
2011-06-11 19:23:00 +00:00
|
|
|
nsresult SourceDataComplete();
|
2010-08-14 04:09:49 +00:00
|
|
|
|
|
|
|
/* Called for multipart images when there's a new source image to add. */
|
2011-06-11 19:23:00 +00:00
|
|
|
nsresult NewSourceData();
|
2010-08-14 04:09:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A hint of the number of bytes of source data that the image contains. If
|
|
|
|
* called early on, this can help reduce copying and reallocations by
|
|
|
|
* appropriately preallocating the source data buffer.
|
|
|
|
*
|
|
|
|
* We take this approach rather than having the source data management code do
|
|
|
|
* something more complicated (like chunklisting) because HTTP is by far the
|
|
|
|
* dominant source of images, and the Content-Length header is quite reliable.
|
|
|
|
* Thus, pre-allocation simplifies code and reduces the total number of
|
|
|
|
* allocations.
|
|
|
|
*/
|
2011-06-11 19:23:00 +00:00
|
|
|
nsresult SetSourceSizeHint(PRUint32 sizeHint);
|
2010-08-14 04:09:49 +00:00
|
|
|
|
|
|
|
// "Blend" method indicates how the current image is combined with the
|
|
|
|
// previous image.
|
|
|
|
enum {
|
|
|
|
// All color components of the frame, including alpha, overwrite the current
|
|
|
|
// contents of the frame's output buffer region
|
|
|
|
kBlendSource = 0,
|
|
|
|
|
|
|
|
// The frame should be composited onto the output buffer based on its alpha,
|
|
|
|
// using a simple OVER operation
|
|
|
|
kBlendOver
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kDisposeClearAll = -1, // Clear the whole image, revealing
|
|
|
|
// what was there before the gif displayed
|
|
|
|
kDisposeNotSpecified, // Leave frame, let new frame draw on top
|
|
|
|
kDisposeKeep, // Leave frame, let new frame draw on top
|
|
|
|
kDisposeClear, // Clear the frame's area, revealing bg
|
|
|
|
kDisposeRestorePrevious // Restore the previous (composited) frame
|
|
|
|
};
|
|
|
|
|
2010-08-25 22:58:27 +00:00
|
|
|
// Progressive decoding knobs
|
|
|
|
static void SetDecodeBytesAtATime(PRUint32 aBytesAtATime);
|
|
|
|
static void SetMaxMSBeforeYield(PRUint32 aMaxMS);
|
2010-08-26 22:54:21 +00:00
|
|
|
static void SetMaxBytesForSyncDecode(PRUint32 aMaxBytes);
|
2010-08-25 22:58:27 +00:00
|
|
|
|
2010-09-12 15:22:31 +00:00
|
|
|
const char* GetURIString() { return mURIString.get();}
|
|
|
|
|
2001-03-10 01:11:54 +00:00
|
|
|
private:
|
2007-03-20 23:56:50 +00:00
|
|
|
struct Anim
|
|
|
|
{
|
|
|
|
//! Area of the first frame that needs to be redrawn on subsequent loops.
|
|
|
|
nsIntRect firstFrameRefreshArea;
|
2009-09-12 22:44:18 +00:00
|
|
|
PRUint32 currentAnimationFrameIndex; // 0 to numFrames-1
|
2007-03-20 23:56:50 +00:00
|
|
|
//! Track the last composited frame for Optimizations (See DoComposite code)
|
|
|
|
PRInt32 lastCompositedFrameIndex;
|
|
|
|
/** For managing blending of frames
|
|
|
|
*
|
|
|
|
* Some animations will use the compositingFrame to composite images
|
|
|
|
* and just hand this back to the caller when it is time to draw the frame.
|
|
|
|
* NOTE: When clearing compositingFrame, remember to set
|
|
|
|
* lastCompositedFrameIndex to -1. Code assume that if
|
|
|
|
* lastCompositedFrameIndex >= 0 then compositingFrame exists.
|
|
|
|
*/
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsAutoPtr<imgFrame> compositingFrame;
|
2007-03-20 23:56:50 +00:00
|
|
|
/** the previous composited frame, for DISPOSE_RESTORE_PREVIOUS
|
|
|
|
*
|
|
|
|
* The Previous Frame (all frames composited up to the current) needs to be
|
|
|
|
* stored in cases where the image specifies it wants the last frame back
|
|
|
|
* when it's done with the current frame.
|
|
|
|
*/
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsAutoPtr<imgFrame> compositingPrevFrame;
|
2011-11-03 00:11:01 +00:00
|
|
|
//! Timer to animate multiframed images
|
|
|
|
nsCOMPtr<nsITimer> timer;
|
2010-05-12 21:41:47 +00:00
|
|
|
|
2007-03-20 23:56:50 +00:00
|
|
|
Anim() :
|
|
|
|
firstFrameRefreshArea(),
|
|
|
|
currentAnimationFrameIndex(0),
|
2011-11-03 00:11:01 +00:00
|
|
|
lastCompositedFrameIndex(-1)
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
~Anim()
|
|
|
|
{
|
|
|
|
if (timer)
|
|
|
|
timer->Cancel();
|
|
|
|
}
|
2007-03-20 23:56:50 +00:00
|
|
|
};
|
2007-10-19 00:36:34 +00:00
|
|
|
|
2010-03-08 19:01:04 +00:00
|
|
|
/**
|
|
|
|
* Deletes and nulls out the frame in mFrames[framenum].
|
|
|
|
*
|
|
|
|
* Does not change the size of mFrames.
|
|
|
|
*
|
|
|
|
* @param framenum The index of the frame to be deleted.
|
|
|
|
* Must lie in [0, mFrames.Length() )
|
|
|
|
*/
|
|
|
|
void DeleteImgFrame(PRUint32 framenum);
|
|
|
|
|
2011-07-21 18:14:41 +00:00
|
|
|
imgFrame* GetImgFrameNoDecode(PRUint32 framenum);
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
imgFrame* GetImgFrame(PRUint32 framenum);
|
2009-11-12 23:18:40 +00:00
|
|
|
imgFrame* GetDrawableImgFrame(PRUint32 framenum);
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
imgFrame* GetCurrentImgFrame();
|
2009-11-12 23:18:40 +00:00
|
|
|
imgFrame* GetCurrentDrawableImgFrame();
|
2009-09-12 22:44:18 +00:00
|
|
|
PRUint32 GetCurrentImgFrameIndex() const;
|
2007-03-20 23:56:50 +00:00
|
|
|
|
2011-07-23 18:49:00 +00:00
|
|
|
inline void EnsureAnimExists()
|
2009-09-12 22:44:18 +00:00
|
|
|
{
|
|
|
|
if (!mAnim) {
|
|
|
|
|
|
|
|
// Create the animation context
|
2007-03-20 23:56:50 +00:00
|
|
|
mAnim = new Anim();
|
2009-09-12 22:44:18 +00:00
|
|
|
|
2009-09-16 00:30:52 +00:00
|
|
|
// We don't support discarding animated images (See bug 414259).
|
|
|
|
// Lock the image and throw away the key.
|
|
|
|
//
|
|
|
|
// Note that this is inefficient, since we could get rid of the source
|
|
|
|
// data too. However, doing this is actually hard, because we're probably
|
|
|
|
// calling ensureAnimExists mid-decode, and thus we're decoding out of
|
|
|
|
// the source buffer. Since we're going to fix this anyway later, and
|
|
|
|
// since we didn't kill the source data in the old world either, locking
|
|
|
|
// is acceptable for the moment.
|
|
|
|
LockImage();
|
2009-09-12 22:44:18 +00:00
|
|
|
}
|
2007-03-20 23:56:50 +00:00
|
|
|
}
|
2011-11-03 00:11:01 +00:00
|
|
|
|
2007-03-20 23:56:50 +00:00
|
|
|
/** Function for doing the frame compositing of animations
|
|
|
|
*
|
|
|
|
* @param aDirtyRect Area that the display will need to update
|
|
|
|
* @param aPrevFrame Last Frame seen/processed
|
|
|
|
* @param aNextFrame Frame we need to incorperate/display
|
|
|
|
* @param aNextFrameIndex Position of aNextFrame in mFrames list
|
|
|
|
*/
|
2011-10-08 04:03:47 +00:00
|
|
|
nsresult DoComposite(nsIntRect* aDirtyRect,
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
imgFrame* aPrevFrame,
|
|
|
|
imgFrame* aNextFrame,
|
2007-03-20 23:56:50 +00:00
|
|
|
PRInt32 aNextFrameIndex);
|
2011-11-03 00:11:01 +00:00
|
|
|
|
2007-06-07 15:10:25 +00:00
|
|
|
/** Clears an area of <aFrame> with transparent black.
|
2007-04-25 21:21:28 +00:00
|
|
|
*
|
|
|
|
* @param aFrame Target Frame
|
|
|
|
*
|
2007-06-07 15:10:25 +00:00
|
|
|
* @note Does also clears the transparancy mask
|
2007-04-25 21:21:28 +00:00
|
|
|
*/
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
static void ClearFrame(imgFrame* aFrame);
|
2011-11-03 00:11:01 +00:00
|
|
|
|
2007-04-25 21:21:28 +00:00
|
|
|
//! @overload
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
static void ClearFrame(imgFrame* aFrame, nsIntRect &aRect);
|
2007-04-25 21:21:28 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
//! Copy one frames's image and mask into another
|
2011-09-29 06:19:26 +00:00
|
|
|
static bool CopyFrameImage(imgFrame *aSrcFrame,
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
imgFrame *aDstFrame);
|
2007-03-20 23:56:50 +00:00
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
/** Draws one frames's image to into another,
|
2007-08-25 19:18:44 +00:00
|
|
|
* at the position specified by aRect
|
|
|
|
*
|
|
|
|
* @param aSrcFrame Frame providing the source image
|
|
|
|
* @param aDstFrame Frame where the image is drawn into
|
|
|
|
* @param aRect The position and size to draw the image
|
|
|
|
*/
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
static nsresult DrawFrameTo(imgFrame *aSrcFrame,
|
|
|
|
imgFrame *aDstFrame,
|
2007-08-25 19:18:44 +00:00
|
|
|
nsIntRect& aRect);
|
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsresult InternalAddFrameHelper(PRUint32 framenum, imgFrame *frame,
|
|
|
|
PRUint8 **imageData, PRUint32 *imageLength,
|
|
|
|
PRUint32 **paletteData, PRUint32 *paletteLength);
|
|
|
|
nsresult InternalAddFrame(PRUint32 framenum, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight,
|
|
|
|
gfxASurface::gfxImageFormat aFormat, PRUint8 aPaletteDepth,
|
|
|
|
PRUint8 **imageData, PRUint32 *imageLength,
|
|
|
|
PRUint32 **paletteData, PRUint32 *paletteLength);
|
|
|
|
|
|
|
|
private: // data
|
|
|
|
|
2007-03-20 23:56:50 +00:00
|
|
|
nsIntSize mSize;
|
2011-01-13 01:45:13 +00:00
|
|
|
|
|
|
|
// Whether mFrames below were decoded using any special flags.
|
|
|
|
// Some flags (e.g. unpremultiplied data) may not be compatible
|
|
|
|
// with the browser's needs for displaying the image to the user.
|
|
|
|
// As such, we may need to redecode if we're being asked for
|
|
|
|
// a frame with different flags. 0 indicates default flags.
|
|
|
|
//
|
|
|
|
// Valid flag bits are imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA
|
|
|
|
// and imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION.
|
|
|
|
PRUint32 mFrameDecodeFlags;
|
|
|
|
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
//! All the frames of the image
|
2009-09-12 22:44:18 +00:00
|
|
|
// IMPORTANT: if you use mFrames in a method, call EnsureImageIsDecoded() first
|
|
|
|
// to ensure that the frames actually exist (they may have been discarded to save
|
|
|
|
// memory, or we may be decoding on draw).
|
Bug 753 - Remove nsIImage, gfxIImageFrame, and their implementations, and expose an equivalent api on imgIContainer. r=roc,josh,bz,longsonr,vlad,karlt,jimm,bsmedberg,mfinkle,peterw,peterv sr=vlad,roc
--HG--
rename : gfx/src/shared/gfxImageFrame.cpp => modules/libpr0n/src/imgFrame.cpp
rename : gfx/src/shared/gfxImageFrame.h => modules/libpr0n/src/imgFrame.h
2009-07-21 01:50:15 +00:00
|
|
|
nsTArray<imgFrame *> mFrames;
|
2007-03-20 23:56:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIProperties> mProperties;
|
2007-10-19 00:36:34 +00:00
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
// IMPORTANT: if you use mAnim in a method, call EnsureImageIsDecoded() first to ensure
|
|
|
|
// that the frames actually exist (they may have been discarded to save memory, or
|
|
|
|
// we maybe decoding on draw).
|
2010-08-14 04:09:49 +00:00
|
|
|
RasterImage::Anim* mAnim;
|
2007-03-20 23:56:50 +00:00
|
|
|
|
|
|
|
//! # loops remaining before animation stops (-1 no stop)
|
|
|
|
PRInt32 mLoopCount;
|
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
//! imgIDecoderObserver
|
2007-03-20 23:56:50 +00:00
|
|
|
nsWeakPtr mObserver;
|
2007-10-19 00:36:34 +00:00
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
// Discard members
|
|
|
|
PRUint32 mLockCount;
|
2010-08-14 04:09:49 +00:00
|
|
|
DiscardTrackerNode mDiscardTrackerNode;
|
2007-10-19 00:36:34 +00:00
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
// Source data members
|
2011-06-09 02:21:53 +00:00
|
|
|
FallibleTArray<char> mSourceData;
|
2009-09-12 22:44:18 +00:00
|
|
|
nsCString mSourceDataMimeType;
|
2010-09-12 15:22:26 +00:00
|
|
|
nsCString mURIString;
|
2009-09-12 22:44:18 +00:00
|
|
|
|
|
|
|
friend class imgDecodeWorker;
|
2010-08-14 04:09:49 +00:00
|
|
|
friend class DiscardTracker;
|
2009-09-12 22:44:18 +00:00
|
|
|
|
|
|
|
// Decoder and friends
|
2010-08-23 02:30:46 +00:00
|
|
|
nsRefPtr<Decoder> mDecoder;
|
2009-09-12 22:44:18 +00:00
|
|
|
nsRefPtr<imgDecodeWorker> mWorker;
|
|
|
|
PRUint32 mBytesDecoded;
|
|
|
|
|
2011-09-08 18:05:11 +00:00
|
|
|
// How many times we've decoded this image.
|
|
|
|
// This is currently only used for statistics
|
|
|
|
PRInt32 mDecodeCount;
|
|
|
|
|
2011-11-09 03:14:41 +00:00
|
|
|
// Cached value for GetImageContainer.
|
|
|
|
nsRefPtr<mozilla::layers::ImageContainer> mImageContainer;
|
|
|
|
|
2010-09-08 00:34:18 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRUint32 mFramesNotified;
|
|
|
|
#endif
|
|
|
|
|
2010-05-12 21:41:47 +00:00
|
|
|
// Boolean flags (clustered together to conserve space):
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mHasSize:1; // Has SetSize() been called?
|
|
|
|
bool mDecodeOnDraw:1; // Decoding on draw?
|
|
|
|
bool mMultipart:1; // Multipart?
|
|
|
|
bool mDiscardable:1; // Is container discardable?
|
|
|
|
bool mHasSourceData:1; // Do we have source data?
|
2010-05-12 21:41:47 +00:00
|
|
|
|
|
|
|
// Do we have the frames in decoded form?
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mDecoded:1;
|
|
|
|
bool mHasBeenDecoded:1;
|
2010-05-12 21:41:47 +00:00
|
|
|
|
|
|
|
// Helpers for decoder
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mWorkerPending:1;
|
|
|
|
bool mInDecoder:1;
|
2010-05-12 21:41:47 +00:00
|
|
|
|
2010-09-08 00:33:02 +00:00
|
|
|
// Whether the animation can stop, due to running out
|
|
|
|
// of frames, or no more owning request
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mAnimationFinished:1;
|
2010-09-08 00:33:02 +00:00
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
// Decoding
|
|
|
|
nsresult WantDecodedFrames();
|
|
|
|
nsresult SyncDecode();
|
2010-08-23 02:30:46 +00:00
|
|
|
nsresult InitDecoder(bool aDoSizeDecode);
|
2009-09-12 22:44:18 +00:00
|
|
|
nsresult WriteToDecoder(const char *aBuffer, PRUint32 aCount);
|
|
|
|
nsresult DecodeSomeData(PRUint32 aMaxBytes);
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsDecodeFinished();
|
2011-08-10 23:12:08 +00:00
|
|
|
TimeStamp mDrawStartTime;
|
2009-09-12 22:44:18 +00:00
|
|
|
|
|
|
|
// Decoder shutdown
|
|
|
|
enum eShutdownIntent {
|
|
|
|
eShutdownIntent_Done = 0,
|
|
|
|
eShutdownIntent_Interrupted = 1,
|
|
|
|
eShutdownIntent_Error = 2,
|
|
|
|
eShutdownIntent_AllCount = 3
|
|
|
|
};
|
|
|
|
nsresult ShutdownDecoder(eShutdownIntent aIntent);
|
|
|
|
|
|
|
|
// Helpers
|
|
|
|
void DoError();
|
2011-08-05 13:57:16 +00:00
|
|
|
bool CanDiscard();
|
|
|
|
bool CanForciblyDiscard();
|
|
|
|
bool DiscardingActive();
|
|
|
|
bool StoringSourceData();
|
2009-09-12 22:44:18 +00:00
|
|
|
|
2010-09-08 00:33:02 +00:00
|
|
|
protected:
|
2011-08-05 13:57:16 +00:00
|
|
|
bool ShouldAnimate();
|
2009-09-12 22:44:18 +00:00
|
|
|
};
|
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
// XXXdholbert These helper classes should move to be inside the
|
|
|
|
// scope of the RasterImage class.
|
2009-09-12 22:44:18 +00:00
|
|
|
// Decoding Helper Class
|
|
|
|
//
|
|
|
|
// We use this class to mimic the interactivity benefits of threading
|
|
|
|
// in a single-threaded event loop. We want to progressively decode
|
|
|
|
// and keep a responsive UI while we're at it, so we have a runnable
|
|
|
|
// class that does a bit of decoding, and then "yields" by dispatching
|
|
|
|
// itself to the end of the event queue.
|
|
|
|
class imgDecodeWorker : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
imgDecodeWorker(imgIContainer* aContainer) {
|
|
|
|
mContainer = do_GetWeakReference(aContainer);
|
|
|
|
}
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
NS_METHOD Dispatch();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakPtr mContainer;
|
2011-08-04 20:25:12 +00:00
|
|
|
TimeDuration mDecodeTime; // the default constructor initializes to 0
|
2001-03-10 01:11:54 +00:00
|
|
|
};
|
|
|
|
|
2009-09-12 22:44:18 +00:00
|
|
|
// Asynchronous Decode Requestor
|
|
|
|
//
|
|
|
|
// We use this class when someone calls requestDecode() from within a decode
|
|
|
|
// notification. Since requestDecode() involves modifying the decoder's state
|
|
|
|
// (for example, possibly shutting down a header-only decode and starting a
|
|
|
|
// full decode), we don't want to do this from inside a decoder.
|
|
|
|
class imgDecodeRequestor : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
imgDecodeRequestor(imgIContainer *aContainer) {
|
|
|
|
mContainer = do_GetWeakReference(aContainer);
|
|
|
|
}
|
|
|
|
NS_IMETHOD Run() {
|
|
|
|
nsCOMPtr<imgIContainer> con = do_QueryReferent(mContainer);
|
|
|
|
if (con)
|
|
|
|
con->RequestDecode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsWeakPtr mContainer;
|
|
|
|
};
|
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
} // namespace imagelib
|
|
|
|
} // namespace mozilla
|
2009-09-12 22:44:18 +00:00
|
|
|
|
2010-08-14 04:09:49 +00:00
|
|
|
#endif /* mozilla_imagelib_RasterImage_h_ */
|