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
parent 5eb007c73d
commit 5464037382
8 changed files with 43 additions and 43 deletions

View File

@ -322,7 +322,7 @@ pref("media.fragmented-mp4.gonk.enabled", true);
pref("media.video-queue.default-size", 3); pref("media.video-queue.default-size", 3);
// optimize images' memory usage // 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 */ 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. // 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 // Almost everything that was factored into 'max_decoded_image_kb' is now stored

View File

@ -235,12 +235,12 @@ private:
DECL_GFX_PREF(Once, "image.cache.size", ImageCacheSize, int32_t, 5*1024*1024); 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(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.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.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_downscaling.min_factor", ImageHQDownscalingMinFactor, uint32_t, 1000);
DECL_GFX_PREF(Live, "image.high_quality_upscaling.max_size", ImageHQUpscalingMaxSize, uint32_t, 20971520); 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(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(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.discard_factor", ImageMemSurfaceCacheDiscardFactor, uint32_t, 1);
DECL_GFX_PREF(Once, "image.mem.surfacecache.max_size_kb", ImageMemSurfaceCacheMaxSizeKB, uint32_t, 100 * 1024); DECL_GFX_PREF(Once, "image.mem.surfacecache.max_size_kb", ImageMemSurfaceCacheMaxSizeKB, uint32_t, 100 * 1024);

View File

@ -44,14 +44,14 @@ public:
* *
* INIT_FLAG_DISCARDABLE: The container should be discardable * INIT_FLAG_DISCARDABLE: The container should be discardable
* *
* INIT_FLAG_DECODE_ON_DRAW: The container should decode on draw rather than * INIT_FLAG_DECODE_ONLY_ON_DRAW: The container should decode on draw rather
* decoding on load. * than possibly being speculatively decoded earlier.
* *
* INIT_FLAG_TRANSIENT: The container is likely to exist for only a short time * INIT_FLAG_TRANSIENT: The container is likely to exist for only a short time
* before being destroyed. (For example, containers for * before being destroyed. (For example, containers for
* multipart/x-mixed-replace image parts fall into this category.) If this * 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 * flag is set, INIT_FLAG_DISCARDABLE and INIT_FLAG_DECODE_ONLY_ON_DRAW must
* set. * not be set.
* *
* INIT_FLAG_DOWNSCALE_DURING_DECODE: The container should attempt to * INIT_FLAG_DOWNSCALE_DURING_DECODE: The container should attempt to
* downscale images during decoding instead of decoding them to their * 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_NONE = 0x0;
static const uint32_t INIT_FLAG_DISCARDABLE = 0x1; 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_TRANSIENT = 0x4;
static const uint32_t INIT_FLAG_DOWNSCALE_DURING_DECODE = 0x8; static const uint32_t INIT_FLAG_DOWNSCALE_DURING_DECODE = 0x8;

View File

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

View File

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

View File

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

View File

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

View File

@ -3825,6 +3825,10 @@ pref("image.cache.size", 5242880);
// Size is given a weight of 1000 - timeweight. // Size is given a weight of 1000 - timeweight.
pref("image.cache.timeweight", 500); 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. // Whether we attempt to downscale images during decoding.
pref("image.downscale-during-decode.enabled", false); pref("image.downscale-during-decode.enabled", false);
@ -3852,10 +3856,6 @@ pref("image.single-color-optimization.enabled", true);
// compressed data. // compressed data.
pref("image.mem.discardable", true); 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. // Allows image locking of decoded image data in content processes.
pref("image.mem.allow_locking_in_content_processes", true); pref("image.mem.allow_locking_in_content_processes", true);