summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-11-20 10:46:27 +0100
committerAndreas Kling <kling@serenityos.org>2021-11-20 10:56:31 +0100
commite017fe92e6be10a3793232f43973373baf443914 (patch)
tree7e04cd70145477a1a31113a3e3415a63ad57d3f6 /Userland/Libraries/LibWeb
parentb224efe73bf2a47330163368afb90931280ef0b9 (diff)
downloadserenity-e017fe92e6be10a3793232f43973373baf443914.zip
LibWeb: Move ImageDecoder client connection singleton to its own file
This will allow us to use it in more places around LibWeb.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibWeb/ImageDecoding.cpp23
-rw-r--r--Userland/Libraries/LibWeb/ImageDecoding.h15
-rw-r--r--Userland/Libraries/LibWeb/Loader/ImageResource.cpp14
4 files changed, 40 insertions, 13 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt
index 3462193dee..81dbfa84aa 100644
--- a/Userland/Libraries/LibWeb/CMakeLists.txt
+++ b/Userland/Libraries/LibWeb/CMakeLists.txt
@@ -195,6 +195,7 @@ set(SOURCES
HTML/TagNames.cpp
HTML/WebSocket.cpp
HighResolutionTime/Performance.cpp
+ ImageDecoding.cpp
InProcessWebView.cpp
IntersectionObserver/IntersectionObserver.cpp
Layout/BlockContainer.cpp
diff --git a/Userland/Libraries/LibWeb/ImageDecoding.cpp b/Userland/Libraries/LibWeb/ImageDecoding.cpp
new file mode 100644
index 0000000000..706c04c97a
--- /dev/null
+++ b/Userland/Libraries/LibWeb/ImageDecoding.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibWeb/ImageDecoding.h>
+
+namespace Web {
+
+ImageDecoderClient::Client& image_decoder_client()
+{
+ static RefPtr<ImageDecoderClient::Client> image_decoder_client;
+ if (!image_decoder_client) {
+ image_decoder_client = ImageDecoderClient::Client::construct();
+ image_decoder_client->on_death = [&] {
+ image_decoder_client = nullptr;
+ };
+ }
+ return *image_decoder_client;
+}
+
+}
diff --git a/Userland/Libraries/LibWeb/ImageDecoding.h b/Userland/Libraries/LibWeb/ImageDecoding.h
new file mode 100644
index 0000000000..081b4e123c
--- /dev/null
+++ b/Userland/Libraries/LibWeb/ImageDecoding.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibImageDecoderClient/Client.h>
+
+namespace Web {
+
+ImageDecoderClient::Client& image_decoder_client();
+
+}
diff --git a/Userland/Libraries/LibWeb/Loader/ImageResource.cpp b/Userland/Libraries/LibWeb/Loader/ImageResource.cpp
index 39f2ee5995..b425c98847 100644
--- a/Userland/Libraries/LibWeb/Loader/ImageResource.cpp
+++ b/Userland/Libraries/LibWeb/Loader/ImageResource.cpp
@@ -5,7 +5,7 @@
*/
#include <LibGfx/Bitmap.h>
-#include <LibImageDecoderClient/Client.h>
+#include <LibWeb/ImageDecoding.h>
#include <LibWeb/Loader/ImageResource.h>
namespace Web {
@@ -27,18 +27,6 @@ int ImageResource::frame_duration(size_t frame_index) const
return m_decoded_frames[frame_index].duration;
}
-static ImageDecoderClient::Client& image_decoder_client()
-{
- static RefPtr<ImageDecoderClient::Client> image_decoder_client;
- if (!image_decoder_client) {
- image_decoder_client = ImageDecoderClient::Client::construct();
- image_decoder_client->on_death = [&] {
- image_decoder_client = nullptr;
- };
- }
- return *image_decoder_client;
-}
-
void ImageResource::decode_if_needed() const
{
if (!has_encoded_data())