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

Everywhere: Debug macros instead of constexpr.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
This commit is contained in:
asynts 2021-01-23 23:59:27 +01:00 committed by Andreas Kling
parent bb483f7ef4
commit 8465683dcf
98 changed files with 414 additions and 972 deletions

View file

@ -317,7 +317,7 @@ static u8 get_scaled_color(u32 data, u8 mask_size, i8 mask_shift)
// to scale the values in order to reach the proper value of 255.
static u32 int_to_scaled_rgb(BMPLoadingContext& context, u32 data)
{
dbgln<debug_bmp>("DIB info sizes before access: #masks={}, #mask_sizes={}, #mask_shifts={}",
dbgln<BMP_DEBUG>("DIB info sizes before access: #masks={}, #mask_sizes={}, #mask_shifts={}",
context.dib.info.masks.size(),
context.dib.info.mask_sizes.size(),
context.dib.info.mask_shifts.size());
@ -465,7 +465,7 @@ static bool decode_bmp_header(BMPLoadingContext& context)
return true;
if (!context.file_bytes || context.file_size < bmp_header_size) {
dbgln<debug_bmp>("Missing BMP header");
dbgln<BMP_DEBUG>("Missing BMP header");
context.state = BMPLoadingContext::State::Error;
return false;
}
@ -474,7 +474,7 @@ static bool decode_bmp_header(BMPLoadingContext& context)
u16 header = streamer.read_u16();
if (header != 0x4d42) {
dbgln<debug_bmp>("BMP has invalid magic header number: {:#04x}", header);
dbgln<BMP_DEBUG>("BMP has invalid magic header number: {:#04x}", header);
context.state = BMPLoadingContext::State::Error;
return false;
}
@ -490,13 +490,13 @@ static bool decode_bmp_header(BMPLoadingContext& context)
streamer.drop_bytes(4);
context.data_offset = streamer.read_u32();
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP file size: {}", context.file_size);
dbgln("BMP data offset: {}", context.data_offset);
}
if (context.data_offset >= context.file_size) {
dbgln<debug_bmp>("BMP data offset is beyond file end?!");
dbgln<BMP_DEBUG>("BMP data offset is beyond file end?!");
return false;
}
@ -549,7 +549,7 @@ static bool decode_bmp_core_dib(BMPLoadingContext& context, Streamer& streamer)
return false;
}
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP width: {}", core.width);
dbgln("BMP height: {}", core.height);
dbgln("BMP bits_per_pixel: {}", core.bpp);
@ -598,7 +598,7 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
return false;
}
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP width: {}", core.width);
dbgln("BMP height: {}", core.height);
dbgln("BMP bits_per_pixel: {}", core.bpp);
@ -638,7 +638,7 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
// ColorEncoding (4) + Identifier (4)
streamer.drop_bytes(8);
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP compression: {}", info.compression);
dbgln("BMP image size: {}", info.image_size);
dbgln("BMP horizontal res: {}", info.horizontal_resolution);
@ -678,7 +678,7 @@ static bool decode_bmp_info_dib(BMPLoadingContext& context, Streamer& streamer)
if (info.number_of_important_palette_colors == 0)
info.number_of_important_palette_colors = info.number_of_palette_colors;
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP compression: {}", info.compression);
dbgln("BMP image size: {}", info.image_size);
dbgln("BMP horizontal res: {}", info.horizontal_resolution);
@ -699,7 +699,7 @@ static bool decode_bmp_v2_dib(BMPLoadingContext& context, Streamer& streamer)
context.dib.info.masks.append(streamer.read_u32());
context.dib.info.masks.append(streamer.read_u32());
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP red mask: {:#08x}", context.dib.info.masks[0]);
dbgln("BMP green mask: {:#08x}", context.dib.info.masks[1]);
dbgln("BMP blue mask: {:#08x}", context.dib.info.masks[2]);
@ -719,12 +719,12 @@ static bool decode_bmp_v3_dib(BMPLoadingContext& context, Streamer& streamer)
// suite results.
if (context.dib.info.compression == Compression::ALPHABITFIELDS) {
context.dib.info.masks.append(streamer.read_u32());
dbgln<debug_bmp>("BMP alpha mask: {:#08x}", context.dib.info.masks[3]);
dbgln<BMP_DEBUG>("BMP alpha mask: {:#08x}", context.dib.info.masks[3]);
} else if (context.dib_size() >= 56 && context.dib.core.bpp >= 16) {
auto mask = streamer.read_u32();
if ((context.dib.core.bpp == 32 && mask != 0) || context.dib.core.bpp == 16) {
context.dib.info.masks.append(mask);
dbgln<debug_bmp>("BMP alpha mask: {:#08x}", mask);
dbgln<BMP_DEBUG>("BMP alpha mask: {:#08x}", mask);
}
} else {
streamer.drop_bytes(4);
@ -745,7 +745,7 @@ static bool decode_bmp_v4_dib(BMPLoadingContext& context, Streamer& streamer)
v4.blue_endpoint = { streamer.read_i32(), streamer.read_i32(), streamer.read_i32() };
v4.gamma_endpoint = { streamer.read_u32(), streamer.read_u32(), streamer.read_u32() };
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP color space: {}", v4.color_space);
dbgln("BMP red endpoint: {}", v4.red_endpoint);
dbgln("BMP green endpoint: {}", v4.green_endpoint);
@ -766,7 +766,7 @@ static bool decode_bmp_v5_dib(BMPLoadingContext& context, Streamer& streamer)
v5.profile_data = streamer.read_u32();
v5.profile_size = streamer.read_u32();
if constexpr (debug_bmp) {
if constexpr (BMP_DEBUG) {
dbgln("BMP intent: {}", v5.intent);
dbgln("BMP profile data: {}", v5.profile_data);
dbgln("BMP profile size: {}", v5.profile_size);
@ -801,7 +801,7 @@ static bool decode_bmp_dib(BMPLoadingContext& context)
streamer = Streamer(context.file_bytes + bmp_header_size + 4, context.data_offset - bmp_header_size - 4);
dbgln<debug_bmp>("BMP dib size: {}", dib_size);
dbgln<BMP_DEBUG>("BMP dib size: {}", dib_size);
bool error = false;
@ -931,7 +931,7 @@ static bool uncompress_bmp_rle_data(BMPLoadingContext& context, ByteBuffer& buff
{
// RLE-compressed images cannot be stored top-down
if (context.dib.core.height < 0) {
dbgln<debug_bmp>("BMP is top-down and RLE compressed");
dbgln<BMP_DEBUG>("BMP is top-down and RLE compressed");
context.state = BMPLoadingContext::State::Error;
return false;
}