Bug 1149893 - Add a pref that makes us decode all images immediately. r=baku

This commit is contained in:
Seth Fowler 2015-04-07 16:44:29 -07:00
Родитель ad58feb79d
Коммит bbb3ac44cd
5 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -247,6 +247,7 @@ private:
DECL_GFX_PREF(Once, "image.cache.size", ImageCacheSize, int32_t, 5*1024*1024);
DECL_GFX_PREF(Once, "image.cache.timeweight", ImageCacheTimeWeight, int32_t, 500);
DECL_GFX_PREF(Live, "image.decode-only-on-draw.enabled", ImageDecodeOnlyOnDrawEnabled, bool, true);
DECL_GFX_PREF(Live, "image.decode-immediately.enabled", ImageDecodeImmediatelyEnabled, bool, false);
DECL_GFX_PREF(Live, "image.downscale-during-decode.enabled", ImageDownscaleDuringDecodeEnabled, bool, false);
DECL_GFX_PREF(Live, "image.high_quality_downscaling.enabled", ImageHQDownscalingEnabled, bool, false);
DECL_GFX_PREF(Live, "image.high_quality_downscaling.min_factor", ImageHQDownscalingMinFactor, uint32_t, 1000);

Просмотреть файл

@ -47,6 +47,9 @@ public:
* INIT_FLAG_DECODE_ONLY_ON_DRAW: The container should decode on draw rather
* than possibly being speculatively decoded earlier.
*
* INIT_FLAG_DECODE_IMMEDIATELY: The container should decode as soon as
* possible, regardless of what our heuristics say.
*
* INIT_FLAG_TRANSIENT: The container is likely to exist for only a short time
* before being destroyed. (For example, containers for
* multipart/x-mixed-replace image parts fall into this category.) If this
@ -60,8 +63,9 @@ public:
static const uint32_t INIT_FLAG_NONE = 0x0;
static const uint32_t INIT_FLAG_DISCARDABLE = 0x1;
static const uint32_t INIT_FLAG_DECODE_ONLY_ON_DRAW = 0x2;
static const uint32_t INIT_FLAG_TRANSIENT = 0x4;
static const uint32_t INIT_FLAG_DOWNSCALE_DURING_DECODE = 0x8;
static const uint32_t INIT_FLAG_DECODE_IMMEDIATELY = 0x4;
static const uint32_t INIT_FLAG_TRANSIENT = 0x8;
static const uint32_t INIT_FLAG_DOWNSCALE_DURING_DECODE = 0x10;
/**
* Creates a new image container.

Просмотреть файл

@ -48,6 +48,7 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
bool isDiscardable = gfxPrefs::ImageMemDiscardable();
bool doDecodeOnlyOnDraw = gfxPrefs::ImageDecodeOnlyOnDrawEnabled() &&
gfxPrefs::AsyncPanZoomEnabled();
bool doDecodeImmediately = gfxPrefs::ImageDecodeImmediatelyEnabled();
bool doDownscaleDuringDecode = gfxPrefs::ImageDownscaleDuringDecodeEnabled();
// We want UI to be as snappy as possible and not to flicker. Disable
@ -74,6 +75,11 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
doDecodeOnlyOnDraw = false;
}
// If we're decoding immediately, disable decode-only-on-draw.
if (doDecodeImmediately) {
doDecodeOnlyOnDraw = false;
}
// For multipart/x-mixed-replace, we basically want a direct channel to the
// decoder. Disable everything for this case.
if (isMultiPart) {
@ -88,6 +94,9 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
if (doDecodeOnlyOnDraw) {
imageFlags |= Image::INIT_FLAG_DECODE_ONLY_ON_DRAW;
}
if (doDecodeImmediately) {
imageFlags |= Image::INIT_FLAG_DECODE_IMMEDIATELY;
}
if (isMultiPart) {
imageFlags |= Image::INIT_FLAG_TRANSIENT;
}

Просмотреть файл

@ -319,6 +319,7 @@ RasterImage::Init(const char* aMimeType,
mSourceDataMimeType.Assign(aMimeType);
mDiscardable = !!(aFlags & INIT_FLAG_DISCARDABLE);
mDecodeOnlyOnDraw = !!(aFlags & INIT_FLAG_DECODE_ONLY_ON_DRAW);
mWantFullDecode = !!(aFlags & INIT_FLAG_DECODE_IMMEDIATELY);
mTransient = !!(aFlags & INIT_FLAG_TRANSIENT);
mDownscaleDuringDecode = !!(aFlags & INIT_FLAG_DOWNSCALE_DURING_DECODE);

Просмотреть файл

@ -3844,6 +3844,10 @@ pref("image.cache.timeweight", 500);
// them to be decoded on demand when they are drawn.
pref("image.decode-only-on-draw.enabled", true);
// Decode all images automatically on load, ignoring our normal heuristics.
// Overrides image.decode-only-on-draw.enabled.
pref("image.decode-immediately.enabled", false);
// Whether we attempt to downscale images during decoding.
pref("image.downscale-during-decode.enabled", false);