1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:38:10 +00:00

LibGfx: Don't keep an unused GIF decoder plugin in failed ImageDecoders

If we can't decode the input data, just have a null decoder. In this
state we simply return a null bitmap and whatever empty values make
sense for each API.

This way, we don't try to decode the same thing over and over since
it's not gonna work anyway. :^)
This commit is contained in:
Andreas Kling 2020-06-13 15:28:04 +02:00
parent e46ee46ed6
commit dc0ed5c860
2 changed files with 20 additions and 12 deletions

View file

@ -33,14 +33,14 @@ namespace Gfx {
ImageDecoder::ImageDecoder(const u8* data, size_t size)
{
m_plugin = make<PNGImageDecoderPlugin>(data, size);
if (m_plugin->sniff()) {
if (m_plugin->sniff())
return;
}
m_plugin = make<GIFImageDecoderPlugin>(data, size);
if (m_plugin->sniff()) {
if (m_plugin->sniff())
return;
}
m_plugin = nullptr;
}
ImageDecoder::~ImageDecoder()
@ -49,6 +49,8 @@ ImageDecoder::~ImageDecoder()
RefPtr<Gfx::Bitmap> ImageDecoder::bitmap() const
{
if (!m_plugin)
return nullptr;
return m_plugin->bitmap();
}