From d4ddb0013cda7a8ef59e01883c643cac53448ef6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 2 Jun 2020 20:27:26 +0200 Subject: [PATCH] LibWeb: Share decoded images at the Resource level :^) This patch adds ImageResource as a subclass of Resource. This new class also keeps a Gfx::ImageDecoder so that we can share decoded bitmaps between all clients of an image resource inside LibWeb. With this, we now share both encoded and decoded data for images. :^) I had to change how the purgeable-volatile flag is updated to keep the volatile-images-outside-the-visible-viewport optimization working. HTMLImageElement now inherits from ImageResourceClient (a subclass of ResourceClient with additional image-specific stuff) and informs its ImageResource about whether it's inside the viewport or outside. This is pretty awesome! :^) --- Base/home/anon/www/many-buggies.html | 9 +++ Base/home/anon/www/welcome.html | 1 + Libraries/LibWeb/CMakeLists.txt | 1 + Libraries/LibWeb/CSS/StyleValue.cpp | 2 +- Libraries/LibWeb/DOM/HTMLImageElement.cpp | 30 ++++---- Libraries/LibWeb/DOM/HTMLImageElement.h | 11 ++- Libraries/LibWeb/DOM/HTMLLinkElement.cpp | 2 +- Libraries/LibWeb/Layout/LayoutDocument.cpp | 2 +- Libraries/LibWeb/Loader/ImageResource.cpp | 80 ++++++++++++++++++++++ Libraries/LibWeb/Loader/ImageResource.h | 59 ++++++++++++++++ Libraries/LibWeb/Loader/Resource.cpp | 9 ++- Libraries/LibWeb/Loader/Resource.h | 16 +++-- Libraries/LibWeb/Loader/ResourceLoader.cpp | 4 +- Libraries/LibWeb/Loader/ResourceLoader.h | 4 +- 14 files changed, 200 insertions(+), 30 deletions(-) create mode 100644 Base/home/anon/www/many-buggies.html create mode 100644 Libraries/LibWeb/Loader/ImageResource.cpp create mode 100644 Libraries/LibWeb/Loader/ImageResource.h diff --git a/Base/home/anon/www/many-buggies.html b/Base/home/anon/www/many-buggies.html new file mode 100644 index 0000000000..aa012e9595 --- /dev/null +++ b/Base/home/anon/www/many-buggies.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Base/home/anon/www/welcome.html b/Base/home/anon/www/welcome.html index 4a7fa634ce..46e8aa17af 100644 --- a/Base/home/anon/www/welcome.html +++ b/Base/home/anon/www/welcome.html @@ -28,6 +28,7 @@ span#ua {

Your user agent is:

Some small test pages: