mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 04:37:40 +00:00
LibWeb: Move ImageDecoder client connection singleton to its own file
This will allow us to use it in more places around LibWeb.
This commit is contained in:
parent
b224efe73b
commit
e017fe92e6
4 changed files with 40 additions and 13 deletions
|
@ -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
|
||||
|
|
23
Userland/Libraries/LibWeb/ImageDecoding.cpp
Normal file
23
Userland/Libraries/LibWeb/ImageDecoding.cpp
Normal file
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
15
Userland/Libraries/LibWeb/ImageDecoding.h
Normal file
15
Userland/Libraries/LibWeb/ImageDecoding.h
Normal file
|
@ -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();
|
||||
|
||||
}
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue