From ac0300a558b9dd8b6c1e765a993550b57156cfb2 Mon Sep 17 00:00:00 2001 From: Cameron Kaiser Date: Thu, 7 Feb 2019 21:29:43 -0800 Subject: [PATCH] #501: add toggle pref --- gfx/thebes/gfxPrefs.h | 1 + image/DecoderFactory.cpp | 6 ++++-- modules/libpref/init/all.js | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 410013d7d..10d1b01f7 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -295,6 +295,7 @@ private: DECL_GFX_PREF(Live, "image.mozsamplesize.enabled", ImageMozSampleSizeEnabled, bool, false); DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1); DECL_GFX_PREF(Live, "image.single-color-optimization.enabled", ImageSingleColorOptimizationEnabled, bool, true); + DECL_GFX_PREF(Live, "image.webp.enabled", ImageWebPEnabled, bool, false); DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabled, bool, false); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false); diff --git a/image/DecoderFactory.cpp b/image/DecoderFactory.cpp index 1872a7e81..f889b2bac 100644 --- a/image/DecoderFactory.cpp +++ b/image/DecoderFactory.cpp @@ -65,7 +65,8 @@ DecoderFactory::GetDecoderType(const char* aMimeType) type = DecoderType::ICON; // WEBP - } else if (!strcmp(aMimeType, IMAGE_WEBP)) { + } else if (!strcmp(aMimeType, IMAGE_WEBP) && + MOZ_LIKELY(gfxPrefs::ImageWebPEnabled())) { type = DecoderType::WEBP; } @@ -161,7 +162,8 @@ DecoderFactory::CreateAnimationDecoder(DecoderType aType, return nullptr; } - MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG, + MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG || + aType == DecoderType::WEBP, "Calling CreateAnimationDecoder for non-animating DecoderType"); RefPtr decoder = diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c6bcbe9d5..85975fdc2 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4193,6 +4193,9 @@ pref("image.mem.surfacecache.discard_factor", 1); // automatically determined based on the system's number of cores. pref("image.multithreaded_decoding.limit", -1); +// Whether we attempt to decode WebP images or not. +pref("image.webp.enabled", true); + // Limit for the canvas image cache. 0 means we don't limit the size of the // cache. pref("canvas.image.cache.limit", 0);