Bug 1294490 - Part 3. Implement WebP decoder. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D8116
This commit is contained in:
Andrew Osmond
2018-10-03 17:40:35 -04:00
parent a154acea09
commit ea3496614c
9 changed files with 688 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
#include "DecoderFactory.h"
#include "gfxPrefs.h"
#include "nsMimeTypes.h"
#include "mozilla/RefPtr.h"
@@ -19,6 +20,7 @@
#include "nsBMPDecoder.h"
#include "nsICODecoder.h"
#include "nsIconDecoder.h"
#include "nsWebPDecoder.h"
namespace mozilla {
@@ -67,6 +69,11 @@ DecoderFactory::GetDecoderType(const char* aMimeType)
// Icon
} else if (!strcmp(aMimeType, IMAGE_ICON_MS)) {
type = DecoderType::ICON;
// WebP
} else if (!strcmp(aMimeType, IMAGE_WEBP) &&
gfxPrefs::ImageWebPEnabled()) {
type = DecoderType::WEBP;
}
return type;
@@ -102,6 +109,9 @@ DecoderFactory::GetDecoder(DecoderType aType,
case DecoderType::ICON:
decoder = new nsIconDecoder(aImage);
break;
case DecoderType::WEBP:
decoder = new nsWebPDecoder(aImage);
break;
default:
MOZ_ASSERT_UNREACHABLE("Unknown decoder type");
}
@@ -182,7 +192,8 @@ DecoderFactory::CreateAnimationDecoder(DecoderType aType,
return NS_ERROR_INVALID_ARG;
}
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");
// Create an anonymous decoder. Interaction with the SurfaceCache and the