1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibGfx: Make Gfx::Bitmap::set_nonvolatile() report allocation failure

Making a bitmap non-volatile after being volatile may fail to allocate
physical pages after the kernel stole the old pages in a purge.

This is different from the pages being purged, but reallocated. In that
case, they are simply replaced with zero-fill-on-demand pages as if
they were freshly allocated.
This commit is contained in:
Andreas Kling 2021-07-24 22:49:48 +02:00
parent 24b5295b30
commit 143443e0b6
23 changed files with 57 additions and 46 deletions

View file

@ -97,8 +97,9 @@ void ImageResource::update_volatility()
if (!frame.bitmap) {
still_has_decoded_image = false;
} else {
bool still_has_frame = frame.bitmap->set_nonvolatile();
if (!still_has_frame)
bool was_purged = false;
bool bitmap_has_memory = frame.bitmap->set_nonvolatile(was_purged);
if (!bitmap_has_memory || was_purged)
still_has_decoded_image = false;
}
}