Bug 547143. r=jrmuizel sr=roc
authorJoe Drew <joe@drew.ca>
Mon, 08 Mar 2010 14:01:04 -0500
changeset 39120 a1eaad798c2a4d5629c75a3c4c5563e6c532b7cd
parent 39119 e050d3eaf1dd2f6e56750ce0b6f589d0449e4a64
child 39121 81e60d14dd49b888cd3cd200c785486e79fccb1c
push id12023
push userjdrew@mozilla.com
push dateMon, 08 Mar 2010 19:08:34 +0000
treeherderautoland@81e60d14dd49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, roc
bugs547143
milestone1.9.3a3pre
Bug 547143. r=jrmuizel sr=roc
modules/libpr0n/src/imgContainer.cpp
modules/libpr0n/src/imgContainer.h
--- a/modules/libpr0n/src/imgContainer.cpp
+++ b/modules/libpr0n/src/imgContainer.cpp
@@ -648,16 +648,24 @@ NS_IMETHODIMP imgContainer::GetDataSize(
     imgFrame *frame = mFrames.SafeElementAt(i, nsnull);
     NS_ABORT_IF_FALSE(frame, "Null frame in frame array!");
     *_retval += frame->GetImageDataLength();
   }
 
   return NS_OK;
 }
 
+void imgContainer::DeleteImgFrame(PRUint32 framenum)
+{
+  NS_ABORT_IF_FALSE(framenum < mFrames.Length(), "Deleting invalid frame!");
+
+  delete mFrames[framenum];
+  mFrames[framenum] = nsnull;
+}
+
 nsresult imgContainer::InternalAddFrameHelper(PRUint32 framenum, imgFrame *aFrame,
                                               PRUint8 **imageData, PRUint32 *imageLength,
                                               PRUint32 **paletteData, PRUint32 *paletteLength)
 {
   NS_ABORT_IF_FALSE(framenum <= mFrames.Length(), "Invalid frame index!");
   if (framenum > mFrames.Length())
     return NS_ERROR_INVALID_ARG;
 
@@ -854,17 +862,17 @@ NS_IMETHODIMP imgContainer::EnsureCleanF
                             /* aPaletteDepth = */ 0, imageData, imageLength,
                             /* aPaletteData = */ nsnull, 
                             /* aPaletteLength = */ nsnull);
 
   // See if we can re-use the frame that already exists.
   nsIntRect rect = frame->GetRect();
   if (rect.x != aX || rect.y != aY || rect.width != aWidth || rect.height != aHeight ||
       frame->GetFormat() != aFormat) {
-    delete frame;
+    DeleteImgFrame(aFrameNum);
     return InternalAddFrame(aFrameNum, aX, aY, aWidth, aHeight, aFormat, 
                             /* aPaletteDepth = */ 0, imageData, imageLength,
                             /* aPaletteData = */ nsnull, 
                             /* aPaletteLength = */ nsnull);
   }
 
   // We can re-use the frame.
   frame->GetImageData(imageData, imageLength);
--- a/modules/libpr0n/src/imgContainer.h
+++ b/modules/libpr0n/src/imgContainer.h
@@ -200,16 +200,26 @@ private:
     }
     ~Anim()
     {
       if (timer)
         timer->Cancel();
     }
   };
 
+  /**
+   * 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);
+
   imgFrame* GetImgFrame(PRUint32 framenum);
   imgFrame* GetDrawableImgFrame(PRUint32 framenum);
   imgFrame* GetCurrentImgFrame();
   imgFrame* GetCurrentDrawableImgFrame();
   PRUint32 GetCurrentImgFrameIndex() const;
   
   inline Anim* ensureAnimExists()
   {