Bug 831269 - Enable sync decoding when image is not ready to paint, r=seth draft
authorpeter chang <pchang@mozilla.com>
Mon, 05 Sep 2016 16:50:16 +0800
changeset 409829 fe16dafa60280fd69e5b3f99b37dd686ae88b91f
parent 409737 dbe4b47941c7b3d6298a0ead5e40dd828096c808
child 530428 715542ca40f25e62451a159258618000caf05aac
push id28564
push userbmo:howareyou322@gmail.com
push dateMon, 05 Sep 2016 08:53:33 +0000
reviewersseth
bugs831269
milestone51.0a1
Bug 831269 - Enable sync decoding when image is not ready to paint, r=seth MozReview-Commit-ID: 87XBXbDuCQF
layout/generic/nsImageFrame.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1523,16 +1523,24 @@ nsDisplayImage::Paint(nsDisplayListBuild
       result == DrawResult::INCOMPLETE ||
       result == DrawResult::TEMPORARY_ERROR) {
     // If the current image failed to paint because it's still loading or
     // decoding, try painting the previous image.
     if (mPrevImage) {
       result = static_cast<nsImageFrame*>(mFrame)->
         PaintImage(*aCtx, ToReferenceFrame(), mVisibleRect, mPrevImage, flags);
     }
+
+    // Enable sync decoding when current image failed to paint because
+    // it's still decoding and previous image is not available
+    if (!mPrevImage && result == DrawResult::NOT_READY) {
+      flags |= imgIContainer::FLAG_SYNC_DECODE;
+      DrawResult result = static_cast<nsImageFrame*>(mFrame)->
+        PaintImage(*aCtx, ToReferenceFrame(), mVisibleRect, mImage, flags);
+    }
   }
 
   nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result);
 }
 
 nsDisplayItemGeometry*
 nsDisplayImage::AllocateGeometry(nsDisplayListBuilder* aBuilder)
 {