Bug 1128769 (Part 6) - Remove imgIContainer::IsDecoded and all remaining callers. r=tn a=lmandel ba=lmandel
authorSeth Fowler <seth@mozilla.com>
Mon, 09 Feb 2015 23:27:40 -0800
changeset 250154 7b3c7ba30dfe
parent 250153 498290d95f1c
child 250155 70787b6f48c3
child 250158 49c645204a22
child 250160 67a12d77e65d
push id4514
push usermfowler@mozilla.com
push date2015-03-02 22:11 +0000
treeherdermozilla-beta@7b3c7ba30dfe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn, lmandel
bugs1128769
milestone37.0
Bug 1128769 (Part 6) - Remove imgIContainer::IsDecoded and all remaining callers. r=tn a=lmandel ba=lmandel
image/public/imgIContainer.idl
image/src/DynamicImage.cpp
image/src/ImageWrapper.cpp
image/src/RasterImage.cpp
image/src/VectorImage.cpp
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRendering.h
layout/base/nsDisplayList.cpp
layout/base/nsDisplayList.h
--- a/image/public/imgIContainer.idl
+++ b/image/public/imgIContainer.idl
@@ -111,17 +111,17 @@ native nsIntSizeByVal(nsIntSize);
 
 /**
  * imgIContainer is the interface that represents an image. It allows
  * access to frames as Thebes surfaces. It also allows drawing of images
  * onto Thebes contexts.
  *
  * Internally, imgIContainer also manages animation of images.
  */
-[scriptable, builtinclass, uuid(4e7d0b17-cb57-4d68-860f-59b303a86dbd)]
+[scriptable, builtinclass, uuid(9a43298b-bf49-44fc-9abe-9ff702f1bd25)]
 interface imgIContainer : nsISupports
 {
   /**
    * The width of the container rectangle.  In the case of any error,
    * zero is returned, and an exception will be thrown.
    */
   readonly attribute int32_t width;
 
@@ -420,24 +420,16 @@ interface imgIContainer : nsISupports
    *               (FLAG_DECODE_*) and FLAG_SYNC_DECODE (which will
    *               synchronously decode images that can be decoded "quickly",
    *               just like startDecoding() does) are accepted; others will be
    *               ignored.
    */
   [noscript] void requestDecodeForSize([const] in nsIntSize aSize,
                                        in uint32_t aFlags);
 
-  /*
-   * Returns true if no more decoding can be performed on this image. Images
-   * with errors return true since they cannot be decoded any further. Note that
-   * because decoded images may be discarded, isDecoded() may return false even
-   * if it has returned true in the past.
-   */
-  [noscript, notxpcom, nostdcall] bool isDecoded();
-
   /**
     * Increments the lock count on the image. An image will not be discarded
     * as long as the lock count is nonzero. Note that it is still possible for
     * the image to be undecoded if decode-on-draw is enabled and the image
     * was never drawn.
     *
     * Upon instantiation images have a lock count of zero.
     */
--- a/image/src/DynamicImage.cpp
+++ b/image/src/DynamicImage.cpp
@@ -255,22 +255,16 @@ DynamicImage::StartDecoding()
 }
 
 NS_IMETHODIMP
 DynamicImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
 {
   return NS_OK;
 }
 
-bool
-DynamicImage::IsDecoded()
-{
-  return true;
-}
-
 NS_IMETHODIMP
 DynamicImage::LockImage()
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DynamicImage::UnlockImage()
--- a/image/src/ImageWrapper.cpp
+++ b/image/src/ImageWrapper.cpp
@@ -225,22 +225,16 @@ ImageWrapper::StartDecoding()
 }
 
 NS_IMETHODIMP
 ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
 {
   return mInnerImage->RequestDecodeForSize(aSize, aFlags);
 }
 
-bool
-ImageWrapper::IsDecoded()
-{
-  return mInnerImage->IsDecoded();
-}
-
 NS_IMETHODIMP
 ImageWrapper::LockImage()
 {
   MOZ_ASSERT(NS_IsMainThread(),
              "Main thread to encourage serialization with UnlockImage");
   return mInnerImage->LockImage();
 }
 
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -1464,23 +1464,16 @@ RasterImage::RequestDecodeForSize(const 
 
   // Look up the first frame of the image, which will implicitly start decoding
   // if it's not available right now.
   LookupFrame(0, targetSize, flags);
 
   return NS_OK;
 }
 
