Bug 1291071 (Part 2) - Pass decoder progress explicitly to FinalizeDecoder. r=edwin
authorSeth Fowler <mark.seth.fowler@gmail.com>
Tue, 02 Aug 2016 16:32:07 -0700
changeset 308440 801b6b88b490705e4905b2b83346515e2461c5b7
parent 308439 5ce50dc53516af734f52c5eff598e8f171623040
child 308441 9b9a6dca288397b794f31e52c8a21b1262c72d47
push id80341
push userseth.bugzilla@blackhail.net
push dateSat, 06 Aug 2016 01:50:41 +0000
treeherdermozilla-inbound@731d13870f6a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1291071
milestone51.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 1291071 (Part 2) - Pass decoder progress explicitly to FinalizeDecoder. r=edwin
image/IDecodingTask.cpp
image/RasterImage.cpp
image/RasterImage.h
--- a/image/IDecodingTask.cpp
+++ b/image/IDecodingTask.cpp
@@ -60,29 +60,35 @@ IDecodingTask::NotifyProgress(NotNull<Ra
 IDecodingTask::NotifyDecodeComplete(NotNull<RasterImage*> aImage,
                                     NotNull<Decoder*> aDecoder)
 {
   MOZ_ASSERT(aDecoder->HasError() || !aDecoder->InFrame(),
              "Decode complete in the middle of a frame?");
 
   // Capture the decoder's state.
   ImageMetadata metadata = aDecoder->GetImageMetadata();
+  Progress progress = aDecoder->TakeProgress();
+  IntRect invalidRect = aDecoder->TakeInvalidRect();
+  Maybe<uint32_t> frameCount = aDecoder->TakeCompleteFrameCount();
+  SurfaceFlags surfaceFlags = aDecoder->GetSurfaceFlags();
 
   // Synchronously notify if we can.
   if (NS_IsMainThread() &&
       !(aDecoder->GetDecoderFlags() & DecoderFlags::ASYNC_NOTIFY)) {
-    aImage->FinalizeDecoder(aDecoder, metadata);
+    aImage->FinalizeDecoder(aDecoder, metadata, progress, invalidRect,
+                            frameCount, surfaceFlags);
     return;
   }
 
   // We're forced to notify asynchronously.
   NotNull<RefPtr<RasterImage>> image = aImage;
   NotNull<RefPtr<Decoder>> decoder = aDecoder;
   NS_DispatchToMainThread(NS_NewRunnableFunction([=]() -> void {
-    image->FinalizeDecoder(decoder.get(), metadata);
+    image->FinalizeDecoder(decoder.get(), metadata, progress, invalidRect,
+                           frameCount, surfaceFlags);
   }));
 }
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // IDecodingTask implementation.
 ///////////////////////////////////////////////////////////////////////////////
 
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1558,17 +1558,21 @@ RasterImage::NotifyProgress(Progress aPr
   }
 
   // Tell the observers what happened.
   image->mProgressTracker->SyncNotifyProgress(aProgress, aInvalidRect);
 }
 
 void
 RasterImage::FinalizeDecoder(Decoder* aDecoder,
-                             const ImageMetadata& aMetadata)
+                             const ImageMetadata& aMetadata,
+                             Progress aProgress,
+                             const IntRect& aInvalidRect,
+                             const Maybe<uint32_t>& aFrameCount,
+                             SurfaceFlags aSurfaceFlags)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aDecoder);
 
   bool wasMetadata = aDecoder->IsMetadataDecode();
   bool done = aDecoder->GetDecodeDone();
 
   // If the decoder detected an error, log it to the error console.
@@ -1577,36 +1581,31 @@ RasterImage::FinalizeDecoder(Decoder* aD
   }
 
   // Record all the metadata the decoder gathered about this image.
   bool metadataOK = SetMetadata(aMetadata, wasMetadata);
   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
     // decoder on the floor, since they aren't valid.
-    aDecoder->TakeProgress();
-    aDecoder->TakeInvalidRect();
     RecoverFromInvalidFrames(mSize,
-                             FromSurfaceFlags(aDecoder->GetSurfaceFlags()));
+                             FromSurfaceFlags(aSurfaceFlags));
     return;
   }
 
   MOZ_ASSERT(mError || mHasSize || !aMetadata.HasSize(),
              "SetMetadata should've gotten a size");
 
   if (!wasMetadata && aDecoder->GetDecodeDone() && !aDecoder->WasAborted()) {
     // Flag that we've been decoded before.
     mHasBeenDecoded = true;
   }
 
   // Send out any final notifications.
-  NotifyProgress(aDecoder->TakeProgress(),
-                 aDecoder->TakeInvalidRect(),
-                 aDecoder->TakeCompleteFrameCount(),
-                 aDecoder->GetSurfaceFlags());
+  NotifyProgress(aProgress, aInvalidRect, aFrameCount, aSurfaceFlags);
 
   if (mHasBeenDecoded && mAnimationState) {
     // We're done decoding and our AnimationState has been notified about all
     // our frames, so let it know not to expect anymore.
     mAnimationState->SetDoneDecoding(true);
   }
 
   if (!wasMetadata && aDecoder->ChunkCount()) {
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -197,17 +197,21 @@ public:
                       SurfaceFlags aSurfaceFlags = DefaultSurfaceFlags());
 
   /**
    * Records telemetry and does final teardown of the provided decoder.
    *
    * Main-thread only.
    */
   void FinalizeDecoder(Decoder* aDecoder,
-                       const ImageMetadata& aMetadata);
+                       const ImageMetadata& aMetadata,
+                       Progress aProgress,
+                       const gfx::IntRect& aInvalidRect,
+                       const Maybe<uint32_t>& aFrameCount,
+                       SurfaceFlags aSurfaceFlags);
 
   // Helper method for FinalizeDecoder.
   void ReportDecoderError(Decoder* aDecoder);
 
 
   //////////////////////////////////////////////////////////////////////////////
   // Network callbacks.
   //////////////////////////////////////////////////////////////////////////////