Logo Search packages:      
Sourcecode: xulrunner version File versions

imgContainer Class Reference

#include <imgContainer.h>

Inheritance diagram for imgContainer:

imgIContainer nsISupports nsISupports nsISupports

List of all members.

Detailed Description

Handles static and animated image containers.

A Quick Walk Through
The decoder initializes this class and calls AppendFrame() to add a frame. Once imgContainer detects more than one frame, it starts the animation with StartAnimation().
StartAnimation() checks if animating is allowed, and creates a timer. The timer calls Notify when the specified frame delay time is up.
Notify() moves on to the next frame, sets up the new timer delay, destroys the old frame, and forces a redraw via observer->FrameChanged().
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.
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.
The rest of the imgContainer specific functions are used by DoComposite to destroy the old frame and build the new one.
"Mask", "Alpha", and "Alpha Level" are interchangable phrases in respects to imgContainer.
GIFs never have more than a 1 bit alpha. APNGs may have a full alpha channel.
Background color specified in GIF is ignored by web browsers.
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.
The mAnim structure has members only needed for animated images, so it's not allocated until the second frame is added.
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().

Definition at line 134 of file imgContainer.h.

Public Member Functions

void addRestoreData ([array, size_is(aCount), const ] in char data, in unsigned long aCount)
void appendFrame (in gfxIImageFrame item)
void clear ()
void decodingComplete ()
void endFrameDecode (in unsigned long framenumber, in unsigned long timeout)
void get (in string prop, in nsIIDRef iid,[iid_is(iid), retval] out nsQIResult result)
gfxIImageFrame getFrameAt (in unsigned long index)
void getKeys (out PRUint32 count,[array, size_is(count), retval] out string keys)
boolean has (in string prop)
void init (in PRInt32 aWidth, in PRInt32 aHeight, in imgIContainerObserver aObserver)
void notify (in nsITimer timer)
void removeFrame (in gfxIImageFrame item)
void resetAnimation ()
void restoreDataDone ()
void set (in string prop, in nsISupports value)
void setDiscardable (in string aMimeType)
void startAnimation ()
void stopAnimation ()
void undefine (in string prop)
 NS_IMETHOD_ (nsrefcnt) Release(void)=0
 NS_IMETHOD_ (nsrefcnt) AddRef(void)=0
NS_IMETHOD QueryInterface (REFNSIID aIID, void **aInstancePtr)=0

Public Attributes

attribute unsigned short animationMode
readonly attribute gfxIImageFrame currentFrame
readonly attribute PRInt32 height
const long kBlendOver = 1
const long kBlendSource = 0
const long kDisposeClear = 2
const long kDisposeClearAll = -1
const long kDisposeKeep = 1
const long kDisposeNotSpecified = 0
const long kDisposeRestorePrevious = 3
const short kDontAnimMode = 1
const short kLoopOnceAnimMode = 2
const short kNormalAnimMode = 0
attribute long loopCount
readonly attribute unsigned long numFrames
readonly attribute gfx_format preferredAlphaChannelFormat
readonly attribute PRInt32 width

Private Member Functions

void BuildCompositeMask (gfxIImageFrame *aCompositingFrame, gfxIImageFrame *aOverlayFrame)
nsresult DoComposite (gfxIImageFrame **aFrameToUse, nsIntRect *aDirtyRect, gfxIImageFrame *aPrevFrame, gfxIImageFrame *aNextFrame, PRInt32 aNextFrameIndex)
Anim * ensureAnimExists ()
gfxIImageFrameGetCurrentFrameNoRef ()
nsresult ReloadImages (void)
nsresult ResetDiscardTimer (void)
nsresult RestoreDiscardedData (void)
void SetMaskVisibility (gfxIImageFrame *aFrame, nsIntRect &aRect, PRBool aVisible)
void SetMaskVisibility (gfxIImageFrame *aFrame, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aVisible)
void SetMaskVisibility (gfxIImageFrame *aFrame, PRBool aVisible)

Static Private Member Functions

static void ClearFrame (gfxIImageFrame *aFrame, nsIntRect &aRect)
static void ClearFrame (gfxIImageFrame *aFrame)
static PRBool CopyFrameImage (gfxIImageFrame *aSrcFrame, gfxIImageFrame *aDstFrame)
 Copy one gfxIImageFrame's image and mask into another.
static nsresult DrawFrameTo (gfxIImageFrame *aSrcFrame, gfxIImageFrame *aDstFrame, nsIntRect &aRect)
static void sDiscardTimerCallback (nsITimer *aTimer, void *aClosure)

Private Attributes

imgContainer::Anim * mAnim
PRUint16 mAnimationMode
 See imgIContainer for mode constants.
PRBool mDiscardable
nsCString mDiscardableMimeType
PRBool mDiscarded
nsCOMPtr< nsITimermDiscardTimer
nsCOMArray< gfxIImageFramemFrames
 All the <gfxIImageFrame>s of the PNG.
PRInt32 mLoopCount
 # loops remaining before animation stops (-1 no stop)
int mNumFrames
nsWeakPtr mObserver
nsCOMPtr< nsIProperties > mProperties
nsTArray< char > mRestoreData
PRBool mRestoreDataDone
nsIntSize mSize


struct  Anim

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index