Bug 1258741 - Part 1. Remove dead/unused image decoder aborted flag. r=tnikkel
authorAndrew Osmond <aosmond@mozilla.com>
Wed, 21 Sep 2016 07:13:08 -0400
changeset 318641 5238fbaf49fa56ffa84a83dfa9cc92e9818671a4
parent 318640 7362a3b3d23989a2ced1ffd112a66ec300c77e40
child 318642 d56e9b123ed63993592c477540b64ec24a18002b
push id20725
push userphilringnalda@gmail.com
push dateThu, 20 Oct 2016 01:36:01 +0000
treeherderfx-team@998ad5a74da8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1258741
milestone52.0a1
Bug 1258741 - Part 1. Remove dead/unused image decoder aborted flag. r=tnikkel
image/Decoder.cpp
image/Decoder.h
image/RasterImage.cpp
image/decoders/nsICODecoder.cpp
image/test/gtest/TestDecoders.cpp
--- a/image/Decoder.cpp
+++ b/image/Decoder.cpp
@@ -58,17 +58,16 @@ Decoder::Decoder(RasterImage* aImage)
   , mInitialized(false)
   , mMetadataDecode(false)
   , mHaveExplicitOutputSize(false)
   , mInFrame(false)
   , mFinishedNewFrame(false)
   , mReachedTerminalState(false)
   , mDecodeDone(false)
   , mError(false)
