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
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
--- 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.