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

AK: Deprecate the old AK::Stream

This also removes a few cases where the respective header wasn't
actually required to be included.
This commit is contained in:
Tim Schumacher 2023-01-20 14:07:24 +01:00 committed by Andrew Kaster
parent 230cb3b0cb
commit ae64b68717
38 changed files with 116 additions and 120 deletions

View file

@ -7,10 +7,10 @@
#include <AK/Bitmap.h>
#include <AK/Checked.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/Memory.h>
#include <AK/MemoryStream.h>
#include <AK/Optional.h>
#include <AK/Queue.h>
#include <AK/ScopeGuard.h>
@ -212,7 +212,7 @@ ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::create_from_serialized_byte_buffer(ByteBu
/// - image data (= actual size * u8)
ErrorOr<NonnullRefPtr<Bitmap>> Bitmap::create_from_serialized_bytes(ReadonlyBytes bytes)
{
InputMemoryStream stream { bytes };
DeprecatedInputMemoryStream stream { bytes };
size_t actual_size;
unsigned width;
unsigned height;
@ -260,7 +260,7 @@ ByteBuffer Bitmap::serialize_to_byte_buffer() const
{
// FIXME: Somehow handle possible OOM situation here.
auto buffer = ByteBuffer::create_uninitialized(sizeof(size_t) + 4 * sizeof(unsigned) + sizeof(BitmapFormat) + sizeof(ARGB32) * palette_size(m_format) + size_in_bytes()).release_value_but_fixme_should_propagate_errors();
OutputMemoryStream stream { buffer };
DeprecatedOutputMemoryStream stream { buffer };
auto write = [&]<typename T>(T value) {
if (stream.write({ &value, sizeof(T) }) != sizeof(T))

View file

@ -5,10 +5,10 @@
*/
#include <AK/Debug.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/DeprecatedString.h>
#include <AK/Endian.h>
#include <AK/Error.h>
#include <AK/MemoryStream.h>
#include <AK/StringBuilder.h>
#include <AK/Try.h>
#include <AK/Vector.h>
@ -454,7 +454,7 @@ static size_t bits_per_pixel(DXGIFormat format)
}
}
static void decode_dx5_alpha_block(InputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
static void decode_dx5_alpha_block(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
{
LittleEndian<u8> color0 {}, color1 {};
LittleEndian<u8> code0 {}, code1 {}, code2 {}, code3 {}, code4 {}, code5 {};
@ -517,7 +517,7 @@ static void decode_dx5_alpha_block(InputMemoryStream& stream, DDSLoadingContext&
}
}
static void decode_dx3_alpha_block(InputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
static void decode_dx3_alpha_block(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, u64 bitmap_x, u64 bitmap_y)
{
LittleEndian<u8> a0 {}, a1 {}, a2 {}, a3 {}, a4 {}, a5 {}, a6 {}, a7 {};
@ -565,7 +565,7 @@ static void unpack_rbg_565(u32 rgb, u8* output)
output[3] = 255;
}
static void decode_color_block(InputMemoryStream& stream, DDSLoadingContext& context, bool dxt1, u64 bitmap_x, u64 bitmap_y)
static void decode_color_block(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, bool dxt1, u64 bitmap_x, u64 bitmap_y)
{
LittleEndian<u8> c0_low {}, c0_high {}, c1_low {}, c1_high {};
LittleEndian<u8> codes_0 {}, codes_1 {}, codes_2 {}, codes_3 {};
@ -621,7 +621,7 @@ static void decode_color_block(InputMemoryStream& stream, DDSLoadingContext& con
}
}
static void decode_dxt(InputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 y)
static void decode_dxt(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 y)
{
if (format == DXGI_FORMAT_BC1_UNORM) {
for (size_t x = 0; x < width; x += 4) {
@ -643,7 +643,7 @@ static void decode_dxt(InputMemoryStream& stream, DDSLoadingContext& context, DX
}
}
}
static void decode_bitmap(InputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 height)
static void decode_bitmap(DeprecatedInputMemoryStream& stream, DDSLoadingContext& context, DXGIFormat format, u64 width, u64 height)
{
Vector<u32> dxt_formats = { DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC3_UNORM };
if (dxt_formats.contains_slow(format)) {
@ -698,7 +698,7 @@ static size_t get_minimum_bytes_for_mipmap(DXGIFormat format, u64 width, u64 hei
static ErrorOr<void> decode_dds(DDSLoadingContext& context)
{
InputMemoryStream stream({ context.data, context.data_size });
DeprecatedInputMemoryStream stream({ context.data, context.data_size });
// All valid DDS files are at least 128 bytes long.
if (stream.remaining() < 128) {

View file

@ -6,6 +6,7 @@
#pragma once
#include <AK/Endian.h>
#include <AK/Span.h>
#include <AK/Vector.h>
#include <LibGfx/AffineTransform.h>

View file

@ -7,6 +7,7 @@
#include <AK/Array.h>
#include <AK/Debug.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/Error.h>
#include <AK/IntegralMath.h>
#include <AK/Memory.h>

View file

@ -6,7 +6,7 @@
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/MemoryStream.h>
#include <AK/DeprecatedMemoryStream.h>
#include <AK/NonnullOwnPtrVector.h>
#include <AK/Types.h>
#include <LibGfx/BMPLoader.h>
@ -59,7 +59,7 @@ struct ICOLoadingContext {
size_t largest_index;
};
static Optional<size_t> decode_ico_header(InputMemoryStream& stream)
static Optional<size_t> decode_ico_header(DeprecatedInputMemoryStream& stream)
{
ICONDIR header;
stream >> Bytes { &header, sizeof(header) };
@ -71,7 +71,7 @@ static Optional<size_t> decode_ico_header(InputMemoryStream& stream)
return { header.image_count };
}
static Optional<ICOImageDescriptor> decode_ico_direntry(InputMemoryStream& stream)
static Optional<ICOImageDescriptor> decode_ico_direntry(DeprecatedInputMemoryStream& stream)
{
ICONDIRENTRY entry;
stream >> Bytes { &entry, sizeof(entry) };
@ -108,7 +108,7 @@ static size_t find_largest_image(ICOLoadingContext const& context)
static bool load_ico_directory(ICOLoadingContext& context)
{
InputMemoryStream stream { { context.data, context.data_size } };
DeprecatedInputMemoryStream stream { { context.data, context.data_size } };
auto image_count = decode_ico_header(stream);
if (!image_count.has_value() || image_count.value() == 0) {
@ -187,7 +187,7 @@ bool ICOImageDecoderPlugin::load_ico_bitmap(ICOLoadingContext& context, Optional
ErrorOr<bool> ICOImageDecoderPlugin::sniff(ReadonlyBytes data)
{
InputMemoryStream stream { { data.data(), data.size() } };
DeprecatedInputMemoryStream stream { { data.data(), data.size() } };
return decode_ico_header(stream).has_value();
}
@ -237,7 +237,7 @@ bool ICOImageDecoderPlugin::set_nonvolatile(bool& was_purged)
bool ICOImageDecoderPlugin::initialize()
{
InputMemoryStream stream { { m_context->data, m_context->data_size } };
DeprecatedInputMemoryStream stream { { m_context->data, m_context->data_size } };
return decode_ico_header(stream).has_value();
}

View file

@ -6,6 +6,7 @@
#include "QOIWriter.h"
#include <AK/DeprecatedString.h>
#include <AK/Endian.h>
namespace Gfx {