Bug 1207355 (Part 5) - Request decodes intelligently in MultipartImage. r=tn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Thu, 29 Oct 2015 16:37:42 -0700
changeset 270366 0c3e7157e07f4fd0122b0a0a3636f410ddc6bd73
parent 270365 884aa587c3a80938c9997ca413104143e85acf3f
child 270367 f3635689afc1a8b96f94571d4593e01a80c39274
push id29612
push userkwierso@gmail.com
push dateFri, 30 Oct 2015 23:36:00 +0000
treeherdermozilla-central@1596ab6985cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1207355
milestone45.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 1207355 (Part 5) - Request decodes intelligently in MultipartImage. r=tn
image/MultipartImage.cpp
--- a/image/MultipartImage.cpp
+++ b/image/MultipartImage.cpp
@@ -65,16 +65,26 @@ public:
 
   virtual void OnLoadComplete(bool aLastPart) override
   {
     if (!mImage) {
       // We've already finished observing the last image we were given.
       return;
     }
 
+    // Retrieve the image's intrinsic size.
+    int32_t width = 0;
+    int32_t height = 0;
+    mImage->GetWidth(&width);
+    mImage->GetHeight(&height);
+
+    // Request decoding at the intrinsic size.
+    mImage->RequestDecodeForSize(IntSize(width, height),
+                                 imgIContainer::DECODE_FLAGS_DEFAULT);
+
     // If there's already an error, we may never get a FRAME_COMPLETE
     // notification, so go ahead and notify our owner right away.
     RefPtr<ProgressTracker> tracker = mImage->GetProgressTracker();
     if (tracker->GetProgress() & FLAG_HAS_ERROR) {
       FinishObserving();
     }
   }
 
@@ -120,17 +130,16 @@ MultipartImage::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mTracker, "Should've called SetProgressTracker() by now");
 
   // Start observing the first part.
   RefPtr<ProgressTracker> firstPartTracker =
     InnerImage()->GetProgressTracker();
   firstPartTracker->AddObserver(this);
-  InnerImage()->RequestDecode();
   InnerImage()->IncrementAnimationConsumers();
 }
 
 MultipartImage::~MultipartImage()
 {
   // Ask our ProgressTracker to drop its weak reference to us.
   mTracker->ResetImage();
 }
@@ -149,17 +158,16 @@ MultipartImage::BeginTransitionToPart(Im
     MOZ_ASSERT(!mNextPart);
   }
 
   mNextPart = aNextPart;
 
   // Start observing the next part; we'll complete the transition when
   // NextPartObserver calls FinishTransition.
   mNextPartObserver->BeginObserving(mNextPart);
-  mNextPart->RequestDecode();
   mNextPart->IncrementAnimationConsumers();
 }
 
 static Progress
 FilterProgress(Progress aProgress)
 {
   // Filter out onload blocking notifications, since we don't want to block
   // onload for multipart images.