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

LibDraw: Create purgeable GraphicsBitmap in the PNG decoder

Also add ImageDecoder APIs for controlling the volatile flag.
This commit is contained in:
Andreas Kling 2019-12-18 20:50:58 +01:00
parent 77ae98a9b6
commit 7cc4b90b16
3 changed files with 21 additions and 1 deletions

View file

@ -515,7 +515,7 @@ static bool decode_png_bitmap(PNGLoadingContext& context)
#ifdef PNG_STOPWATCH_DEBUG
Stopwatch sw("load_png_impl: create bitmap");
#endif
context.bitmap = GraphicsBitmap::create(context.has_alpha() ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32, { context.width, context.height });
context.bitmap = GraphicsBitmap::create_purgeable(context.has_alpha() ? GraphicsBitmap::Format::RGBA32 : GraphicsBitmap::Format::RGB32, { context.width, context.height });
}
unfilter(context);
@ -701,3 +701,16 @@ RefPtr<GraphicsBitmap> PNGImageDecoderPlugin::bitmap()
ASSERT(m_context->bitmap);
return m_context->bitmap;
}
void PNGImageDecoderPlugin::set_volatile()
{
if (m_context->bitmap)
m_context->bitmap->set_volatile();
}
bool PNGImageDecoderPlugin::set_nonvolatile()
{
if (!m_context->bitmap)
return false;
return m_context->bitmap->set_nonvolatile();
}