Bug 1124088 - Rename decode-on-draw to decode-only-on-draw. r=tn

This commit is contained in:
Seth Fowler 2015-03-24 15:39:00 -07:00
Родитель d3ec1cd8da
Коммит 5e1bf3762e
8 изменённых файлов: 43 добавлений и 43 удалений

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

@ -322,7 +322,7 @@ pref("media.fragmented-mp4.gonk.enabled", true);
pref("media.video-queue.default-size", 3);
// optimize images' memory usage
pref("image.mem.decodeondraw", true);
pref("image.decode-only-on-draw.enabled", true);
pref("image.mem.allow_locking_in_content_processes", false); /* don't allow image locking */
// Limit the surface cache to 1/8 of main memory or 128MB, whichever is smaller.
// Almost everything that was factored into 'max_decoded_image_kb' is now stored

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

@ -235,12 +235,12 @@ 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.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);
DECL_GFX_PREF(Live, "image.high_quality_upscaling.max_size", ImageHQUpscalingMaxSize, uint32_t, 20971520);
DECL_GFX_PREF(Once, "image.mem.decode_bytes_at_a_time", ImageMemDecodeBytesAtATime, uint32_t, 200000);
DECL_GFX_PREF(Live, "image.mem.decodeondraw", ImageMemDecodeOnDraw, bool, true);
DECL_GFX_PREF(Live, "image.mem.discardable", ImageMemDiscardable, bool, false);
DECL_GFX_PREF(Once, "image.mem.surfacecache.discard_factor", ImageMemSurfaceCacheDiscardFactor, uint32_t, 1);
DECL_GFX_PREF(Once, "image.mem.surfacecache.max_size_kb", ImageMemSurfaceCacheMaxSizeKB, uint32_t, 100 * 1024);

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

@ -44,14 +44,14 @@ public:
*
* INIT_FLAG_DISCARDABLE: The container should be discardable
*
* INIT_FLAG_DECODE_ON_DRAW: The container should decode on draw rather than
* decoding on load.
* INIT_FLAG_DECODE_ONLY_ON_DRAW: The container should decode on draw rather
* than possibly being speculatively decoded earlier.
*
* 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
* flag is set, INIT_FLAG_DISCARDABLE and INIT_FLAG_DECODE_ON_DRAW must not be
* set.
* flag is set, INIT_FLAG_DISCARDABLE and INIT_FLAG_DECODE_ONLY_ON_DRAW must
* not be set.
*
* INIT_FLAG_DOWNSCALE_DURING_DECODE: The container should attempt to
* downscale images during decoding instead of decoding them to their
@ -59,7 +59,7 @@ public:
*/
static const uint32_t INIT_FLAG_NONE = 0x0;
static const uint32_t INIT_FLAG_DISCARDABLE = 0x1;
static const uint32_t INIT_FLAG_DECODE_ON_DRAW = 0x2;
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;

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

