Bug 1194059 (Part 2c) - Stop locking images during their initial decode, since it's not necessary anymore. r=tn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Thu, 13 Aug 2015 20:28:04 -0700
changeset 528636 2bb149b1a0e2e0ca6d5faf6971606bbbfda1cb96
parent 528635 bfecc2d5de00471248ca6873e25e4e6506e524bc
child 528637 c06fc98ed11bc26aa8def24ccb51564832d1a2f5
push id83259
push usermfowler@mozilla.com
push dateFri, 14 Aug 2015 03:29:25 +0000
treeherdertry@c99a979de0c1 [default view] [failures only]
reviewerstn
bugs1194059
milestone43.0a1
Bug 1194059 (Part 2c) - Stop locking images during their initial decode, since it's not necessary anymore. r=tn
image/Decoder.cpp
image/Decoder.h
image/RasterImage.cpp
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -32,17 +32,16 @@ Decoder::Decoder(RasterImage* aImage)
   , mFailCode(NS_OK)
   , mChunkCount(0)
   , mFlags(0)
   , mBytesDecoded(0)
   , mInitialized(false)
   , mMetadataDecode(false)
   , mSendPartialInvalidations(false)
   , mImageIsTransient(false)
-  , mImageIsLocked(false)
   , mFirstFrameDecode(false)
   , mInFrame(false)
   , mDataDone(false)
   , mDecodeDone(false)
   , mDataError(false)
   , mDecodeAborted(false)
   , mShouldReportError(false)
 { }
--- a/image/Decoder.h
+++ b/image/Decoder.h
@@ -177,30 +177,16 @@ public:
    */
   void SetImageIsTransient(bool aIsTransient)
   {
     MOZ_ASSERT(!mInitialized, "Shouldn't be initialized yet");
     mImageIsTransient = aIsTransient;
   }
 
   /**
-   * Set whether the image is locked for the lifetime of this decoder. We lock
-   * the image during our initial decode to ensure that we don't evict any
-   * surfaces before we realize that the image is animated.
-   */
-  void SetImageIsLocked()
-  {
-    MOZ_ASSERT(!mInitialized, "Shouldn't be initialized yet");
-    mImageIsLocked = true;
-  }
-
-  bool ImageIsLocked() const { return mImageIsLocked; }
-
-
-  /**
    * Set whether we should stop decoding after the first frame.
    */
   void SetIsFirstFrameDecode()
   {
     MOZ_ASSERT(!mInitialized, "Shouldn't be initialized yet");
     mFirstFrameDecode = true;
   }
 
@@ -446,17 +432,16 @@ private:
 
   uint32_t mFlags;
   size_t mBytesDecoded;
 
   bool mInitialized : 1;
   bool mMetadataDecode : 1;
   bool mSendPartialInvalidations : 1;
   bool mImageIsTransient : 1;
-  bool mImageIsLocked : 1;
   bool mFirstFrameDecode : 1;
   bool mInFrame : 1;
   bool mDataDone : 1;
   bool mDecodeDone : 1;
   bool mDataError : 1;
   bool mDecodeAborted : 1;
   bool mShouldReportError : 1;
 };
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1413,25 +1413,16 @@ RasterImage::Decode(const IntSize& aSize
   }
 
   MOZ_ASSERT(mDownscaleDuringDecode || aSize == mSize,
              "Can only decode to our intrinsic size if we're not allowed to "
              "downscale-during-decode");
 
   Maybe<IntSize> targetSize = mSize != aSize ? Some(aSize) : Nothing();
 
-  bool imageIsLocked = false;
-  if (!mHasBeenDecoded) {
-    // Lock the image while we're decoding, so that it doesn't get evicted from
-    // the SurfaceCache before we have a chance to realize that it's animated.
-    // The corresponding unlock happens in FinalizeDecoder.
-    LockImage();
-    imageIsLocked = true;
-  }
-
   // Create a decoder.
   nsRefPtr<Decoder> decoder =
     DecoderFactory::CreateDecoder(mDecoderType, this, mSourceBuffer, targetSize,
                                   aFlags, mRequestedSampleSize, mRequestedResolution,
                                   mHasBeenDecoded, mTransient, imageIsLocked);
 
   // Make sure DecoderFactory was able to create a decoder successfully.
   if (!decoder) {
@@ -2045,21 +2036,16 @@ RasterImage::FinalizeDecoder(Decoder* aD
     // If we were waiting to fire the load event, go ahead and fire it now.
     if (mLoadProgress && wasMetadata) {
       NotifyForLoadEvent(*mLoadProgress);
       mLoadProgress = Nothing();
       NotifyProgress(FLAG_ONLOAD_UNBLOCKED);
     }
   }
 
-  if (aDecoder->ImageIsLocked()) {
-    // Unlock the image, balancing the LockImage call we made in CreateDecoder.
-    UnlockImage();
-  }
-
   // If we were a metadata decode and a full decode was requested, do it.
   if (done && wasMetadata && mWantFullDecode) {
     mWantFullDecode = false;
     RequestDecode();
   }
 }
 
 void