LibGfx+LibWeb: Cache SkImage in ImmutableBitmap

By caching the SkImage that is reused across repaints, we allow Skia t
optimize GPU texture caching.

ImmutableBitmap is chosen to own the SkImage because it guarantees that
the underlying pixels cannot be modified. This is not the case for
Gfx::Bitmap, where invalidating the SkImage would be challenging since
it exposes pointers to underlying data through methods like scanline().
This commit is contained in:
Aliaksandr Kalenik 2024-11-09 05:48:17 +01:00 committed by Alexander Kalenik
parent 460803d2da
commit 698bca686e
Notes: github-actions[bot] 2024-11-09 20:21:03 +00:00
20 changed files with 186 additions and 118 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -120,13 +121,6 @@ RefPtr<Gfx::ImmutableBitmap> HTMLImageElement::immutable_bitmap() const
return current_image_bitmap();
}
RefPtr<Gfx::Bitmap const> HTMLImageElement::bitmap() const
{
if (auto immutable_bitmap = this->immutable_bitmap())
return immutable_bitmap->bitmap();
return {};
}
bool HTMLImageElement::is_image_available() const
{
return m_current_request && m_current_request->is_available();