-  , mDecodeAborted(false)
   , mShouldReportError(false)
 { }
 
 Decoder::~Decoder()
 {
   MOZ_ASSERT(mProgress == NoProgress || !mImage,
              "Destroying Decoder without taking all its progress changes");
   MOZ_ASSERT(mInvalidRect.IsEmpty() || !mImage,
@@ -196,21 +195,19 @@ Decoder::CompleteDecode()
     PostError();
   }
 
   // If the implementation left us mid-frame, finish that up.
   if (mInFrame && !HasError()) {
     PostFrameStop();
   }
 
-  // If PostDecodeDone() has not been called, and this decoder wasn't aborted
-  // early because of low-memory conditions or losing a race with another
-  // decoder, we need to send teardown notifications (and report an error to the
-  // console later).
-  if (!IsMetadataDecode() && !mDecodeDone && !WasAborted()) {
+  // If PostDecodeDone() has not been called, we need to send teardown
+  // notifications (and report an error to the console later).
+  if (!mDecodeDone && !IsMetadataDecode()) {
     mShouldReportError = true;
 
     // Even if we encountered an error, we're still usable if we have at least
     // one complete frame.
     if (GetCompleteFrameCount() > 0) {
       // We're usable, so do exactly what we should have when the decoder
       // completed.
 
@@ -218,20 +215,17 @@ Decoder::CompleteDecode()
       PostHasTransparency();
 
       if (mInFrame) {
         PostFrameStop();
       }
       PostDecodeDone();
     } else {
       // We're not usable. Record some final progress indicating the error.
-      if (!IsMetadataDecode()) {
-        mProgress |= FLAG_DECODE_COMPLETE;
-      }
-      mProgress |= FLAG_HAS_ERROR;
+      mProgress |= FLAG_DECODE_COMPLETE | FLAG_HAS_ERROR;
     }
   }
 
   if (mDecodeDone && !IsMetadataDecode()) {
     MOZ_ASSERT(HasError() || mCurrentFrame, "Should have an error or a frame");
 
     // If this image wasn't animated and isn't a transient image, mark its frame
     // as optimizable. We don't support optimizing animated images and
@@ -266,17 +260,16 @@ Decoder::TakeCompleteFrameCount()
   return finishedNewFrame ? Some(GetCompleteFrameCount()) : Nothing();
 }
 
 DecoderFinalStatus
 Decoder::FinalStatus() const
 {
   return DecoderFinalStatus(IsMetadataDecode(),
                             GetDecodeDone(),
-                            WasAborted(),
                             HasError(),
                             ShouldReportError());
 }
 
 DecoderTelemetry
 Decoder::Telemetry() const
 {
   MOZ_ASSERT(mIterator);
--- a/image/Decoder.h
+++ b/image/Decoder.h
@@ -27,37 +27,30 @@ namespace Telemetry {
 } // namespace Telemetry
 
 namespace image {
 
 struct DecoderFinalStatus final
 {
   DecoderFinalStatus(bool aWasMetadataDecode,
                      bool aFinished,
-                     bool aWasAborted,
                      bool aHadError,
                      bool aShouldReportError)
     : mWasMetadataDecode(aWasMetadataDecode)
     , mFinished(aFinished)
-    , mWasAborted(aWasAborted)
     , mHadError(aHadError)
     , mShouldReportError(aShouldReportError)
   { }
 
   /// True if this was a metadata decode.
   const bool mWasMetadataDecode : 1;
 
   /// True if this decoder finished, whether successfully or due to failure.
   const bool mFinished : 1;
 
-  /// True if this decoder was asynchronously aborted. This normally happens
-  /// when a decoder fails to insert a surface into the surface cache, indicating
-  /// that another decoding beat it to the punch.
-  const bool mWasAborted : 1;
-
   /// True if this decoder encountered an error.
   const bool mHadError : 1;
 
   /// True if this decoder encountered the kind of error that should be reported
   /// to the console.
   const bool mShouldReportError : 1;
 };
 
@@ -282,27 +275,16 @@ public:
   {
     return mReachedTerminalState || mDecodeDone ||
            (mMetadataDecode && HasSize()) || HasError();
   }
 
   /// Are we in the middle of a frame right now? Used for assertions only.
   bool InFrame() const { return mInFrame; }
 
-  /**
-   * Returns true if this decoder was aborted.
-   *
-   * This may happen due to a low-memory condition, or because another decoder
-   * was racing with this one to decode the same frames with the same flags and
-   * this decoder lost the race. Either way, this is not a permanent situation
-   * and does not constitute an error, so we don't report any errors when this
-   * happens.
-   */
-  bool WasAborted() const { return mDecodeAborted; }
-
   enum DecodeStyle {
       PROGRESSIVE, // produce intermediate frames representing the partial
                    // state of the image
       SEQUENTIAL   // decode to final image immediately
   };
 
   /**
    * Get or set the DecoderFlags that influence the behavior of this decoder.
@@ -566,16 +548,15 @@ private:
   bool mMetadataDecode : 1;
   bool mHaveExplicitOutputSize : 1;
   bool mInFrame : 1;
   bool mFinishedNewFrame : 1;  // True if PostFrameStop() has been called since
                                // the last call to TakeCompleteFrameCount().
   bool mReachedTerminalState : 1;
   bool mDecodeDone : 1;
   bool mError : 1;
-  bool mDecodeAborted : 1;
   bool mShouldReportError : 1;
 };
 
 } // namespace image
 } // namespace mozilla
 
 #endif // mozilla_image_Decoder_h
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1578,17 +1578,17 @@ RasterImage::NotifyDecodeComplete(const 
                                   const IntRect& aInvalidRect,
                                   const Maybe<uint32_t>& aFrameCount,
                                   DecoderFlags aDecoderFlags,
                                   SurfaceFlags aSurfaceFlags)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // If the decoder detected an error, log it to the error console.
-  if (aStatus.mShouldReportError && !aStatus.mWasAborted) {
+  if (aStatus.mShouldReportError) {
     ReportDecoderError();
   }
 
   // Record all the metadata the decoder gathered about this image.
   bool metadataOK = SetMetadata(aMetadata, aStatus.mWasMetadataDecode);
   if (!metadataOK) {
     // This indicates a serious error that requires us to discard all existing
     // surfaces and redecode to recover. We'll drop the results from this
@@ -1596,17 +1596,17 @@ RasterImage::NotifyDecodeComplete(const 
     RecoverFromInvalidFrames(mSize,
                              FromSurfaceFlags(aSurfaceFlags));
     return;
   }
 
   MOZ_ASSERT(mError || mHasSize || !aMetadata.HasSize(),
              "SetMetadata should've gotten a size");
 
-  if (!aStatus.mWasMetadataDecode && aStatus.mFinished && !aStatus.mWasAborted) {
+  if (!aStatus.mWasMetadataDecode && aStatus.mFinished) {
     // Flag that we've been decoded before.
     mHasBeenDecoded = true;
   }
 
   // Send out any final notifications.
   NotifyProgress(aProgress, aInvalidRect, aFrameCount,
                  aDecoderFlags, aSurfaceFlags);
 
@@ -1628,17 +1628,17 @@ RasterImage::NotifyDecodeComplete(const 
                             int32_t(aTelemetry.mDecodeTime.ToMicroseconds()));
 
       if (aTelemetry.mSpeedHistogram) {
         Telemetry::Accumulate(*aTelemetry.mSpeedHistogram, aTelemetry.Speed());
       }
     }
 
     // Detect errors.
-    if (aStatus.mHadError && !aStatus.mWasAborted) {
+    if (aStatus.mHadError) {
       DoError();
     } else if (aStatus.mWasMetadataDecode && !mHasSize) {
       DoError();
     }
 
     // If we were waiting to fire the load event, go ahead and fire it now.
     if (mLoadProgress && aStatus.mWasMetadataDecode) {
       NotifyForLoadEvent(*mLoadProgress);
--- a/image/decoders/nsICODecoder.cpp
+++ b/image/decoders/nsICODecoder.cpp
@@ -95,17 +95,16 @@ nsICODecoder::GetFinalStateFromContained
   // Let the contained decoder finish up if necessary.
   if (!mContainedSourceBuffer->IsComplete()) {
     mContainedSourceBuffer->Complete(NS_OK);
     mContainedDecoder->Decode();
   }
 
   // Make our state the same as the state of the contained decoder.
   mDecodeDone = mContainedDecoder->GetDecodeDone();
-  mDecodeAborted = mContainedDecoder->WasAborted();
   mProgress |= mContainedDecoder->TakeProgress();
   mInvalidRect.UnionRect(mInvalidRect, mContainedDecoder->TakeInvalidRect());
   mCurrentFrame = mContainedDecoder->GetCurrentFrameRef();
 
   // Propagate errors.
   nsresult rv = HasError() || mContainedDecoder->HasError()
               ? NS_ERROR_FAILURE
               : NS_OK;
--- a/image/test/gtest/TestDecoders.cpp
+++ b/image/test/gtest/TestDecoders.cpp
@@ -30,17 +30,16 @@ using namespace mozilla::gfx;
 using namespace mozilla::image;
 
 static already_AddRefed<SourceSurface>
 CheckDecoderState(const ImageTestCase& aTestCase, Decoder* aDecoder)
 {
   EXPECT_TRUE(aDecoder->GetDecodeDone());
   EXPECT_EQ(bool(aTestCase.mFlags & TEST_CASE_HAS_ERROR),
             aDecoder->HasError());
-  EXPECT_TRUE(!aDecoder->WasAborted());
 
   // Verify that the decoder made the expected progress.
   Progress progress = aDecoder->TakeProgress();
   EXPECT_EQ(bool(aTestCase.mFlags & TEST_CASE_HAS_ERROR),
             bool(progress & FLAG_HAS_ERROR));
 
   if (aTestCase.mFlags & TEST_CASE_HAS_ERROR) {
     return nullptr;  // That's all we can check for bad images.