@ -46,38 +46,38 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
// We default to the static globals.
bool isDiscardable = gfxPrefs::ImageMemDiscardable();
bool doDecodeOnDraw = gfxPrefs::ImageMemDecodeOnDraw() &&
gfxPrefs::AsyncPanZoomEnabled();
bool doDecodeOnlyOnDraw = gfxPrefs::ImageDecodeOnlyOnDrawEnabled() &&
gfxPrefs::AsyncPanZoomEnabled();
bool doDownscaleDuringDecode = gfxPrefs::ImageDownscaleDuringDecodeEnabled();
// We want UI to be as snappy as possible and not to flicker. Disable
// discarding and decode-on-draw for chrome URLS.
// discarding and decode-only-on-draw for chrome URLS.
bool isChrome = false;
rv = uri->SchemeIs("chrome", &isChrome);
if (NS_SUCCEEDED(rv) && isChrome) {
isDiscardable = doDecodeOnDraw = false;
isDiscardable = doDecodeOnlyOnDraw = false;
}
// We don't want resources like the "loading" icon to be discardable or
// decode-on-draw either.
// decode-only-on-draw either.
bool isResource = false;
rv = uri->SchemeIs("resource", &isResource);
if (NS_SUCCEEDED(rv) && isResource) {
isDiscardable = doDecodeOnDraw = false;
isDiscardable = doDecodeOnlyOnDraw = false;
}
// Downscale-during-decode and decode-on-draw are only enabled for certain
// content types.
if ((doDownscaleDuringDecode || doDecodeOnDraw) &&
// Downscale-during-decode and decode-only-on-draw are only enabled for
// certain content types.
if ((doDownscaleDuringDecode || doDecodeOnlyOnDraw) &&
!ShouldDownscaleDuringDecode(aMimeType)) {
doDownscaleDuringDecode = false;
doDecodeOnDraw = false;
doDecodeOnlyOnDraw = false;
}
// For multipart/x-mixed-replace, we basically want a direct channel to the
// decoder. Disable everything for this case.
if (isMultiPart) {
isDiscardable = doDecodeOnDraw = doDownscaleDuringDecode = false;
isDiscardable = doDecodeOnlyOnDraw = doDownscaleDuringDecode = false;
}
// We have all the information we need.
@ -85,8 +85,8 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
if (isDiscardable) {
imageFlags |= Image::INIT_FLAG_DISCARDABLE;
}
if (doDecodeOnDraw) {
imageFlags |= Image::INIT_FLAG_DECODE_ON_DRAW;
if (doDecodeOnlyOnDraw) {
imageFlags |= Image::INIT_FLAG_DECODE_ONLY_ON_DRAW;
}
if (isMultiPart) {
imageFlags |= Image::INIT_FLAG_TRANSIENT;

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

@ -263,7 +263,7 @@ RasterImage::RasterImage(ProgressTracker* aProgressTracker,
mSourceBuffer(new SourceBuffer()),
mFrameCount(0),
mHasSize(false),
mDecodeOnDraw(false),
mDecodeOnlyOnDraw(false),
mTransient(false),
mDiscardable(false),
mHasSourceData(false),
@ -304,18 +304,18 @@ RasterImage::Init(const char* aMimeType,
NS_ENSURE_ARG_POINTER(aMimeType);
// We must be non-discardable and non-decode-on-draw for
// We must be non-discardable and non-decode-only-on-draw for
// transient images.
MOZ_ASSERT(!(aFlags & INIT_FLAG_TRANSIENT) ||
(!(aFlags & INIT_FLAG_DISCARDABLE) &&
!(aFlags & INIT_FLAG_DECODE_ON_DRAW) &&
!(aFlags & INIT_FLAG_DECODE_ONLY_ON_DRAW) &&
!(aFlags & INIT_FLAG_DOWNSCALE_DURING_DECODE)),
"Illegal init flags for transient image");
// Store initialization data
mSourceDataMimeType.Assign(aMimeType);
mDiscardable = !!(aFlags & INIT_FLAG_DISCARDABLE);
mDecodeOnDraw = !!(aFlags & INIT_FLAG_DECODE_ON_DRAW);
mDecodeOnlyOnDraw = !!(aFlags & INIT_FLAG_DECODE_ONLY_ON_DRAW);
mTransient = !!(aFlags & INIT_FLAG_TRANSIENT);
mDownscaleDuringDecode = !!(aFlags & INIT_FLAG_DOWNSCALE_DURING_DECODE);
@ -1172,11 +1172,11 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
Progress loadProgress = LoadCompleteProgress(aLastPart, mError, finalStatus);
if (mDecodeOnDraw) {
// For decode-on-draw images, we want to send notifications as if we've
if (mDecodeOnlyOnDraw) {
// For decode-only-on-draw images, we want to send notifications as if we've
// already finished decoding. Otherwise some observers will never even try
// to draw. (We may have already sent some of these notifications from
// NotifyForDecodeOnDrawOnly(), but ProgressTracker will ensure no duplicate
// NotifyForDecodeOnlyOnDraw(), but ProgressTracker will ensure no duplicate
// notifications get sent.)
loadProgress |= FLAG_ONLOAD_BLOCKED |
FLAG_DECODE_STARTED |
@ -1192,11 +1192,11 @@ RasterImage::OnImageDataComplete(nsIRequest*, nsISupports*, nsresult aStatus,
}
void
RasterImage::NotifyForDecodeOnDrawOnly()
RasterImage::NotifyForDecodeOnlyOnDraw()
{
if (!NS_IsMainThread()) {
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableMethod(this, &RasterImage::NotifyForDecodeOnDrawOnly);
NS_NewRunnableMethod(this, &RasterImage::NotifyForDecodeOnlyOnDraw);
NS_DispatchToMainThread(runnable);
return;
}
@ -1213,10 +1213,10 @@ RasterImage::OnImageDataAvailable(nsIRequest*,
{
nsresult rv;
if (MOZ_UNLIKELY(mDecodeOnDraw && aOffset == 0)) {
// If we're a decode-on-draw image, send notifications as if we've just
if (MOZ_UNLIKELY(mDecodeOnlyOnDraw && aOffset == 0)) {
// If we're a decode-only-on-draw image, send notifications as if we've just
// started decoding.
NotifyForDecodeOnDrawOnly();
NotifyForDecodeOnlyOnDraw();
}
// WriteToSourceBuffer always consumes everything it gets if it doesn't run
@ -1424,8 +1424,8 @@ RasterImage::CreateDecoder(const Maybe<nsIntSize>& aSize, uint32_t aFlags)
NS_IMETHODIMP
RasterImage::RequestDecode()
{
// For decode-on-draw images, we only act on RequestDecodeForSize.
if (mDecodeOnDraw) {
// For decode-only-on-draw images, we only act on RequestDecodeForSize.
if (mDecodeOnlyOnDraw) {
return NS_OK;
}
@ -1436,8 +1436,8 @@ RasterImage::RequestDecode()
NS_IMETHODIMP
RasterImage::StartDecoding()
{
// For decode-on-draw images, we only act on RequestDecodeForSize.
if (mDecodeOnDraw) {
// For decode-only-on-draw images, we only act on RequestDecodeForSize.
if (mDecodeOnlyOnDraw) {
return NS_OK;
}

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

@ -248,7 +248,7 @@ public:
nsresult aStatus,
bool aLastPart) override;
void NotifyForDecodeOnDrawOnly();
void NotifyForDecodeOnlyOnDraw();
/**
* A hint of the number of bytes of source data that the image contains. If
@ -400,7 +400,7 @@ private: // data
// Boolean flags (clustered together to conserve space):
bool mHasSize:1; // Has SetSize() been called?
bool mDecodeOnDraw:1; // Decoding on draw?
bool mDecodeOnlyOnDraw:1; // Decoding only on draw?
bool mTransient:1; // Is the image short-lived?
bool mDiscardable:1; // Is container discardable?
bool mHasSourceData:1; // Do we have source data?

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

@ -566,7 +566,7 @@ pref("media.fragmented-mp4.android-media-codec.enabled", true);
pref("media.fragmented-mp4.android-media-codec.preferred", true);
// optimize images memory usage
pref("image.mem.decodeondraw", true);
pref("image.decode-only-on-draw.enabled", true);
#ifdef NIGHTLY_BUILD
// Shumway component (SWF player) is disabled by default. Also see bug 904346.

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

@ -3825,6 +3825,10 @@ pref("image.cache.size", 5242880);
// Size is given a weight of 1000 - timeweight.
pref("image.cache.timeweight", 500);
// Prevents images from automatically being decoded on load, instead allowing
// them to be decoded on demand when they are drawn.
pref("image.decode-only-on-draw.enabled", true);
// Whether we attempt to downscale images during decoding.
pref("image.downscale-during-decode.enabled", false);
@ -3852,10 +3856,6 @@ pref("image.single-color-optimization.enabled", true);
// compressed data.
pref("image.mem.discardable", true);
// Prevents images from automatically being decoded on load, instead allowing
// them to be decoded on demand when they are drawn.
pref("image.mem.decodeondraw", true);
// Allows image locking of decoded image data in content processes.
pref("image.mem.allow_locking_in_content_processes", true);