Bug 1317562. Allow flags to be passed to StartDecoding for the sole purpose of allowing async notifications to be requested. r=aosmond
authorTimothy Nikkel <tnikkel@gmail.com>
Sat, 26 Nov 2016 01:56:26 -0600
changeset 324301 072d40d19b1fe3e521eab399429114a9f28fb19e
parent 324300 95a822efc877b26b46b348aa334fd482377267ab
child 324302 0ed01739297a91281878a5ce1a4f8c0329b0d0da
push id84363
push usertnikkel@gmail.com
push dateSat, 26 Nov 2016 07:56:46 +0000
treeherdermozilla-inbound@0ed01739297a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond
bugs1317562
milestone53.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 1317562. Allow flags to be passed to StartDecoding for the sole purpose of allowing async notifications to be requested. r=aosmond
dom/svg/SVGFEImageElement.cpp
image/DynamicImage.cpp
image/ImageWrapper.cpp
image/RasterImage.cpp
image/VectorImage.cpp
image/imgIContainer.idl
image/imgIRequest.idl
image/imgRequest.cpp
image/imgRequestProxy.cpp
layout/style/nsStyleStruct.cpp
layout/xul/nsImageBoxFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
--- a/dom/svg/SVGFEImageElement.cpp
+++ b/dom/svg/SVGFEImageElement.cpp
@@ -346,17 +346,17 @@ SVGFEImageElement::Notify(imgIRequest* a
 {
   nsresult rv = nsImageLoadingContent::Notify(aRequest, aType, aData);
 
   if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
     // Request a decode
     nsCOMPtr<imgIContainer> container;
     aRequest->GetImage(getter_AddRefs(container));
     MOZ_ASSERT(container, "who sent the notification then?");
-    container->StartDecoding();
+    container->StartDecoding(imgIContainer::FLAG_NONE);
   }
 
   if (aType == imgINotificationObserver::LOAD_COMPLETE ||
       aType == imgINotificationObserver::FRAME_UPDATE ||
       aType == imgINotificationObserver::SIZE_AVAILABLE) {
     Invalidate();
   }
 
--- a/image/DynamicImage.cpp
+++ b/image/DynamicImage.cpp
@@ -241,17 +241,17 @@ DynamicImage::Draw(gfxContext* aContext,
   aContext->Multiply(gfxMatrix::Scaling(scale.width, scale.height));
 
   gfxUtils::DrawPixelSnapped(aContext, mDrawable, drawableSize, region,
                              SurfaceFormat::B8G8R8A8, aSamplingFilter);
   return DrawResult::SUCCESS;
 }
 
 NS_IMETHODIMP
-DynamicImage::StartDecoding()
+DynamicImage::StartDecoding(uint32_t aFlags)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DynamicImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
 {
   return NS_OK;
--- a/image/ImageWrapper.cpp
+++ b/image/ImageWrapper.cpp
@@ -211,19 +211,19 @@ ImageWrapper::Draw(gfxContext* aContext,
                    const Maybe<SVGImageContext>& aSVGContext,
                    uint32_t aFlags)
 {
   return mInnerImage->Draw(aContext, aSize, aRegion, aWhichFrame,
                            aSamplingFilter, aSVGContext, aFlags);
 }
 
 NS_IMETHODIMP
-ImageWrapper::StartDecoding()
+ImageWrapper::StartDecoding(uint32_t aFlags)
 {
-  return mInnerImage->StartDecoding();
+  return mInnerImage->StartDecoding(aFlags);
 }
 
 NS_IMETHODIMP
 ImageWrapper::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
 {
   return mInnerImage->RequestDecodeForSize(aSize, aFlags);
 }
 
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1030,28 +1030,29 @@ RasterImage::Discard()
 
 bool
 RasterImage::CanDiscard() {
   return mHasSourceData &&       // ...have the source data...
          !mAnimationState;       // Can never discard animated images
 }
 
 NS_IMETHODIMP
-RasterImage::StartDecoding()
+RasterImage::StartDecoding(uint32_t aFlags)
 {
   if (mError) {
     return NS_ERROR_FAILURE;
   }
 
   if (!mHasSize) {
     mWantFullDecode = true;
     return NS_OK;
   }
 
-  return RequestDecodeForSize(mSize, FLAG_SYNC_DECODE_IF_FAST);
+  uint32_t flags = (aFlags & FLAG_ASYNC_NOTIFY) | FLAG_SYNC_DECODE_IF_FAST;
+  return RequestDecodeForSize(mSize, flags);
 }
 
 NS_IMETHODIMP
 RasterImage::RequestDecodeForSize(const IntSize& aSize, uint32_t aFlags)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mError) {
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -1021,17 +1021,17 @@ VectorImage::RecoverFromLossOfSurfaces()
 {
   NS_WARNING("An imgFrame became invalid. Attempting to recover...");
 
   // Discard all existing frames, since they're probably all now invalid.
   SurfaceCache::RemoveImage(ImageKey(this));
 }
 
 NS_IMETHODIMP
-VectorImage::StartDecoding()
+VectorImage::StartDecoding(uint32_t aFlags)
 {
   // Nothing to do for SVG images
   return NS_OK;
 }
 
 NS_IMETHODIMP
 VectorImage::RequestDecodeForSize(const nsIntSize& aSize, uint32_t aFlags)
 {
--- a/image/imgIContainer.idl
+++ b/image/imgIContainer.idl
@@ -409,18 +409,21 @@ interface imgIContainer : nsISupports
        [const] in MaybeSVGImageContext aSVGContext,
        in uint32_t aFlags);
 
   /*
    * Ensures that an image is decoding. Calling this function guarantees that
    * the image will at some point fire off decode notifications. Images that
    * can be decoded "quickly" according to some heuristic will be decoded
    * synchronously.
+   *
+   * @param aFlags Flags of the FLAG_* variety. Only FLAG_ASYNC_NOTIFY
+   *               is accepted; all others are ignored.
    */
-  [noscript] void startDecoding();
+  [noscript] void startDecoding(in uint32_t aFlags);
 
   /*
    * This method triggers decoding for an image, but unlike startDecoding() it
    * enables the caller to provide more detailed information about the decode
    * request.
    *
    * @param aSize The size to which the image should be scaled while decoding,
    *              if possible. If the image cannot be scaled to this size while
--- a/image/imgIRequest.idl
+++ b/image/imgIRequest.idl
@@ -148,17 +148,17 @@ interface imgIRequest : nsIRequest
    * Requests a synchronous decode for the image.
    *
    * imgIContainer has a startDecoding() method, but callers may want to request
    * a decode before the container has necessarily been instantiated. Calling
    * startDecoding() on the imgIRequest simply forwards along the request if the
    * container already exists, or calls it once the container becomes available
    * if it does not yet exist.
    */
-  void startDecoding();
+  void startDecoding(in uint32_t aFlags);
 
   /**
    * Locks an image. If the image does not exist yet, locks it once it becomes
    * available. The lock persists for the lifetime of the imgIRequest (until
    * unlockImage is called) even if the underlying image changes.
    *
    * If you don't call unlockImage() by the time this imgIRequest goes away, it
    * will be called for you automatically.
--- a/image/imgRequest.cpp
+++ b/image/imgRequest.cpp
@@ -1033,17 +1033,17 @@ imgRequest::FinishPreparingForNewPart(co
     MOZ_ASSERT(progressTracker->HasImage());
   }
 
   if (aResult.mShouldResetCacheEntry) {
     ResetCacheEntry();
   }
 
   if (IsDecodeRequested()) {
-    aResult.mImage->StartDecoding();
+    aResult.mImage->StartDecoding(imgIContainer::FLAG_NONE);
   }
 }
 
 NS_IMETHODIMP
 imgRequest::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext,
                             nsIInputStream* aInStr, uint64_t aOffset,
                             uint32_t aCount)
 {
--- a/image/imgRequestProxy.cpp
+++ b/image/imgRequestProxy.cpp
@@ -224,17 +224,17 @@ imgRequestProxy::ChangeOwner(imgRequest*
     IncrementAnimationConsumers();
   }
 
   GetOwner()->AddProxy(this);
 
   // If we'd previously requested a synchronous decode, request a decode on the
   // new image.
   if (mDecodeRequested) {
-    StartDecoding();
+    StartDecoding(imgIContainer::FLAG_NONE);
   }
 
   return NS_OK;
 }
 
 void
 imgRequestProxy::AddToLoadGroup()
 {
@@ -353,24 +353,24 @@ imgRequestProxy::CancelAndForgetObserver
   }
 
   NullOutListener();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-imgRequestProxy::StartDecoding()
+imgRequestProxy::StartDecoding(uint32_t aFlags)
 {
   // Flag this, so we know to transfer the request if our owner changes
   mDecodeRequested = true;
 
   RefPtr<Image> image = GetImage();
   if (image) {
-    return image->StartDecoding();
+    return image->StartDecoding(aFlags);
   }
 
   if (GetOwner()) {
     GetOwner()->StartDecoding();
   }
 
   return NS_OK;
 }
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -2280,17 +2280,17 @@ nsStyleImage::ComputeActualCropRect(nsIn
 nsresult
 nsStyleImage::StartDecoding() const
 {
   if (mType == eStyleImageType_Image) {
     imgRequestProxy* req = GetImageData();
     if (!req) {
       return NS_ERROR_FAILURE;
     }
-    return req->StartDecoding();
+    return req->StartDecoding(imgIContainer::FLAG_NONE);
   }
   return NS_OK;
 }
 
 bool
 nsStyleImage::IsOpaque() const
 {
   if (!IsComplete()) {
--- a/layout/xul/nsImageBoxFrame.cpp
+++ b/layout/xul/nsImageBoxFrame.cpp
@@ -284,17 +284,17 @@ nsImageBoxFrame::UpdateImage()
     }
   }
 
   if (!mImageRequest) {
     // We have no image, so size to 0
     mIntrinsicSize.SizeTo(0, 0);
   } else {
     // We don't want discarding or decode-on-draw for xul images.
-    mImageRequest->StartDecoding();
+    mImageRequest->StartDecoding(imgIContainer::FLAG_NONE);
     mImageRequest->LockImage();
   }
 
   // Do this _after_ locking the new image in case they are the same image.
   if (oldImageRequest) {
     oldImageRequest->UnlockImage();
   }
 }
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -2200,17 +2200,17 @@ nsTreeBodyFrame::GetImage(int32_t aRowIn
       NS_ENSURE_SUCCESS(rv, rv);
     }
     listener->UnsuppressInvalidation();
 
     if (!imageRequest)
       return NS_ERROR_FAILURE;
 
     // We don't want discarding/decode-on-draw for xul images
-    imageRequest->StartDecoding();
+    imageRequest->StartDecoding(imgIContainer::FLAG_NONE);
     imageRequest->LockImage();
 
     // In a case it was already cached.
     imageRequest->GetImage(aResult);
     nsTreeImageCacheEntry cacheEntry(imageRequest, imgNotificationObserver);
     mImageCache.Put(imageSrc, cacheEntry);
   }
   return NS_OK;