Bug 865993. For layerized images GetImageContainer has the same meaning as Draw()'ing the image, and Draw will not be called on the image, so send the unlocked draw notification there too. r=joedrew
authorTimothy Nikkel <tnikkel@gmail.com>
Fri, 26 Apr 2013 14:58:17 -0500
changeset 141056 6255ed636db10e67ced1e6043781e1c5a650b682
parent 141055 e185401101a8ff27c5e9dc1729ec038c070aecda
child 141057 0e45f1b9521f016bea4531379fa5c650c31c35ea
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoedrew
bugs865993
milestone23.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 865993. For layerized images GetImageContainer has the same meaning as Draw()'ing the image, and Draw will not be called on the image, so send the unlocked draw notification there too. r=joedrew
image/src/RasterImage.cpp
image/src/RasterImage.h
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -1100,16 +1100,20 @@ NS_IMETHODIMP
 RasterImage::GetImageContainer(LayerManager* aManager, ImageContainer **_retval)
 {
   int32_t maxTextureSize = aManager->GetMaxTextureSize();
   if (mSize.width > maxTextureSize || mSize.height > maxTextureSize) {
     *_retval = nullptr;
     return NS_OK;
   }
 
+  if (IsUnlocked() && mStatusTracker) {
+    mStatusTracker->OnUnlockedDraw();
+  }
+
   if (mImageContainer) {
     *_retval = mImageContainer;
     NS_ADDREF(*_retval);
     return NS_OK;
   }
 
   nsRefPtr<layers::Image> image = GetCurrentImage();
   if (!image) {
@@ -3131,23 +3135,19 @@ RasterImage::Draw(gfxContext *aContext,
   //
   // (We don't normally draw unlocked images, so this conditition will usually
   // be false.  But we will draw unlocked images if image locking is globally
   // disabled via the content.image.allow_locking pref.)
   if (DiscardingActive()) {
     DiscardTracker::Reset(&mDiscardTrackerNode);
   }
 
-  // We would like to just check if we have a zero lock count, but we can't do
-  // that for animated images because in EnsureAnimExists we lock the image and
-  // never unlock so that animated images always have their lock count >= 1. In
-  // that case we use our animation consumers count as a proxy for lock count.
-  if (mLockCount == 0 || (mAnim && mAnimationConsumers == 0)) {
-    if (mStatusTracker)
-      mStatusTracker->OnUnlockedDraw();
+
+  if (IsUnlocked() && mStatusTracker) {
+    mStatusTracker->OnUnlockedDraw();
   }
 
   // We use !mDecoded && mHasSourceData to mean discarded.
   if (!mDecoded && mHasSourceData) {
     mDrawStartTime = TimeStamp::Now();
   }
 
   // If a synchronous draw is requested, flush anything that might be sitting around
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -711,16 +711,22 @@ private:
   void SetInUpdateImageContainer(bool aInUpdate) { mInUpdateImageContainer = aInUpdate; }
   bool IsInUpdateImageContainer() { return mInUpdateImageContainer; }
   enum RequestDecodeType {
       ASYNCHRONOUS,
       SOMEWHAT_SYNCHRONOUS
   };
   NS_IMETHOD RequestDecodeCore(RequestDecodeType aDecodeType);
 
+  // We would like to just check if we have a zero lock count, but we can't do
+  // that for animated images because in EnsureAnimExists we lock the image and
+  // never unlock so that animated images always have their lock count >= 1. In
+  // that case we use our animation consumers count as a proxy for lock count.
+  bool IsUnlocked() { return (mLockCount == 0 || (mAnim && mAnimationConsumers == 0)); }
+
 private: // data
   nsIntSize                  mSize;
 
   // Whether mFrames below were decoded using any special flags.
   // Some flags (e.g. unpremultiplied data) may not be compatible
   // with the browser's needs for displaying the image to the user.
   // As such, we may need to redecode if we're being asked for
   // a frame with different flags.  0 indicates default flags.