Bug 1084136 (Part 9) - Don't track whether we've ever been decoded separately. r=tn

--HG--
extra : rebase_source : 6a6708f9b6524b152204fccf96922e17eccbd6b3
This commit is contained in:
Seth Fowler 2014-11-06 17:34:00 -08:00
parent c26f9ade1c
commit efe9a7ae68
2 changed files with 7 additions and 20 deletions

View File

@ -145,8 +145,7 @@ private:
imgStatusTracker::imgStatusTracker(Image* aImage)
: mImage(aImage),
mState(0),
mImageStatus(imgIRequest::STATUS_NONE),
mHasBeenDecoded(false)
mImageStatus(imgIRequest::STATUS_NONE)
{
mTrackerObserver = new imgStatusTrackerObserver(this);
}
@ -155,8 +154,7 @@ imgStatusTracker::imgStatusTracker(Image* aImage)
imgStatusTracker::imgStatusTracker(const imgStatusTracker& aOther)
: mImage(aOther.mImage),
mState(aOther.mState),
mImageStatus(aOther.mImageStatus),
mHasBeenDecoded(aOther.mHasBeenDecoded)
mImageStatus(aOther.mImageStatus)
// Note: we explicitly don't copy several fields:
// - mRequestRunnable, because it won't be nulled out when the
// mRequestRunnable's Run function eventually gets called.
@ -424,15 +422,13 @@ imgStatusTracker::Difference(imgStatusTracker* aOther) const
diff.diffState = ~mState & aOther->mState & ~FLAG_REQUEST_STARTED;
diff.diffImageStatus = ~mImageStatus & aOther->mImageStatus;
diff.gotDecoded = !mHasBeenDecoded && aOther->mHasBeenDecoded;
// Only record partial invalidations if we haven't been decoded before.
// When images are re-decoded after discarding, we don't want to display
// partially decoded versions to the user.
const uint32_t combinedStatus = mImageStatus | aOther->mImageStatus;
const bool doInvalidations = !(mHasBeenDecoded || aOther->mHasBeenDecoded)
|| combinedStatus & imgIRequest::STATUS_ERROR
|| combinedStatus & imgIRequest::STATUS_DECODE_COMPLETE;
const bool doInvalidations = !(mImageStatus & imgIRequest::STATUS_DECODE_COMPLETE)
|| aOther->mImageStatus & imgIRequest::STATUS_DECODE_COMPLETE
|| combinedStatus & imgIRequest::STATUS_ERROR;
// Record and reset the invalid rectangle.
// XXX(seth): We shouldn't be resetting anything here; see bug 910441.
@ -467,8 +463,6 @@ imgStatusTracker::ApplyDifference(const ImageStatusDiff& aDiff)
// Synchronize our state.
mState |= aDiff.diffState | loadState;
mHasBeenDecoded = mHasBeenDecoded || aDiff.gotDecoded;
// Update the image status. There are some subtle points which are handled below.
mImageStatus |= aDiff.diffImageStatus;
}
@ -687,9 +681,7 @@ imgStatusTracker::RecordStopDecode(nsresult aStatus)
mState |= FLAG_DECODE_STOPPED;
mImageStatus |= imgIRequest::STATUS_DECODE_COMPLETE;
if (NS_SUCCEEDED(aStatus) && !(mImageStatus & imgIRequest::STATUS_ERROR)) {
mHasBeenDecoded = true;
} else {
if (NS_FAILED(aStatus)) {
mImageStatus |= imgIRequest::STATUS_ERROR;
}
}

View File

@ -48,7 +48,6 @@ struct ImageStatusDiff
: invalidRect()
, diffState(0)
, diffImageStatus(0)
, gotDecoded(false)
{ }
static ImageStatusDiff NoChange() { return ImageStatusDiff(); }
@ -58,21 +57,18 @@ struct ImageStatusDiff
bool operator==(const ImageStatusDiff& aOther) const {
return aOther.invalidRect == invalidRect
&& aOther.diffState == diffState
&& aOther.diffImageStatus == diffImageStatus
&& aOther.gotDecoded == gotDecoded;
&& aOther.diffImageStatus == diffImageStatus;
}
void Combine(const ImageStatusDiff& aOther) {
invalidRect = invalidRect.Union(aOther.invalidRect);
diffState |= aOther.diffState;
diffImageStatus |= aOther.diffImageStatus;
gotDecoded = gotDecoded || aOther.gotDecoded;
}
nsIntRect invalidRect;
uint32_t diffState;
uint32_t diffImageStatus;
bool gotDecoded : 1;
};
} // namespace image
@ -311,7 +307,6 @@ private:
uint32_t mState;
uint32_t mImageStatus;
bool mHasBeenDecoded : 1;
};
class imgStatusTrackerInit