1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:37:44 +00:00

AK: Move memory streams from LibCore

This commit is contained in:
Tim Schumacher 2023-01-25 20:19:05 +01:00 committed by Andrew Kaster
parent 11550f582b
commit 093cf428a3
46 changed files with 213 additions and 203 deletions

View file

@ -11,9 +11,9 @@
#include <AK/Error.h>
#include <AK/IntegralMath.h>
#include <AK/Memory.h>
#include <AK/MemoryStream.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/Try.h>
#include <LibCore/MemoryStream.h>
#include <LibGfx/GIFLoader.h>
#include <string.h>
@ -381,7 +381,7 @@ static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
if (context.data_size < 32)
return Error::from_string_literal("Size too short for GIF frame descriptors");
auto stream = TRY(Core::Stream::FixedMemoryStream::construct(ReadonlyBytes { context.data, context.data_size }));
auto stream = TRY(FixedMemoryStream::construct(ReadonlyBytes { context.data, context.data_size }));
TRY(decode_gif_header(*stream));
@ -565,7 +565,7 @@ bool GIFImageDecoderPlugin::set_nonvolatile(bool& was_purged)
bool GIFImageDecoderPlugin::initialize()
{
auto stream_or_error = Core::Stream::FixedMemoryStream::construct(ReadonlyBytes { m_context->data, m_context->data_size });
auto stream_or_error = FixedMemoryStream::construct(ReadonlyBytes { m_context->data, m_context->data_size });
if (stream_or_error.is_error())
return false;
return !decode_gif_header(*stream_or_error.value()).is_error();
@ -573,7 +573,7 @@ bool GIFImageDecoderPlugin::initialize()
ErrorOr<bool> GIFImageDecoderPlugin::sniff(ReadonlyBytes data)
{
auto stream = TRY(Core::Stream::FixedMemoryStream::construct(data));
auto stream = TRY(FixedMemoryStream::construct(data));
return !decode_gif_header(*stream).is_error();
}

View file

@ -5,14 +5,15 @@
*/
#include <AK/Debug.h>
#include <AK/Endian.h>
#include <AK/Error.h>
#include <AK/FixedArray.h>
#include <AK/HashMap.h>
#include <AK/Math.h>
#include <AK/MemoryStream.h>
#include <AK/String.h>
#include <AK/Try.h>
#include <AK/Vector.h>
#include <LibCore/MemoryStream.h>
#include <LibGfx/JPGLoader.h>
#define JPG_INVALID 0X0000
@ -198,7 +199,7 @@ struct JPGLoadingContext {
HuffmanStreamState huffman_stream;
i32 previous_dc_values[3] = { 0 };
MacroblockMeta mblock_meta;
OwnPtr<Core::Stream::FixedMemoryStream> stream;
OwnPtr<FixedMemoryStream> stream;
Optional<ICCMultiChunkState> icc_multi_chunk_state;
Optional<ByteBuffer> icc_data;
@ -1201,7 +1202,7 @@ static ErrorOr<void> scan_huffman_stream(AK::SeekableStream& stream, JPGLoadingC
static ErrorOr<void> decode_header(JPGLoadingContext& context)
{
if (context.state < JPGLoadingContext::State::HeaderDecoded) {
context.stream = TRY(Core::Stream::FixedMemoryStream::construct({ context.data, context.data_size }));
context.stream = TRY(FixedMemoryStream::construct({ context.data, context.data_size }));
if (auto result = parse_header(*context.stream, context); result.is_error()) {
context.state = JPGLoadingContext::State::Error;

View file

@ -5,7 +5,7 @@
*/
#include <AK/Endian.h>
#include <LibCore/MemoryStream.h>
#include <AK/MemoryStream.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/QOILoader.h>
@ -202,13 +202,13 @@ bool QOIImageDecoderPlugin::initialize()
ErrorOr<bool> QOIImageDecoderPlugin::sniff(ReadonlyBytes data)
{
auto stream = TRY(Core::Stream::FixedMemoryStream::construct({ data.data(), data.size() }));
auto stream = TRY(FixedMemoryStream::construct({ data.data(), data.size() }));
return !decode_qoi_header(*stream).is_error();
}
ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> QOIImageDecoderPlugin::create(ReadonlyBytes data)
{
auto stream = TRY(Core::Stream::FixedMemoryStream::construct(data));
auto stream = TRY(FixedMemoryStream::construct(data));
return adopt_nonnull_own_or_enomem(new (nothrow) QOIImageDecoderPlugin(move(stream)));
}