mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
|
@ -83,7 +83,7 @@ struct PNGLoadingContext {
|
|||
BitmapDecoded,
|
||||
};
|
||||
State state { State::NotDecoded };
|
||||
const u8* data { nullptr };
|
||||
u8 const* data { nullptr };
|
||||
size_t data_size { 0 };
|
||||
int width { -1 };
|
||||
int height { -1 };
|
||||
|
@ -119,7 +119,7 @@ struct PNGLoadingContext {
|
|||
|
||||
class Streamer {
|
||||
public:
|
||||
Streamer(const u8* data, size_t size)
|
||||
Streamer(u8 const* data, size_t size)
|
||||
: m_data_ptr(data)
|
||||
, m_size_remaining(size)
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ public:
|
|||
{
|
||||
if (m_size_remaining < sizeof(T))
|
||||
return false;
|
||||
value = *((const NetworkOrdered<T>*)m_data_ptr);
|
||||
value = *((NetworkOrdered<T> const*)m_data_ptr);
|
||||
m_data_ptr += sizeof(T);
|
||||
m_size_remaining -= sizeof(T);
|
||||
return true;
|
||||
|
@ -159,7 +159,7 @@ public:
|
|||
bool at_end() const { return !m_size_remaining; }
|
||||
|
||||
private:
|
||||
const u8* m_data_ptr { nullptr };
|
||||
u8 const* m_data_ptr { nullptr };
|
||||
size_t m_size_remaining { 0 };
|
||||
};
|
||||
|
||||
|
@ -191,9 +191,9 @@ union [[gnu::packed]] Pixel {
|
|||
static_assert(AssertSize<Pixel, 4>());
|
||||
|
||||
template<bool has_alpha, u8 filter_type>
|
||||
ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void* dummy_scanline_data)
|
||||
ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, void const* dummy_scanline_data)
|
||||
{
|
||||
auto* dummy_scanline = (const Pixel*)dummy_scanline_data;
|
||||
auto* dummy_scanline = (Pixel const*)dummy_scanline_data;
|
||||
if constexpr (filter_type == 0) {
|
||||
auto* pixels = (Pixel*)bitmap.scanline(y);
|
||||
for (int i = 0; i < bitmap.width(); ++i) {
|
||||
|
@ -208,7 +208,7 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void*
|
|||
for (int i = 1; i < bitmap.width(); ++i) {
|
||||
auto& x = pixels[i];
|
||||
swap(x.r, x.b);
|
||||
auto& a = (const Pixel&)pixels[i - 1];
|
||||
auto& a = (Pixel const&)pixels[i - 1];
|
||||
x.v[0] += a.v[0];
|
||||
x.v[1] += a.v[1];
|
||||
x.v[2] += a.v[2];
|
||||
|
@ -219,11 +219,11 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void*
|
|||
}
|
||||
if constexpr (filter_type == 2) {
|
||||
auto* pixels = (Pixel*)bitmap.scanline(y);
|
||||
auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (const Pixel*)bitmap.scanline(y - 1);
|
||||
auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (Pixel const*)bitmap.scanline(y - 1);
|
||||
for (int i = 0; i < bitmap.width(); ++i) {
|
||||
auto& x = pixels[i];
|
||||
swap(x.r, x.b);
|
||||
const Pixel& b = pixels_y_minus_1[i];
|
||||
Pixel const& b = pixels_y_minus_1[i];
|
||||
x.v[0] += b.v[0];
|
||||
x.v[1] += b.v[1];
|
||||
x.v[2] += b.v[2];
|
||||
|
@ -234,14 +234,14 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void*
|
|||
}
|
||||
if constexpr (filter_type == 3) {
|
||||
auto* pixels = (Pixel*)bitmap.scanline(y);
|
||||
auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (const Pixel*)bitmap.scanline(y - 1);
|
||||
auto* pixels_y_minus_1 = y == 0 ? dummy_scanline : (Pixel const*)bitmap.scanline(y - 1);
|
||||
for (int i = 0; i < bitmap.width(); ++i) {
|
||||
auto& x = pixels[i];
|
||||
swap(x.r, x.b);
|
||||
Pixel a;
|
||||
if (i != 0)
|
||||
a = pixels[i - 1];
|
||||
const Pixel& b = pixels_y_minus_1[i];
|
||||
Pixel const& b = pixels_y_minus_1[i];
|
||||
x.v[0] = x.v[0] + ((a.v[0] + b.v[0]) / 2);
|
||||
x.v[1] = x.v[1] + ((a.v[1] + b.v[1]) / 2);
|
||||
x.v[2] = x.v[2] + ((a.v[2] + b.v[2]) / 2);
|
||||
|
@ -257,7 +257,7 @@ ALWAYS_INLINE static void unfilter_impl(Gfx::Bitmap& bitmap, int y, const void*
|
|||
auto& x = pixels[i];
|
||||
swap(x.r, x.b);
|
||||
Pixel a;
|
||||
const Pixel& b = pixels_y_minus_1[i];
|
||||
Pixel const& b = pixels_y_minus_1[i];
|
||||
Pixel c;
|
||||
if (i != 0) {
|
||||
a = pixels[i - 1];
|
||||
|
@ -291,7 +291,7 @@ template<typename T>
|
|||
ALWAYS_INLINE static void unpack_grayscale_with_alpha(PNGLoadingContext& context)
|
||||
{
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
auto* tuples = reinterpret_cast<const Tuple<T>*>(context.scanlines[y].data.data());
|
||||
auto* tuples = reinterpret_cast<Tuple<T> const*>(context.scanlines[y].data.data());
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
pixel.r = tuples[i].gray;
|
||||
|
@ -306,7 +306,7 @@ template<typename T>
|
|||
ALWAYS_INLINE static void unpack_triplets_without_alpha(PNGLoadingContext& context)
|
||||
{
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
auto* triplets = reinterpret_cast<const Triplet<T>*>(context.scanlines[y].data.data());
|
||||
auto* triplets = reinterpret_cast<Triplet<T> const*>(context.scanlines[y].data.data());
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
pixel.r = triplets[i].r;
|
||||
|
@ -321,7 +321,7 @@ template<typename T>
|
|||
ALWAYS_INLINE static void unpack_triplets_with_transparency_value(PNGLoadingContext& context, Triplet<T> transparency_value)
|
||||
{
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
auto* triplets = reinterpret_cast<const Triplet<T>*>(context.scanlines[y].data.data());
|
||||
auto* triplets = reinterpret_cast<Triplet<T> const*>(context.scanlines[y].data.data());
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
pixel.r = triplets[i].r;
|
||||
|
@ -401,7 +401,7 @@ NEVER_INLINE FLATTEN static ErrorOr<void> unfilter(PNGLoadingContext& context)
|
|||
}
|
||||
} else if (context.bit_depth == 16) {
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
auto* triplets = reinterpret_cast<const Quad<u16>*>(context.scanlines[y].data.data());
|
||||
auto* triplets = reinterpret_cast<Quad<u16> const*>(context.scanlines[y].data.data());
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
pixel.r = triplets[i].r & 0xFF;
|
||||
|
@ -538,7 +538,7 @@ static bool decode_png_size(PNGLoadingContext& context)
|
|||
return false;
|
||||
}
|
||||
|
||||
const u8* data_ptr = context.data + sizeof(png_header);
|
||||
u8 const* data_ptr = context.data + sizeof(png_header);
|
||||
size_t data_remaining = context.data_size - sizeof(png_header);
|
||||
|
||||
Streamer streamer(data_ptr, data_remaining);
|
||||
|
@ -566,7 +566,7 @@ static bool decode_png_chunks(PNGLoadingContext& context)
|
|||
return false;
|
||||
}
|
||||
|
||||
const u8* data_ptr = context.data + sizeof(png_header);
|
||||
u8 const* data_ptr = context.data + sizeof(png_header);
|
||||
int data_remaining = context.data_size - sizeof(png_header);
|
||||
|
||||
context.compressed_data.ensure_capacity(context.data_size);
|
||||
|
@ -861,7 +861,7 @@ static bool process_IDAT(ReadonlyBytes data, PNGLoadingContext& context)
|
|||
|
||||
static bool process_PLTE(ReadonlyBytes data, PNGLoadingContext& context)
|
||||
{
|
||||
context.palette_data.append((const PaletteEntry*)data.data(), data.size() / 3);
|
||||
context.palette_data.append((PaletteEntry const*)data.data(), data.size() / 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -902,18 +902,18 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context)
|
|||
}
|
||||
dbgln_if(PNG_DEBUG, "Chunk type: '{}', size: {}, crc: {:x}", chunk_type, chunk_size, chunk_crc);
|
||||
|
||||
if (!strcmp((const char*)chunk_type, "IHDR"))
|
||||
if (!strcmp((char const*)chunk_type, "IHDR"))
|
||||
return process_IHDR(chunk_data, context);
|
||||
if (!strcmp((const char*)chunk_type, "IDAT"))
|
||||
if (!strcmp((char const*)chunk_type, "IDAT"))
|
||||
return process_IDAT(chunk_data, context);
|
||||
if (!strcmp((const char*)chunk_type, "PLTE"))
|
||||
if (!strcmp((char const*)chunk_type, "PLTE"))
|
||||
return process_PLTE(chunk_data, context);
|
||||
if (!strcmp((const char*)chunk_type, "tRNS"))
|
||||
if (!strcmp((char const*)chunk_type, "tRNS"))
|
||||
return process_tRNS(chunk_data, context);
|
||||
return true;
|
||||
}
|
||||
|
||||
PNGImageDecoderPlugin::PNGImageDecoderPlugin(const u8* data, size_t size)
|
||||
PNGImageDecoderPlugin::PNGImageDecoderPlugin(u8 const* data, size_t size)
|
||||
{
|
||||
m_context = make<PNGLoadingContext>();
|
||||
m_context->data = data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue