Bug 836155 - Replace GetCurrentFrameRect() with FrameRect(aWhichFrame). r=joe
authorSeth Fowler <seth@mozilla.com>
Mon, 04 Feb 2013 16:06:14 -0800
changeset 130698 e9b342a7e9b83521aad133c2f5e5028087a175ff
parent 130697 04be5f5f4b183cce4a3b75bc5e03ae92df85af2d
child 130699 3196b34c41e26cd27deb3ebf92aca777f9ae1441
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs836155
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 836155 - Replace GetCurrentFrameRect() with FrameRect(aWhichFrame). r=joe
image/src/Image.h
image/src/RasterImage.cpp
image/src/RasterImage.h
image/src/VectorImage.cpp
image/src/VectorImage.h
image/src/imgStatusTracker.cpp
--- a/image/src/Image.h
+++ b/image/src/Image.h
@@ -60,20 +60,19 @@ public:
    */
   virtual nsresult Init(imgDecoderObserver* aObserver,
                         const char* aMimeType,
                         uint32_t aFlags) = 0;
 
   virtual imgStatusTracker& GetStatusTracker() = 0;
 
   /**
-   * The rectangle defining the location and size of the currently displayed
-   * frame.
+   * The rectangle defining the location and size of the given frame.
    */
-  virtual void GetCurrentFrameRect(nsIntRect& aRect) = 0;
+  virtual nsIntRect FrameRect(uint32_t aWhichFrame) = 0;
 
   /**
    * The size, in bytes, occupied by the significant data portions of the image.
    * This includes both compressed source data and decoded frames.
    */
   virtual uint32_t SizeOfData() = 0;
 
   /**
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -900,34 +900,39 @@ RasterImage::FrameIsOpaque(uint32_t aWhi
   // Other, the frame is transparent if either:
   //  1. It needs a background.
   //  2. Its size doesn't cover our entire area.
   nsIntRect framerect = frame->GetRect();
   return !frame->GetNeedsBackground() &&
          framerect.IsEqualInterior(nsIntRect(0, 0, mSize.width, mSize.height));
 }
 
-void
-RasterImage::GetCurrentFrameRect(nsIntRect& aRect)
+nsIntRect
+RasterImage::FrameRect(uint32_t aWhichFrame)
 {
-  // Get the current frame
-  imgFrame* curframe = GetCurrentImgFrame();
-
-  // If we have the frame, use that rectangle
-  if (curframe) {
-    aRect = curframe->GetRect();
-  } else {
-    // If the frame doesn't exist, we pass the empty rectangle. It's not clear
-    // whether this is appropriate in general, but at the moment the only
-    // consumer of this method is imgStatusTracker (when it wants to figure out
-    // dirty rectangles to send out batched observer updates). This should
-    // probably be revisited when we fix bug 503973.
-    aRect.MoveTo(0, 0);
-    aRect.SizeTo(0, 0);
+  if (aWhichFrame > FRAME_MAX_VALUE) {
+    NS_WARNING("aWhichFrame outside valid range!");
+    return nsIntRect();
   }
+
+  // Get the requested frame.
+  imgFrame* frame = aWhichFrame == FRAME_FIRST ? GetImgFrame(0)
+                                               : GetCurrentImgFrame();
+
+  // If we have the frame, use that rectangle.
+  if (frame) {
+    return frame->GetRect();
+  }
+
+  // If the frame doesn't exist, we return the empty rectangle. It's not clear
+  // whether this is appropriate in general, but at the moment the only
+  // consumer of this method is imgStatusTracker (when it wants to figure out
+  // dirty rectangles to send out batched observer updates). This should
+  // probably be revisited when we fix bug 503973.
+  return nsIntRect();
 }
 
 uint32_t
 RasterImage::GetCurrentFrameIndex()
 {
   return GetCurrentImgFrameIndex();
 }
 
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -155,17 +155,17 @@ public:
 
   virtual nsresult StartAnimation();
   virtual nsresult StopAnimation();
 
   // Methods inherited from Image
   nsresult Init(imgDecoderObserver* aObserver,
                 const char* aMimeType,
                 uint32_t aFlags);
-  virtual void  GetCurrentFrameRect(nsIntRect& aRect) MOZ_OVERRIDE;
+  virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
 
   // Raster-specific methods
   static NS_METHOD WriteToRasterImage(nsIInputStream* aIn, void* aClosure,
                                       const char* aFromRawSegment,
                                       uint32_t aToOffset, uint32_t aCount,
                                       uint32_t* aWriteCount);
 
   /* The index of the current frame that would be drawn if the image was to be
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -208,20 +208,20 @@ VectorImage::Init(imgDecoderObserver* aO
   }
   NS_ABORT_IF_FALSE(!strcmp(aMimeType, IMAGE_SVG_XML), "Unexpected mimetype");
 
   mIsInitialized = true;
 
   return NS_OK;
 }
 
-void
-VectorImage::GetCurrentFrameRect(nsIntRect& aRect)
+nsIntRect
+VectorImage::FrameRect(uint32_t aWhichFrame)
 {
-  aRect = nsIntRect::GetMaxSizedIntRect();
+  return nsIntRect::GetMaxSizedIntRect();
 }
 
 size_t
 VectorImage::HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const
 {
   // We're not storing the source data -- we just feed that directly to
   // our helper SVG document as we receive it, for it to parse.
   // So 0 is an appropriate return value here.
--- a/image/src/VectorImage.h
+++ b/image/src/VectorImage.h
@@ -35,17 +35,17 @@ public:
 
   // (no public constructor - use ImageFactory)
   virtual ~VectorImage();
 
   // Methods inherited from Image
   nsresult Init(imgDecoderObserver* aObserver,
                 const char* aMimeType,
                 uint32_t aFlags);
-  virtual void GetCurrentFrameRect(nsIntRect& aRect) MOZ_OVERRIDE;
+  virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE;
 
   virtual size_t HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const;
   virtual size_t HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const;
   virtual size_t NonHeapSizeOfDecoded() const;
   virtual size_t OutOfProcessSizeOfDecoded() const;
 
   virtual nsresult OnImageDataAvailable(nsIRequest* aRequest,
                                         nsISupports* aContext,
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -366,18 +366,17 @@ imgStatusTracker::SyncNotify(imgRequestP
   // BlockOnload
   if (mState & stateBlockingOnload)
     proxy->BlockOnload();
 
   if (mImage) {
     // OnDataAvailable
     // XXX - Should only send partial rects here, but that needs to
     // wait until we fix up the observer interface
-    nsIntRect r;
-    mImage->GetCurrentFrameRect(r);
+    nsIntRect r(mImage->FrameRect(imgIContainer::FRAME_CURRENT));
 
     // If there's any content in this frame at all (always true for
     // vector images, true for raster images that have decoded at
     // least one frame) then send OnFrameUpdate.
     if (!r.IsEmpty())
       proxy->OnFrameUpdate(&r);
 
     if (mState & stateFrameStopped)