1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:47:34 +00:00

LibGfx: Mark compilation-unit-only functions as static

This enables a nice warning in case a function becomes dead code.
This commit is contained in:
Ben Wiederhake 2020-08-11 00:09:28 +02:00 committed by Andreas Kling
parent e050f21f36
commit f2f0c22052
3 changed files with 20 additions and 22 deletions

View file

@ -186,12 +186,12 @@ RefPtr<Gfx::Bitmap> load_bmp(const StringView& path)
return bitmap; return bitmap;
} }
const LogStream& operator<<(const LogStream& out, Endpoint<i32> ep) static const LogStream& operator<<(const LogStream& out, Endpoint<i32> ep)
{ {
return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")"; return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")";
} }
const LogStream& operator<<(const LogStream& out, Endpoint<u32> ep) static const LogStream& operator<<(const LogStream& out, Endpoint<u32> ep)
{ {
return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")"; return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")";
} }
@ -254,7 +254,7 @@ private:
}; };
// Lookup table for distributing all possible 2-bit numbers evenly into 8-bit numbers // Lookup table for distributing all possible 2-bit numbers evenly into 8-bit numbers
u8 scaling_factors_2bit[4] = { static u8 scaling_factors_2bit[4] = {
0x00, 0x00,
0x55, 0x55,
0xaa, 0xaa,
@ -262,7 +262,7 @@ u8 scaling_factors_2bit[4] = {
}; };
// Lookup table for distributing all possible 3-bit numbers evenly into 8-bit numbers // Lookup table for distributing all possible 3-bit numbers evenly into 8-bit numbers
u8 scaling_factors_3bit[8] = { static u8 scaling_factors_3bit[8] = {
0x00, 0x00,
0x24, 0x24,
0x48, 0x48,
@ -273,7 +273,7 @@ u8 scaling_factors_3bit[8] = {
0xff, 0xff,
}; };
u8 scale_masked_8bit_number(u8 number, u8 bits_set) static u8 scale_masked_8bit_number(u8 number, u8 bits_set)
{ {
// If there are more than 4 bit set, an easy way to scale the number is to // If there are more than 4 bit set, an easy way to scale the number is to
// just copy the most significant bits into the least significant bits // just copy the most significant bits into the least significant bits
@ -288,7 +288,7 @@ u8 scale_masked_8bit_number(u8 number, u8 bits_set)
return scaling_factors_3bit[number >> 5]; return scaling_factors_3bit[number >> 5];
} }
u8 get_scaled_color(u32 data, u8 mask_size, i8 mask_shift) static u8 get_scaled_color(u32 data, u8 mask_size, i8 mask_shift)
{ {
// A negative mask_shift indicates we actually need to left shift // A negative mask_shift indicates we actually need to left shift
// the result in order to get out a valid 8-bit color (for example, the blue // the result in order to get out a valid 8-bit color (for example, the blue
@ -307,7 +307,7 @@ u8 get_scaled_color(u32 data, u8 mask_size, i8 mask_shift)
// consider, as an example, a 5 bit number (so the bottom 3 bits are ignored). // consider, as an example, a 5 bit number (so the bottom 3 bits are ignored).
// The purest white you could get is 0xf8, which is 248 in RGB-land. We need // The purest white you could get is 0xf8, which is 248 in RGB-land. We need
// to scale the values in order to reach the proper value of 255. // to scale the values in order to reach the proper value of 255.
u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data) static u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data)
{ {
u8 r = get_scaled_color(data & context.dib.info.masks[0], context.dib.info.mask_sizes[0], context.dib.info.mask_shifts[0]); u8 r = get_scaled_color(data & context.dib.info.masks[0], context.dib.info.mask_sizes[0], context.dib.info.mask_shifts[0]);
u8 g = get_scaled_color(data & context.dib.info.masks[1], context.dib.info.mask_sizes[1], context.dib.info.mask_shifts[1]); u8 g = get_scaled_color(data & context.dib.info.masks[1], context.dib.info.mask_sizes[1], context.dib.info.mask_shifts[1]);
@ -325,7 +325,7 @@ u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data)
return color; return color;
} }
void populate_dib_mask_info(BMPLoadingContext& context) static void populate_dib_mask_info(BMPLoadingContext& context)
{ {
if (context.dib.info.masks.is_empty()) if (context.dib.info.masks.is_empty())
return; return;
@ -592,7 +592,7 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
return true; return true;
} }
ALWAYS_INLINE bool is_supported_compression_format(BMPLoadingContext& context, u8 compression) ALWAYS_INLINE static bool is_supported_compression_format(BMPLoadingContext& context, u8 compression)
{ {
return compression == Compression::RGB || compression == Compression::BITFIELDS return compression == Compression::RGB || compression == Compression::BITFIELDS
|| compression == Compression::ALPHABITFIELDS || compression == Compression::RLE8 || compression == Compression::ALPHABITFIELDS || compression == Compression::RLE8

View file

@ -36,8 +36,6 @@
namespace Gfx { namespace Gfx {
static bool load_gif_frame_descriptors(GIFLoadingContext&);
struct RGB { struct RGB {
u8 r; u8 r;
u8 g; u8 g;
@ -117,7 +115,7 @@ enum class GIFFormat {
GIF89a, GIF89a,
}; };
Optional<GIFFormat> decode_gif_header(BufferStream& stream) static Optional<GIFFormat> decode_gif_header(BufferStream& stream)
{ {
static const char valid_header_87[] = "GIF87a"; static const char valid_header_87[] = "GIF87a";
static const char valid_header_89[] = "GIF89a"; static const char valid_header_89[] = "GIF89a";
@ -262,7 +260,7 @@ private:
Vector<u8> m_output {}; Vector<u8> m_output {};
}; };
bool decode_frames_up_to_index(GIFLoadingContext& context, size_t frame_index) static bool decode_frames_up_to_index(GIFLoadingContext& context, size_t frame_index)
{ {
if (frame_index >= context.images.size()) { if (frame_index >= context.images.size()) {
return false; return false;
@ -340,7 +338,7 @@ bool decode_frames_up_to_index(GIFLoadingContext& context, size_t frame_index)
return true; return true;
} }
bool load_gif_frame_descriptors(GIFLoadingContext& context) static bool load_gif_frame_descriptors(GIFLoadingContext& context)
{ {
if (context.data_size < 32) if (context.data_size < 32)
return false; return false;

View file

@ -220,7 +220,7 @@ struct JPGLoadingContext {
MacroblockMeta mblock_meta; MacroblockMeta mblock_meta;
}; };
void generate_huffman_codes(HuffmanTableSpec& table) static void generate_huffman_codes(HuffmanTableSpec& table)
{ {
unsigned code = 0; unsigned code = 0;
for (auto number_of_codes : table.code_counts) { for (auto number_of_codes : table.code_counts) {
@ -230,7 +230,7 @@ void generate_huffman_codes(HuffmanTableSpec& table)
} }
} }
Optional<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1) static Optional<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1)
{ {
if (count > (8 * sizeof(size_t))) { if (count > (8 * sizeof(size_t))) {
dbg() << String::format("Can't read %i bits at once!", count); dbg() << String::format("Can't read %i bits at once!", count);
@ -254,7 +254,7 @@ Optional<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1
return value; return value;
} }
Optional<u8> get_next_symbol(HuffmanStreamState& hstream, const HuffmanTableSpec& table) static Optional<u8> get_next_symbol(HuffmanStreamState& hstream, const HuffmanTableSpec& table)
{ {
unsigned code = 0; unsigned code = 0;
size_t code_cursor = 0; size_t code_cursor = 0;
@ -289,7 +289,7 @@ Optional<u8> get_next_symbol(HuffmanStreamState& hstream, const HuffmanTableSpec
* macroblocks that share the chrominance data. Next two iterations (assuming that * macroblocks that share the chrominance data. Next two iterations (assuming that
* we are dealing with three components) will fill up the blocks with chroma data. * we are dealing with three components) will fill up the blocks with chroma data.
*/ */
bool build_macroblocks(JPGLoadingContext& context, Vector<Macroblock>& macroblocks, u8 hcursor, u8 vcursor) static bool build_macroblocks(JPGLoadingContext& context, Vector<Macroblock>& macroblocks, u8 hcursor, u8 vcursor)
{ {
for (u32 cindex = 0; cindex < context.component_count; cindex++) { for (u32 cindex = 0; cindex < context.component_count; cindex++) {
auto& component = context.components[cindex]; auto& component = context.components[cindex];
@ -373,7 +373,7 @@ bool build_macroblocks(JPGLoadingContext& context, Vector<Macroblock>& macrobloc
return true; return true;
} }
Optional<Vector<Macroblock>> decode_huffman_stream(JPGLoadingContext& context) static Optional<Vector<Macroblock>> decode_huffman_stream(JPGLoadingContext& context)
{ {
Vector<Macroblock> macroblocks; Vector<Macroblock> macroblocks;
macroblocks.resize(context.mblock_meta.padded_total); macroblocks.resize(context.mblock_meta.padded_total);
@ -798,7 +798,7 @@ static bool skip_marker_with_length(BufferStream& stream)
return !stream.handle_read_failure(); return !stream.handle_read_failure();
} }
void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macroblocks) static void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macroblocks)
{ {
for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) { for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) { for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {
@ -819,7 +819,7 @@ void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macroblocks)
} }
} }
void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks) static void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks)
{ {
static const float m0 = 2.0 * cos(1.0 / 16.0 * 2.0 * M_PI); static const float m0 = 2.0 * cos(1.0 / 16.0 * 2.0 * M_PI);
static const float m1 = 2.0 * cos(2.0 / 16.0 * 2.0 * M_PI); static const float m1 = 2.0 * cos(2.0 / 16.0 * 2.0 * M_PI);
@ -986,7 +986,7 @@ void inverse_dct(const JPGLoadingContext& context, Vector<Macroblock>& macrobloc
} }
} }
void ycbcr_to_rgb(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks) static void ycbcr_to_rgb(const JPGLoadingContext& context, Vector<Macroblock>& macroblocks)
{ {
for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) { for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) { for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {