mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:17:44 +00:00
AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
This commit is contained in:
parent
c4c4bbc5ba
commit
27f699ef0c
208 changed files with 1603 additions and 1621 deletions
|
@ -4,9 +4,9 @@
|
|||
Color::Color(NamedColor named)
|
||||
{
|
||||
struct {
|
||||
byte r;
|
||||
byte g;
|
||||
byte b;
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
} rgb;
|
||||
|
||||
switch (named) {
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include <AK/AKString.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
typedef dword RGBA32;
|
||||
typedef u32 RGBA32;
|
||||
|
||||
inline constexpr dword make_rgb(byte r, byte g, byte b)
|
||||
inline constexpr u32 make_rgb(u8 r, u8 g, u8 b)
|
||||
{
|
||||
return ((r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ public:
|
|||
|
||||
Color() {}
|
||||
Color(NamedColor);
|
||||
Color(byte r, byte g, byte b)
|
||||
Color(u8 r, u8 g, u8 b)
|
||||
: m_value(0xff000000 | (r << 16) | (g << 8) | b)
|
||||
{
|
||||
}
|
||||
Color(byte r, byte g, byte b, byte a)
|
||||
Color(u8 r, u8 g, u8 b, u8 a)
|
||||
: m_value((a << 24) | (r << 16) | (g << 8) | b)
|
||||
{
|
||||
}
|
||||
|
@ -48,36 +48,36 @@ public:
|
|||
static Color from_rgb(unsigned rgb) { return Color(rgb | 0xff000000); }
|
||||
static Color from_rgba(unsigned rgba) { return Color(rgba); }
|
||||
|
||||
byte red() const { return (m_value >> 16) & 0xff; }
|
||||
byte green() const { return (m_value >> 8) & 0xff; }
|
||||
byte blue() const { return m_value & 0xff; }
|
||||
byte alpha() const { return (m_value >> 24) & 0xff; }
|
||||
u8 red() const { return (m_value >> 16) & 0xff; }
|
||||
u8 green() const { return (m_value >> 8) & 0xff; }
|
||||
u8 blue() const { return m_value & 0xff; }
|
||||
u8 alpha() const { return (m_value >> 24) & 0xff; }
|
||||
|
||||
void set_alpha(byte value)
|
||||
void set_alpha(u8 value)
|
||||
{
|
||||
m_value &= 0x00ffffff;
|
||||
m_value |= value << 24;
|
||||
}
|
||||
|
||||
void set_red(byte value)
|
||||
void set_red(u8 value)
|
||||
{
|
||||
m_value &= 0xff00ffff;
|
||||
m_value |= value << 16;
|
||||
}
|
||||
|
||||
void set_green(byte value)
|
||||
void set_green(u8 value)
|
||||
{
|
||||
m_value &= 0xffff00ff;
|
||||
m_value |= value << 8;
|
||||
}
|
||||
|
||||
void set_blue(byte value)
|
||||
void set_blue(u8 value)
|
||||
{
|
||||
m_value &= 0xffffff00;
|
||||
m_value |= value;
|
||||
}
|
||||
|
||||
Color with_alpha(byte alpha)
|
||||
Color with_alpha(u8 alpha)
|
||||
{
|
||||
return Color((m_value & 0x00ffffff) | alpha << 24);
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ public:
|
|||
return *this;
|
||||
|
||||
int d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha();
|
||||
byte r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
|
||||
byte g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
|
||||
byte b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
|
||||
byte a = d / 255;
|
||||
u8 r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
|
||||
u8 g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
|
||||
u8 b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
|
||||
u8 a = d / 255;
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
struct [[gnu::packed]] FontFileHeader
|
||||
{
|
||||
char magic[4];
|
||||
byte glyph_width;
|
||||
byte glyph_height;
|
||||
byte type;
|
||||
byte is_variable_width;
|
||||
byte unused[6];
|
||||
u8 glyph_width;
|
||||
u8 glyph_height;
|
||||
u8 type;
|
||||
u8 is_variable_width;
|
||||
u8 unused[6];
|
||||
char name[64];
|
||||
};
|
||||
|
||||
|
@ -55,11 +55,11 @@ Font& Font::default_bold_font()
|
|||
|
||||
RefPtr<Font> Font::clone() const
|
||||
{
|
||||
size_t bytes_per_glyph = sizeof(dword) * glyph_height();
|
||||
size_t bytes_per_glyph = sizeof(u32) * glyph_height();
|
||||
// FIXME: This is leaked!
|
||||
auto* new_rows = static_cast<unsigned*>(kmalloc(bytes_per_glyph * 256));
|
||||
memcpy(new_rows, m_rows, bytes_per_glyph * 256);
|
||||
auto* new_widths = static_cast<byte*>(kmalloc(256));
|
||||
auto* new_widths = static_cast<u8*>(kmalloc(256));
|
||||
if (m_glyph_widths)
|
||||
memcpy(new_widths, m_glyph_widths, 256);
|
||||
else
|
||||
|
@ -67,7 +67,7 @@ RefPtr<Font> Font::clone() const
|
|||
return adopt(*new Font(m_name, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height));
|
||||
}
|
||||
|
||||
Font::Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_width, byte glyph_width, byte glyph_height)
|
||||
Font::Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height)
|
||||
: m_name(name)
|
||||
, m_rows(rows)
|
||||
, m_glyph_widths(widths)
|
||||
|
@ -78,8 +78,8 @@ Font::Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_w
|
|||
, m_fixed_width(is_fixed_width)
|
||||
{
|
||||
if (!m_fixed_width) {
|
||||
byte maximum = 0;
|
||||
byte minimum = 255;
|
||||
u8 maximum = 0;
|
||||
u8 minimum = 255;
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
minimum = min(minimum, m_glyph_widths[i]);
|
||||
maximum = max(maximum, m_glyph_widths[i]);
|
||||
|
@ -93,7 +93,7 @@ Font::~Font()
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<Font> Font::load_from_memory(const byte* data)
|
||||
RefPtr<Font> Font::load_from_memory(const u8* data)
|
||||
{
|
||||
auto& header = *reinterpret_cast<const FontFileHeader*>(data);
|
||||
if (memcmp(header.magic, "!Fnt", 4)) {
|
||||
|
@ -108,9 +108,9 @@ RefPtr<Font> Font::load_from_memory(const byte* data)
|
|||
size_t bytes_per_glyph = sizeof(unsigned) * header.glyph_height;
|
||||
|
||||
auto* rows = const_cast<unsigned*>((const unsigned*)(data + sizeof(FontFileHeader)));
|
||||
byte* widths = nullptr;
|
||||
u8* widths = nullptr;
|
||||
if (header.is_variable_width)
|
||||
widths = (byte*)(rows) + 256 * bytes_per_glyph;
|
||||
widths = (u8*)(rows) + 256 * bytes_per_glyph;
|
||||
return adopt(*new Font(String(header.name), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height));
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ RefPtr<Font> Font::load_from_file(const StringView& path)
|
|||
if (!mapped_file.is_valid())
|
||||
return nullptr;
|
||||
|
||||
auto font = load_from_memory((const byte*)mapped_file.pointer());
|
||||
auto font = load_from_memory((const u8*)mapped_file.pointer());
|
||||
font->m_mapped_file = move(mapped_file);
|
||||
return font;
|
||||
}
|
||||
|
|
|
@ -54,13 +54,13 @@ public:
|
|||
|
||||
~Font();
|
||||
|
||||
GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(byte)ch * m_glyph_height], { glyph_width(ch), m_glyph_height }); }
|
||||
GlyphBitmap glyph_bitmap(char ch) const { return GlyphBitmap(&m_rows[(u8)ch * m_glyph_height], { glyph_width(ch), m_glyph_height }); }
|
||||
|
||||
byte glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(byte)ch]; }
|
||||
byte glyph_height() const { return m_glyph_height; }
|
||||
byte min_glyph_width() const { return m_min_glyph_width; }
|
||||
byte max_glyph_width() const { return m_max_glyph_width; }
|
||||
byte glyph_spacing() const { return m_fixed_width ? 0 : 1; }
|
||||
u8 glyph_width(char ch) const { return m_fixed_width ? m_glyph_width : m_glyph_widths[(u8)ch]; }
|
||||
u8 glyph_height() const { return m_glyph_height; }
|
||||
u8 min_glyph_width() const { return m_min_glyph_width; }
|
||||
u8 max_glyph_width() const { return m_max_glyph_width; }
|
||||
u8 glyph_spacing() const { return m_fixed_width ? 0 : 1; }
|
||||
int width(const StringView& string) const;
|
||||
|
||||
String name() const { return m_name; }
|
||||
|
@ -69,27 +69,27 @@ public:
|
|||
bool is_fixed_width() const { return m_fixed_width; }
|
||||
void set_fixed_width(bool b) { m_fixed_width = b; }
|
||||
|
||||
void set_glyph_width(char ch, byte width)
|
||||
void set_glyph_width(char ch, u8 width)
|
||||
{
|
||||
ASSERT(m_glyph_widths);
|
||||
m_glyph_widths[(byte)ch] = width;
|
||||
m_glyph_widths[(u8)ch] = width;
|
||||
}
|
||||
|
||||
private:
|
||||
Font(const StringView& name, unsigned* rows, byte* widths, bool is_fixed_width, byte glyph_width, byte glyph_height);
|
||||
Font(const StringView& name, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height);
|
||||
|
||||
static RefPtr<Font> load_from_memory(const byte*);
|
||||
static RefPtr<Font> load_from_memory(const u8*);
|
||||
|
||||
String m_name;
|
||||
|
||||
unsigned* m_rows { nullptr };
|
||||
byte* m_glyph_widths { nullptr };
|
||||
u8* m_glyph_widths { nullptr };
|
||||
MappedFile m_mapped_file;
|
||||
|
||||
byte m_glyph_width { 0 };
|
||||
byte m_glyph_height { 0 };
|
||||
byte m_min_glyph_width { 0 };
|
||||
byte m_max_glyph_width { 0 };
|
||||
u8 m_glyph_width { 0 };
|
||||
u8 m_glyph_height { 0 };
|
||||
u8 m_min_glyph_width { 0 };
|
||||
u8 m_max_glyph_width { 0 };
|
||||
|
||||
bool m_fixed_width { false };
|
||||
};
|
||||
|
|
|
@ -97,6 +97,6 @@ void GraphicsBitmap::fill(Color color)
|
|||
ASSERT(m_format == GraphicsBitmap::Format::RGB32 || m_format == GraphicsBitmap::Format::RGBA32);
|
||||
for (int y = 0; y < height(); ++y) {
|
||||
auto* scanline = this->scanline(y);
|
||||
fast_dword_fill(scanline, color.value(), width());
|
||||
fast_u32_fill(scanline, color.value(), width());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ public:
|
|||
RGBA32* scanline(int y);
|
||||
const RGBA32* scanline(int y) const;
|
||||
|
||||
byte* bits(int y);
|
||||
const byte* bits(int y) const;
|
||||
u8* bits(int y);
|
||||
const u8* bits(int y) const;
|
||||
|
||||
Rect rect() const { return { {}, m_size }; }
|
||||
Size size() const { return m_size; }
|
||||
|
@ -63,8 +63,8 @@ public:
|
|||
|
||||
size_t size_in_bytes() const { return m_pitch * m_size.height(); }
|
||||
|
||||
Color palette_color(byte index) const { return Color::from_rgba(m_palette[index]); }
|
||||
void set_palette_color(byte index, Color color) { m_palette[index] = color.value(); }
|
||||
Color palette_color(u8 index) const { return Color::from_rgba(m_palette[index]); }
|
||||
void set_palette_color(u8 index, Color color) { m_palette[index] = color.value(); }
|
||||
|
||||
template<Format>
|
||||
Color get_pixel(int x, int y) const
|
||||
|
@ -110,22 +110,22 @@ private:
|
|||
|
||||
inline RGBA32* GraphicsBitmap::scanline(int y)
|
||||
{
|
||||
return reinterpret_cast<RGBA32*>((((byte*)m_data) + (y * m_pitch)));
|
||||
return reinterpret_cast<RGBA32*>((((u8*)m_data) + (y * m_pitch)));
|
||||
}
|
||||
|
||||
inline const RGBA32* GraphicsBitmap::scanline(int y) const
|
||||
{
|
||||
return reinterpret_cast<const RGBA32*>((((const byte*)m_data) + (y * m_pitch)));
|
||||
return reinterpret_cast<const RGBA32*>((((const u8*)m_data) + (y * m_pitch)));
|
||||
}
|
||||
|
||||
inline const byte* GraphicsBitmap::bits(int y) const
|
||||
inline const u8* GraphicsBitmap::bits(int y) const
|
||||
{
|
||||
return reinterpret_cast<const byte*>(scanline(y));
|
||||
return reinterpret_cast<const u8*>(scanline(y));
|
||||
}
|
||||
|
||||
inline byte* GraphicsBitmap::bits(int y)
|
||||
inline u8* GraphicsBitmap::bits(int y)
|
||||
{
|
||||
return reinterpret_cast<byte*>(scanline(y));
|
||||
return reinterpret_cast<u8*>(scanline(y));
|
||||
}
|
||||
|
||||
template<>
|
||||
|
|
|
@ -14,43 +14,43 @@
|
|||
//#define PNG_STOPWATCH_DEBUG
|
||||
|
||||
struct PNG_IHDR {
|
||||
NetworkOrdered<dword> width;
|
||||
NetworkOrdered<dword> height;
|
||||
byte bit_depth { 0 };
|
||||
byte color_type { 0 };
|
||||
byte compression_method { 0 };
|
||||
byte filter_method { 0 };
|
||||
byte interlace_method { 0 };
|
||||
NetworkOrdered<u32> width;
|
||||
NetworkOrdered<u32> height;
|
||||
u8 bit_depth { 0 };
|
||||
u8 color_type { 0 };
|
||||
u8 compression_method { 0 };
|
||||
u8 filter_method { 0 };
|
||||
u8 interlace_method { 0 };
|
||||
};
|
||||
|
||||
static_assert(sizeof(PNG_IHDR) == 13);
|
||||
|
||||
struct Scanline {
|
||||
byte filter { 0 };
|
||||
u8 filter { 0 };
|
||||
ByteBuffer data { };
|
||||
};
|
||||
|
||||
struct PNGLoadingContext {
|
||||
int width { -1 };
|
||||
int height { -1 };
|
||||
byte bit_depth { 0 };
|
||||
byte color_type { 0 };
|
||||
byte compression_method { 0 };
|
||||
byte filter_method { 0 };
|
||||
byte interlace_method { 0 };
|
||||
byte bytes_per_pixel { 0 };
|
||||
u8 bit_depth { 0 };
|
||||
u8 color_type { 0 };
|
||||
u8 compression_method { 0 };
|
||||
u8 filter_method { 0 };
|
||||
u8 interlace_method { 0 };
|
||||
u8 bytes_per_pixel { 0 };
|
||||
bool has_seen_zlib_header { false };
|
||||
bool has_alpha() const { return color_type & 4; }
|
||||
Vector<Scanline> scanlines;
|
||||
RefPtr<GraphicsBitmap> bitmap;
|
||||
byte* decompression_buffer { nullptr };
|
||||
u8* decompression_buffer { nullptr };
|
||||
int decompression_buffer_size { 0 };
|
||||
Vector<byte> compressed_data;
|
||||
Vector<u8> compressed_data;
|
||||
};
|
||||
|
||||
class Streamer {
|
||||
public:
|
||||
Streamer(const byte* data, int size)
|
||||
Streamer(const u8* data, int size)
|
||||
: m_original_data(data)
|
||||
, m_original_size(size)
|
||||
, m_data_ptr(data)
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool read_bytes(byte* buffer, int count)
|
||||
bool read_bytes(u8* buffer, int count)
|
||||
{
|
||||
if (m_size_remaining < count)
|
||||
return false;
|
||||
|
@ -92,13 +92,13 @@ public:
|
|||
bool at_end() const { return !m_size_remaining; }
|
||||
|
||||
private:
|
||||
const byte* m_original_data;
|
||||
const u8* m_original_data;
|
||||
int m_original_size;
|
||||
const byte* m_data_ptr;
|
||||
const u8* m_data_ptr;
|
||||
int m_size_remaining;
|
||||
};
|
||||
|
||||
static RefPtr<GraphicsBitmap> load_png_impl(const byte*, int);
|
||||
static RefPtr<GraphicsBitmap> load_png_impl(const u8*, int);
|
||||
static bool process_chunk(Streamer&, PNGLoadingContext& context);
|
||||
|
||||
RefPtr<GraphicsBitmap> load_png(const StringView& path)
|
||||
|
@ -106,13 +106,13 @@ RefPtr<GraphicsBitmap> load_png(const StringView& path)
|
|||
MappedFile mapped_file(path);
|
||||
if (!mapped_file.is_valid())
|
||||
return nullptr;
|
||||
auto bitmap = load_png_impl((const byte*)mapped_file.pointer(), mapped_file.size());
|
||||
auto bitmap = load_png_impl((const u8*)mapped_file.pointer(), mapped_file.size());
|
||||
if (bitmap)
|
||||
bitmap->set_mmap_name(String::format("GraphicsBitmap [%dx%d] - Decoded PNG: %s", bitmap->width(), bitmap->height(), FileSystemPath(path).string().characters()));
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] static inline byte paeth_predictor(int a, int b, int c)
|
||||
[[gnu::always_inline]] static inline u8 paeth_predictor(int a, int b, int c)
|
||||
{
|
||||
int p = a + b - c;
|
||||
int pa = abs(p - a);
|
||||
|
@ -128,17 +128,17 @@ RefPtr<GraphicsBitmap> load_png(const StringView& path)
|
|||
union [[gnu::packed]] Pixel
|
||||
{
|
||||
RGBA32 rgba { 0 };
|
||||
byte v[4];
|
||||
u8 v[4];
|
||||
struct {
|
||||
byte r;
|
||||
byte g;
|
||||
byte b;
|
||||
byte a;
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
u8 a;
|
||||
};
|
||||
};
|
||||
static_assert(sizeof(Pixel) == 4);
|
||||
|
||||
template<bool has_alpha, byte filter_type>
|
||||
template<bool has_alpha, u8 filter_type>
|
||||
[[gnu::always_inline]] static inline void unfilter_impl(GraphicsBitmap& bitmap, int y, const void* dummy_scanline_data)
|
||||
{
|
||||
auto* dummy_scanline = (const Pixel*)dummy_scanline_data;
|
||||
|
@ -232,9 +232,9 @@ template<bool has_alpha, byte filter_type>
|
|||
for (int y = 0; y < context.height; ++y) {
|
||||
struct [[gnu::packed]] Triplet
|
||||
{
|
||||
byte r;
|
||||
byte g;
|
||||
byte b;
|
||||
u8 r;
|
||||
u8 g;
|
||||
u8 b;
|
||||
};
|
||||
auto* triplets = (Triplet*)context.scanlines[y].data.pointer();
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
|
@ -302,15 +302,15 @@ template<bool has_alpha, byte filter_type>
|
|||
}
|
||||
}
|
||||
|
||||
static RefPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size)
|
||||
static RefPtr<GraphicsBitmap> load_png_impl(const u8* data, int data_size)
|
||||
{
|
||||
#ifdef PNG_STOPWATCH_DEBUG
|
||||
Stopwatch sw("load_png_impl: total");
|
||||
#endif
|
||||
const byte* data_ptr = data;
|
||||
const u8* data_ptr = data;
|
||||
int data_remaining = data_size;
|
||||
|
||||
const byte png_header[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
|
||||
const u8 png_header[8] = { 0x89, 'P', 'N', 'G', 13, 10, 26, 10 };
|
||||
if (memcmp(data, png_header, sizeof(png_header))) {
|
||||
dbgprintf("Invalid PNG header\n");
|
||||
return nullptr;
|
||||
|
@ -354,7 +354,7 @@ static RefPtr<GraphicsBitmap> load_png_impl(const byte* data, int data_size)
|
|||
context.scanlines.ensure_capacity(context.height);
|
||||
Streamer streamer(context.decompression_buffer, context.decompression_buffer_size);
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
byte filter;
|
||||
u8 filter;
|
||||
if (!streamer.read(filter))
|
||||
return nullptr;
|
||||
|
||||
|
@ -412,7 +412,7 @@ static bool process_IHDR(const ByteBuffer& data, PNGLoadingContext& context)
|
|||
#endif
|
||||
|
||||
context.decompression_buffer_size = (context.width * context.height * context.bytes_per_pixel + context.height);
|
||||
context.decompression_buffer = (byte*)mmap_with_name(nullptr, context.decompression_buffer_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, "PNG decompression buffer");
|
||||
context.decompression_buffer = (u8*)mmap_with_name(nullptr, context.decompression_buffer_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, "PNG decompression buffer");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -424,12 +424,12 @@ static bool process_IDAT(const ByteBuffer& data, PNGLoadingContext& context)
|
|||
|
||||
static bool process_chunk(Streamer& streamer, PNGLoadingContext& context)
|
||||
{
|
||||
dword chunk_size;
|
||||
u32 chunk_size;
|
||||
if (!streamer.read(chunk_size)) {
|
||||
printf("Bail at chunk_size\n");
|
||||
return false;
|
||||
}
|
||||
byte chunk_type[5];
|
||||
u8 chunk_type[5];
|
||||
chunk_type[4] = '\0';
|
||||
if (!streamer.read_bytes(chunk_type, 4)) {
|
||||
printf("Bail at chunk_type\n");
|
||||
|
@ -440,7 +440,7 @@ static bool process_chunk(Streamer& streamer, PNGLoadingContext& context)
|
|||
printf("Bail at chunk_data\n");
|
||||
return false;
|
||||
}
|
||||
dword chunk_crc;
|
||||
u32 chunk_crc;
|
||||
if (!streamer.read(chunk_crc)) {
|
||||
printf("Bail at chunk_crc\n");
|
||||
return false;
|
||||
|
|
|
@ -69,7 +69,7 @@ void Painter::fill_rect(const Rect& a_rect, Color color)
|
|||
const size_t dst_skip = m_target->pitch() / sizeof(RGBA32);
|
||||
|
||||
for (int i = rect.height() - 1; i >= 0; --i) {
|
||||
fast_dword_fill(dst, color.value(), rect.width());
|
||||
fast_u32_fill(dst, color.value(), rect.width());
|
||||
dst += dst_skip;
|
||||
}
|
||||
}
|
||||
|
@ -125,13 +125,13 @@ void Painter::draw_rect(const Rect& a_rect, Color color, bool rough)
|
|||
if (rect.top() >= clipped_rect.top() && rect.top() <= clipped_rect.bottom()) {
|
||||
int start_x = rough ? max(rect.x() + 1, clipped_rect.x()) : clipped_rect.x();
|
||||
int width = rough ? min(rect.width() - 2, clipped_rect.width()) : clipped_rect.width();
|
||||
fast_dword_fill(m_target->scanline(rect.top()) + start_x, color.value(), width);
|
||||
fast_u32_fill(m_target->scanline(rect.top()) + start_x, color.value(), width);
|
||||
++min_y;
|
||||
}
|
||||
if (rect.bottom() >= clipped_rect.top() && rect.bottom() <= clipped_rect.bottom()) {
|
||||
int start_x = rough ? max(rect.x() + 1, clipped_rect.x()) : clipped_rect.x();
|
||||
int width = rough ? min(rect.width() - 2, clipped_rect.width()) : clipped_rect.width();
|
||||
fast_dword_fill(m_target->scanline(rect.bottom()) + start_x, color.value(), width);
|
||||
fast_u32_fill(m_target->scanline(rect.bottom()) + start_x, color.value(), width);
|
||||
--max_y;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ void Painter::blit_with_opacity(const Point& position, const GraphicsBitmap& sou
|
|||
if (opacity >= 1.0f)
|
||||
return blit(position, source, src_rect);
|
||||
|
||||
byte alpha = 255 * opacity;
|
||||
u8 alpha = 255 * opacity;
|
||||
|
||||
Rect safe_src_rect = Rect::intersection(src_rect, source.rect());
|
||||
Rect dst_rect(position, safe_src_rect.size());
|
||||
|
@ -290,7 +290,7 @@ void Painter::blit_dimmed(const Point& position, const GraphicsBitmap& source, c
|
|||
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
for (int x = 0; x <= (last_column - first_column); ++x) {
|
||||
byte alpha = Color::from_rgba(src[x]).alpha();
|
||||
u8 alpha = Color::from_rgba(src[x]).alpha();
|
||||
if (alpha == 0xff)
|
||||
dst[x] = Color::from_rgba(src[x]).to_grayscale().lightened().value();
|
||||
else if (!alpha)
|
||||
|
@ -387,7 +387,7 @@ void Painter::blit_with_alpha(const Point& position, const GraphicsBitmap& sourc
|
|||
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
for (int x = 0; x <= (last_column - first_column); ++x) {
|
||||
byte alpha = Color::from_rgba(src[x]).alpha();
|
||||
u8 alpha = Color::from_rgba(src[x]).alpha();
|
||||
if (alpha == 0xff)
|
||||
dst[x] = src[x];
|
||||
else if (!alpha)
|
||||
|
@ -422,7 +422,7 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source, const Re
|
|||
const RGBA32* src = source.scanline(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const size_t src_skip = source.pitch() / sizeof(RGBA32);
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
fast_dword_copy(dst, src, clipped_rect.width());
|
||||
fast_u32_copy(dst, src, clipped_rect.width());
|
||||
dst += dst_skip;
|
||||
src += src_skip;
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ void Painter::blit(const Point& position, const GraphicsBitmap& source, const Re
|
|||
}
|
||||
|
||||
if (source.format() == GraphicsBitmap::Format::Indexed8) {
|
||||
const byte* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const u8* src = source.bits(src_rect.top() + first_row) + src_rect.left() + first_column;
|
||||
const size_t src_skip = source.pitch();
|
||||
for (int row = first_row; row <= last_row; ++row) {
|
||||
for (int i = 0; i < clipped_rect.width(); ++i)
|
||||
|
@ -628,7 +628,7 @@ void Painter::set_pixel(const Point& p, Color color)
|
|||
m_target->scanline(point.y())[point.x()] = color.value();
|
||||
}
|
||||
|
||||
[[gnu::always_inline]] inline void Painter::set_pixel_with_draw_op(dword& pixel, const Color& color)
|
||||
[[gnu::always_inline]] inline void Painter::set_pixel_with_draw_op(u32& pixel, const Color& color)
|
||||
{
|
||||
if (draw_op() == DrawOp::Copy)
|
||||
pixel = color.value();
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void set_pixel_with_draw_op(dword& pixel, const Color&);
|
||||
void set_pixel_with_draw_op(u32& pixel, const Color&);
|
||||
void fill_rect_with_draw_op(const Rect&, Color);
|
||||
void blit_with_alpha(const Point&, const GraphicsBitmap&, const Rect& src_rect);
|
||||
void blit_with_opacity(const Point&, const GraphicsBitmap&, const Rect& src_rect, float opacity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue