Bug 565124: Use PRPackedBool instead of PRBool for member variables in imgContainer. r=joe
authorDaniel Holbert <dholbert@cs.stanford.edu>
Wed, 12 May 2010 14:41:47 -0700
changeset 42233 cd6413bdc6de5cb9395ada5feaa9e365deed7227
parent 42232 911cc89e3cc531e69fb2bd0954d6db2f43045c9f
child 42234 fd883c55f992be5fb3fc147ebabfa168ddd6d331
push idunknown
push userunknown
push dateunknown
reviewersjoe
bugs565124
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 565124: Use PRPackedBool instead of PRBool for member variables in imgContainer. r=joe
modules/libpr0n/src/imgContainer.cpp
modules/libpr0n/src/imgContainer.h
--- a/modules/libpr0n/src/imgContainer.cpp
+++ b/modules/libpr0n/src/imgContainer.cpp
@@ -134,34 +134,34 @@ DiscardingEnabled()
 }
 
 NS_IMPL_ISUPPORTS4(imgContainer, imgIContainer, nsITimerCallback, nsIProperties,
                    nsISupportsWeakReference)
 
 //******************************************************************************
 imgContainer::imgContainer() :
   mSize(0,0),
-  mHasSize(PR_FALSE),
   mAnim(nsnull),
   mAnimationMode(kNormalAnimMode),
   mLoopCount(-1),
   mObserver(nsnull),
+  mLockCount(0),
+  mDiscardTimer(nsnull),
+  mDecoder(nsnull),
+  mWorker(nsnull),
+  mBytesDecoded(0),
+  mDecoderFlags(imgIDecoder::DECODER_FLAG_NONE),
+  mHasSize(PR_FALSE),
   mDecodeOnDraw(PR_FALSE),
   mMultipart(PR_FALSE),
   mInitialized(PR_FALSE),
   mDiscardable(PR_FALSE),
-  mLockCount(0),
-  mDiscardTimer(nsnull),
   mHasSourceData(PR_FALSE),
   mDecoded(PR_FALSE),
   mHasBeenDecoded(PR_FALSE),
-  mDecoder(nsnull),
-  mWorker(nsnull),
-  mBytesDecoded(0),
-  mDecoderFlags(imgIDecoder::DECODER_FLAG_NONE),
   mWorkerPending(PR_FALSE),
   mInDecoder(PR_FALSE),
   mError(PR_FALSE)
 {
   // Statistics
   num_containers++;
 }
 
--- a/modules/libpr0n/src/imgContainer.h
+++ b/modules/libpr0n/src/imgContainer.h
@@ -159,21 +159,16 @@ private:
   {
     //! Area of the first frame that needs to be redrawn on subsequent loops.
     nsIntRect                  firstFrameRefreshArea;
     // Note this doesn't hold a proper value until frame 2 finished decoding.
     PRUint32                   currentDecodingFrameIndex; // 0 to numFrames-1
     PRUint32                   currentAnimationFrameIndex; // 0 to numFrames-1
     //! Track the last composited frame for Optimizations (See DoComposite code)
     PRInt32                    lastCompositedFrameIndex;
-    //! Whether we can assume there will be no more frames
-    //! (and thus loop the animation)
-    PRBool                     doneDecoding;
-    //! Are we currently animating the image?
-    PRBool                     animating;
     /** 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.
      */
@@ -182,17 +177,22 @@ private:
      *
      * 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.
      */
     nsAutoPtr<imgFrame>        compositingPrevFrame;
     //! Timer to animate multiframed images
     nsCOMPtr<nsITimer>         timer;
-    
+    //! Whether we can assume there will be no more frames
+    //! (and thus loop the animation)
+    PRPackedBool               doneDecoding;
+    //! Are we currently animating the image?
+    PRPackedBool               animating;
+
     Anim() :
       firstFrameRefreshArea(),
       currentDecodingFrameIndex(0),
       currentAnimationFrameIndex(0),
       lastCompositedFrameIndex(-1),
       doneDecoding(PR_FALSE),
       animating(PR_FALSE)
     {
@@ -288,17 +288,16 @@ private:
   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
 
   nsIntSize                  mSize;
-  PRBool                     mHasSize;
   
   //! All the frames of the image
   // 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).
   nsTArray<imgFrame *>       mFrames;
   
   nsCOMPtr<nsIProperties>    mProperties;
@@ -312,51 +311,49 @@ private: // data
   PRUint16                   mAnimationMode;
   
   //! # loops remaining before animation stops (-1 no stop)
   PRInt32                    mLoopCount;
   
   //! imgIDecoderObserver
   nsWeakPtr                  mObserver;
 
-  // Decoding on draw?
-  PRBool                     mDecodeOnDraw;
-
-  // Multipart?
-  PRBool                     mMultipart;
-
-  // Have we been initalized?
-  PRBool                     mInitialized;
-
   // Discard members
-  PRBool                     mDiscardable;
   PRUint32                   mLockCount;
   nsCOMPtr<nsITimer>         mDiscardTimer;
 
   // Source data members
   nsTArray<char>             mSourceData;
-  PRBool                     mHasSourceData;
   nsCString                  mSourceDataMimeType;
 
-  // Do we have the frames in decoded form?
-  PRBool                     mDecoded;
-  PRBool                     mHasBeenDecoded;
-
   friend class imgDecodeWorker;
 
   // Decoder and friends
   nsCOMPtr<imgIDecoder>          mDecoder;
   nsRefPtr<imgDecodeWorker>      mWorker;
   PRUint32                       mBytesDecoded;
   PRUint32                       mDecoderFlags;
-  PRBool                         mWorkerPending;
-  PRBool                         mInDecoder;
+
+  // Boolean flags (clustered together to conserve space):
+  PRPackedBool               mHasSize:1;       // Has SetSize() been called?
+  PRPackedBool               mDecodeOnDraw:1;  // Decoding on draw?
+  PRPackedBool               mMultipart:1;     // Multipart?
+  PRPackedBool               mInitialized:1;   // Have we been initalized?
+  PRPackedBool               mDiscardable:1;   // Is container discardable?
+  PRPackedBool               mHasSourceData:1; // Do we have source data?
 
-  // Error handling
-  PRBool                         mError;
+  // Do we have the frames in decoded form?
+  PRPackedBool               mDecoded:1;
+  PRPackedBool               mHasBeenDecoded:1;
+
+  // Helpers for decoder
+  PRPackedBool               mWorkerPending:1;
+  PRPackedBool               mInDecoder:1;
+
+  PRPackedBool               mError:1;  // Error handling
 
   // Discard code
   nsresult ResetDiscardTimer();
   static void sDiscardTimerCallback(nsITimer *aTimer, void *aClosure);
 
   // Decoding
   nsresult WantDecodedFrames();
   nsresult SyncDecode();