From 5464037382ce1ddf0a69e5e4aa7d58b46b8ee254 Mon Sep 17 00:00:00 2001 From: Seth Fowler Date: Tue, 24 Mar 2015 15:39:00 -0700 Subject: [PATCH] Bug 1124088 - Rename decode-on-draw to decode-only-on-draw. r=tn --- b2g/app/b2g.js | 2 +- gfx/thebes/gfxPrefs.h | 2 +- image/src/Image.h | 10 +++++----- image/src/ImageFactory.cpp | 26 +++++++++++++------------- image/src/RasterImage.cpp | 32 ++++++++++++++++---------------- image/src/RasterImage.h | 4 ++-- mobile/android/app/mobile.js | 2 +- modules/libpref/init/all.js | 8 ++++---- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 4402d03c539..1631618ea3b 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -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 diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 7114a1a055b..308400f9012 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -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); diff --git a/image/src/Image.h b/image/src/Image.h index c45354575c1..53260cbb617 100644 --- a/image/src/Image.h +++ b/image/src/Image.h @@ -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; diff --git a/image/src/ImageFactory.cpp b/image/src/ImageFactory.cpp index cb10280d94b..ff655f742b9 100644 --- a/image/src/ImageFactory.cpp +++ b/image/src/ImageFactory.cpp @@ -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; diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index afef68cc6fa..238485a427a 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -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 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& 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; } diff --git a/image/src/RasterImage.h b/image/src/RasterImage.h index 9ef185c89fb..d1d75719119 100644 --- a/image/src/RasterImage.h +++ b/image/src/RasterImage.h @@ -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? diff --git a/mobile/android/app/mobile.js b/mobile/android/app/mobile.js index 9763100d9aa..8d63a9f2102 100644 --- a/mobile/android/app/mobile.js +++ b/mobile/android/app/mobile.js @@ -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. diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 398e17741c2..11586a7bcb1 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -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);