1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 00:08:11 +00:00

SharedGraphics: Run clang-format on everything.

This commit is contained in:
Andreas Kling 2019-06-07 11:46:55 +02:00
parent 7770d6a09d
commit 76b3337498
20 changed files with 216 additions and 114 deletions

View file

@ -1,15 +1,15 @@
#include <SharedGraphics/PNGLoader.h>
#include <AK/NetworkOrdered.h>
#include <AK/MappedFile.h>
#include <AK/FileSystemPath.h>
#include <AK/MappedFile.h>
#include <AK/NetworkOrdered.h>
#include <SharedGraphics/PNGLoader.h>
#include <SharedGraphics/puff.c>
#include <fcntl.h>
#include <serenity.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <SharedGraphics/puff.c>
#include <serenity.h>
//#define PNG_STOPWATCH_DEBUG
@ -125,7 +125,8 @@ RetainPtr<GraphicsBitmap> load_png(const StringView& path)
return c;
}
union [[gnu::packed]] Pixel {
union [[gnu::packed]] Pixel
{
RGBA32 rgba { 0 };
byte v[4];
struct {
@ -186,7 +187,8 @@ template<bool has_alpha, byte filter_type>
auto& x = pixels[i];
swap(x.r, x.b);
Pixel a;
if (i != 0) a = pixels[i - 1];
if (i != 0)
a = pixels[i - 1];
const Pixel& 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);
@ -222,32 +224,37 @@ template<bool has_alpha, byte filter_type>
{
{
#ifdef PNG_STOPWATCH_DEBUG
Stopwatch sw("load_png_impl: unfilter: unpack");
Stopwatch sw("load_png_impl: unfilter: unpack");
#endif
// First unpack the scanlines to RGBA:
switch (context.color_type) {
case 2:
for (int y = 0; y < context.height; ++y) {
struct [[gnu::packed]] Triplet { byte r; byte g; byte b; };
auto* triplets = (Triplet*)context.scanlines[y].data.pointer();
for (int i = 0; i < context.width; ++i) {
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
pixel.r = triplets[i].r;
pixel.g = triplets[i].g;
pixel.b = triplets[i].b;
pixel.a = 0xff;
// First unpack the scanlines to RGBA:
switch (context.color_type) {
case 2:
for (int y = 0; y < context.height; ++y) {
struct [[gnu::packed]] Triplet
{
byte r;
byte g;
byte b;
};
auto* triplets = (Triplet*)context.scanlines[y].data.pointer();
for (int i = 0; i < context.width; ++i) {
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
pixel.r = triplets[i].r;
pixel.g = triplets[i].g;
pixel.b = triplets[i].b;
pixel.a = 0xff;
}
}
break;
case 6:
for (int y = 0; y < context.height; ++y) {
memcpy(context.bitmap->scanline(y), context.scanlines[y].data.pointer(), context.scanlines[y].data.size());
}
break;
default:
ASSERT_NOT_REACHED();
break;
}
break;
case 6:
for (int y = 0; y < context.height; ++y) {
memcpy(context.bitmap->scanline(y), context.scanlines[y].data.pointer(), context.scanlines[y].data.size());
}
break;
default:
ASSERT_NOT_REACHED();
break;
}
}
auto dummy_scanline = ByteBuffer::create_zeroed(context.width * sizeof(RGBA32));