-bool
-RasterImage::IsDecoded()
-{
-  // XXX(seth): We need to get rid of this; it's not reliable.
-  return mHasBeenDecoded || mError || (mDecodeOnDraw && mHasSourceData);
-}
-
 NS_IMETHODIMP
 RasterImage::Decode(const Maybe<nsIntSize>& aSize, uint32_t aFlags)
 {
   MOZ_ASSERT(!aSize || NS_IsMainThread());
 
   if (mError) {
     return NS_ERROR_FAILURE;
   }
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -926,22 +926,16 @@ NS_IMETHODIMP
 VectorImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
 {
   // Nothing to do for SVG images, though in theory we could rasterize to the
   // provided size ahead of time if we supported off-main-thread SVG
   // rasterization...
   return NS_OK;
 }
 
-bool
-VectorImage::IsDecoded()
-{
-  return mIsFullyLoaded || mError;
-}
-
 //******************************************************************************
 /* void lockImage() */
 NS_IMETHODIMP
 VectorImage::LockImage()
 {
   // This method is for image-discarding, which only applies to RasterImages.
   return NS_OK;
 }
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -3342,44 +3342,16 @@ nsCSSRendering::GetBackgroundLayerRect(n
   nsRect borderArea =
     ::BoxDecorationRectForBackground(aForFrame, aBorderArea, skipSides);
   nsBackgroundLayerState state =
       PrepareBackgroundLayer(aPresContext, aForFrame, aFlags, borderArea,
                              aClipRect, aLayer);
   return state.mFillArea;
 }
 
-/* static */ bool
-nsCSSRendering::IsBackgroundImageDecodedForStyleContextAndLayer(
-  const nsStyleBackground *aBackground, uint32_t aLayer)
-{
-  const nsStyleImage* image = &aBackground->mLayers[aLayer].mImage;
-  if (image->GetType() == eStyleImageType_Image) {
-    nsCOMPtr<imgIContainer> img;
-    if (NS_SUCCEEDED(image->GetImageData()->GetImage(getter_AddRefs(img)))) {
-      if (!img->IsDecoded()) {
-        return false;
-      }
-    }
-  }
-  return true;
-}
-
-/* static */ bool
-nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(nsIFrame* aFrame)
-{
-  const nsStyleBackground *bg = aFrame->StyleContext()->StyleBackground();
-  NS_FOR_VISIBLE_BACKGROUND_LAYERS_BACK_TO_FRONT(i, bg) {
-    if (!IsBackgroundImageDecodedForStyleContextAndLayer(bg, i)) {
-      return false;
-    }
-  }
-  return true;
-}
-
 static void
 DrawBorderImage(nsPresContext*       aPresContext,
                 nsRenderingContext&  aRenderingContext,
                 nsIFrame*            aForFrame,
                 const nsRect&        aBorderArea,
                 const nsStyleBorder& aStyleBorder,
                 const nsRect&        aDirtyRect,
                 Sides                aSkipSides)
--- a/layout/base/nsCSSRendering.h
+++ b/layout/base/nsCSSRendering.h
@@ -594,28 +594,16 @@ struct nsCSSRendering {
   static nsRect GetBackgroundLayerRect(nsPresContext* aPresContext,
                                        nsIFrame* aForFrame,
                                        const nsRect& aBorderArea,
                                        const nsRect& aClipRect,
                                        const nsStyleBackground::Layer& aLayer,
                                        uint32_t aFlags);
 
   /**
-   * Checks if image in layer aLayer of aBackground is currently decoded.
-   */
-  static bool IsBackgroundImageDecodedForStyleContextAndLayer(
-    const nsStyleBackground *aBackground, uint32_t aLayer);
-
-  /**
-   * Checks if all images that are part of the background for aFrame are
-   * currently decoded.
-   */
-  static bool AreAllBackgroundImagesDecodedForFrame(nsIFrame* aFrame);
-
-  /**
    * Called when we start creating a display list. The frame tree will not
    * change until a matching EndFrameTreeLocked is called.
    */
   static void BeginFrameTreesLocked();
   /**
    * Called when we've finished using a display list. When all
    * BeginFrameTreeLocked calls have been balanced by an EndFrameTreeLocked,
    * the frame tree may start changing again.
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -71,16 +71,17 @@
 // GetTickCount().
 #ifdef GetCurrentTime
 #undef GetCurrentTime
 #endif
 
 using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::dom;
+using namespace mozilla::image;
 using namespace mozilla::layout;
 using namespace mozilla::gfx;
 
 typedef FrameMetrics::ViewID ViewID;
 
 #ifdef DEBUG
 static bool
 SpammyLayoutWarningsEnabled()
@@ -1967,30 +1968,16 @@ nsDisplayItem::nsDisplayItem(nsDisplayLi
   NS_ASSERTION(aBuilder->GetDirtyRect().width >= 0 ||
                !aBuilder->IsForPainting(), "dirty rect not set");
   // The dirty rect is for mCurrentFrame, so we have to use
   // mCurrentOffsetToReferenceFrame
   mVisibleRect = aBuilder->GetDirtyRect() +
       aBuilder->GetCurrentFrameOffsetToReferenceFrame();
 }
 
-void
-nsDisplayItem::AddInvalidRegionForSyncDecodeBackgroundImages(
-  nsDisplayListBuilder* aBuilder,
-  const nsDisplayItemGeometry* aGeometry,
-  nsRegion* aInvalidRegion)
-{
-  if (aBuilder->ShouldSyncDecodeImages()) {
-    if (!nsCSSRendering::AreAllBackgroundImagesDecodedForFrame(mFrame)) {
-      bool snap;
-      aInvalidRegion->Or(*aInvalidRegion, GetBounds(aBuilder, &snap));
-    }
-  }
-}
-
 /* static */ bool
 nsDisplayItem::ForceActiveLayers()
 {
   static bool sForce = false;
   static bool sForceCached = false;
 
   if (!sForceCached) {
     Preferences::AddBoolVarCache(&sForce, "layers.force-active", false);
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -1141,26 +1141,16 @@ public:
         aInvalidRegion->Or(aGeometry->mBounds, bounds);
       } else {
         aInvalidRegion->Xor(aGeometry->mBounds, bounds);
       }
     }
   }
 
   /**
-   * For display items types that just draw a background we use this function
-   * to do any invalidation that might be needed if we are asked to sync decode
-   * images.
-   */
-  void AddInvalidRegionForSyncDecodeBackgroundImages(
-    nsDisplayListBuilder* aBuilder,
-    const nsDisplayItemGeometry* aGeometry,
-    nsRegion* aInvalidRegion);
-
-  /**
    * Called when the area rendered by this display item has changed (been
    * invalidated or changed geometry) since the last paint. This includes
    * when the display item was not rendered at all in the last paint.
    * It does NOT get called when a display item was being rendered and no
    * longer is, because generally that means there is no display item to
    * call this method on.
    */
   virtual void NotifyRenderingChanged() {}