summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bmp/image_loader_bmp.cpp67
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.h4
-rw-r--r--modules/mono/editor/bindings_generator.cpp24
-rw-r--r--modules/navigation/nav_base.h2
-rw-r--r--modules/text_server_adv/text_server_adv.h2
-rw-r--r--modules/text_server_fb/text_server_fb.h2
6 files changed, 27 insertions, 74 deletions
diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp
index 72b540496d..1804d73a69 100644
--- a/modules/bmp/image_loader_bmp.cpp
+++ b/modules/bmp/image_loader_bmp.cpp
@@ -59,30 +59,6 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
size_t height = (size_t)p_header.bmp_info_header.bmp_height;
size_t bits_per_pixel = (size_t)p_header.bmp_info_header.bmp_bit_count;
- // Check whether we can load it
-
- if (bits_per_pixel == 1) {
- // Requires bit unpacking...
- ERR_FAIL_COND_V_MSG(width % 8 != 0, ERR_UNAVAILABLE,
- vformat("1-bpp BMP images must have a width that is a multiple of 8, but the imported BMP is %d pixels wide.", int(width)));
- ERR_FAIL_COND_V_MSG(height % 8 != 0, ERR_UNAVAILABLE,
- vformat("1-bpp BMP images must have a height that is a multiple of 8, but the imported BMP is %d pixels tall.", int(height)));
-
- } else if (bits_per_pixel == 2) {
- // Requires bit unpacking...
- ERR_FAIL_COND_V_MSG(width % 4 != 0, ERR_UNAVAILABLE,
- vformat("2-bpp BMP images must have a width that is a multiple of 4, but the imported BMP is %d pixels wide.", int(width)));
- ERR_FAIL_COND_V_MSG(height % 4 != 0, ERR_UNAVAILABLE,
- vformat("2-bpp BMP images must have a height that is a multiple of 4, but the imported BMP is %d pixels tall.", int(height)));
-
- } else if (bits_per_pixel == 4) {
- // Requires bit unpacking...
- ERR_FAIL_COND_V_MSG(width % 2 != 0, ERR_UNAVAILABLE,
- vformat("4-bpp BMP images must have a width that is a multiple of 2, but the imported BMP is %d pixels wide.", int(width)));
- ERR_FAIL_COND_V_MSG(height % 2 != 0, ERR_UNAVAILABLE,
- vformat("4-bpp BMP images must have a height that is a multiple of 2, but the imported BMP is %d pixels tall.", int(height)));
- }
-
// Image data (might be indexed)
Vector<uint8_t> data;
int data_len = 0;
@@ -98,55 +74,32 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image,
uint8_t *data_w = data.ptrw();
uint8_t *write_buffer = data_w;
- const uint32_t width_bytes = width * bits_per_pixel / 8;
- const uint32_t line_width = (width_bytes + 3) & ~3;
+ const uint32_t width_bytes = (width * bits_per_pixel + 7) / 8;
+ const uint32_t line_width = (width_bytes + 3) & ~3; // Padded to 4 bytes.
- // The actual data traversal is determined by
- // the data width in case of 8/4/2/1 bit images
- const uint32_t w = bits_per_pixel >= 16 ? width : width_bytes;
const uint8_t *line = p_buffer + (line_width * (height - 1));
const uint8_t *end_buffer = p_buffer + p_header.bmp_file_header.bmp_file_size - p_header.bmp_file_header.bmp_file_offset;
+ ERR_FAIL_COND_V(line + line_width > end_buffer, ERR_FILE_CORRUPT);
for (uint64_t i = 0; i < height; i++) {
const uint8_t *line_ptr = line;
- for (unsigned int j = 0; j < w; j++) {
- ERR_FAIL_COND_V(line_ptr >= end_buffer, ERR_FILE_CORRUPT);
+ for (unsigned int j = 0; j < width; j++) {
switch (bits_per_pixel) {
case 1: {
- uint8_t color_index = *line_ptr;
+ write_buffer[index] = (line[(j * bits_per_pixel) / 8] >> (8 - bits_per_pixel * (1 + j % 8))) & 0x01;
- write_buffer[index + 0] = (color_index >> 7) & 1;
- write_buffer[index + 1] = (color_index >> 6) & 1;
- write_buffer[index + 2] = (color_index >> 5) & 1;
- write_buffer[index + 3] = (color_index >> 4) & 1;
- write_buffer[index + 4] = (color_index >> 3) & 1;
- write_buffer[index + 5] = (color_index >> 2) & 1;
- write_buffer[index + 6] = (color_index >> 1) & 1;
- write_buffer[index + 7] = (color_index >> 0) & 1;
-
- index += 8;
- line_ptr += 1;
+ index++;
} break;
case 2: {
- uint8_t color_index = *line_ptr;
+ write_buffer[index] = (line[(j * bits_per_pixel) / 8] >> (8 - bits_per_pixel * (1 + j % 4))) & 0x03;
- write_buffer[index + 0] = (color_index >> 6) & 3;
- write_buffer[index + 1] = (color_index >> 4) & 3;
- write_buffer[index + 2] = (color_index >> 2) & 3;
- write_buffer[index + 3] = color_index & 3;
-
- index += 4;
- line_ptr += 1;
+ index++;
} break;
case 4: {
- uint8_t color_index = *line_ptr;
-
- write_buffer[index + 0] = (color_index >> 4) & 0x0f;
- write_buffer[index + 1] = color_index & 0x0f;
+ write_buffer[index] = (line[(j * bits_per_pixel) / 8] >> (8 - bits_per_pixel * (1 + j % 2))) & 0x0f;
- index += 2;
- line_ptr += 1;
+ index++;
} break;
case 8: {
uint8_t color_index = *line_ptr;
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.h b/modules/gdscript/language_server/gdscript_extend_parser.h
index a808f19e5b..239f7d9f43 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.h
+++ b/modules/gdscript/language_server/gdscript_extend_parser.h
@@ -37,10 +37,10 @@
#include "core/variant/variant.h"
#ifndef LINE_NUMBER_TO_INDEX
-#define LINE_NUMBER_TO_INDEX(p_line) ((p_line)-1)
+#define LINE_NUMBER_TO_INDEX(p_line) ((p_line) - 1)
#endif
#ifndef COLUMN_NUMBER_TO_INDEX
-#define COLUMN_NUMBER_TO_INDEX(p_column) ((p_column)-1)
+#define COLUMN_NUMBER_TO_INDEX(p_column) ((p_column) - 1)
#endif
#ifndef SYMBOL_SEPERATOR
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 3222c58c4e..d0adf39fb2 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -1452,7 +1452,7 @@ Error BindingsGenerator::_populate_method_icalls_table(const TypeInterface &p_it
}
const TypeInterface *return_type = _get_type_or_null(imethod.return_type);
- ERR_FAIL_NULL_V(return_type, ERR_BUG); // Return type not found
+ ERR_FAIL_NULL_V_MSG(return_type, ERR_BUG, "Return type '" + imethod.return_type.cname + "' was not found.");
String im_unique_sig = get_ret_unique_sig(return_type) + ",CallMethodBind";
@@ -1463,7 +1463,7 @@ Error BindingsGenerator::_populate_method_icalls_table(const TypeInterface &p_it
// Get arguments information
for (const ArgumentInterface &iarg : imethod.arguments) {
const TypeInterface *arg_type = _get_type_or_null(iarg.type);
- ERR_FAIL_NULL_V(arg_type, ERR_BUG); // Argument type not found
+ ERR_FAIL_NULL_V_MSG(arg_type, ERR_BUG, "Argument type '" + iarg.type.cname + "' was not found.");
im_unique_sig += ",";
im_unique_sig += get_arg_unique_sig(*arg_type);
@@ -2313,7 +2313,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
const ArgumentInterface &iarg = *itr;
const TypeInterface *arg_type = _get_type_or_null(iarg.type);
- ERR_FAIL_NULL_V(arg_type, ERR_BUG); // Argument type not found
+ ERR_FAIL_NULL_V_MSG(arg_type, ERR_BUG, "Argument type '" + iarg.type.cname + "' was not found.");
if (i != 0) {
output << ", ";
@@ -2333,7 +2333,7 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
if (imethod.return_type.cname != name_cache.type_void) {
const TypeInterface *return_type = _get_type_or_null(imethod.return_type);
- ERR_FAIL_NULL_V(return_type, ERR_BUG); // Return type not found
+ ERR_FAIL_NULL_V_MSG(return_type, ERR_BUG, "Return type '" + imethod.return_type.cname + "' was not found.");
output << INDENT3 "ret = "
<< sformat(return_type->cs_managed_to_variant, "callRet", return_type->cs_type, return_type->name)
@@ -2552,7 +2552,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
const TypeReference &proptype_name = getter ? getter->return_type : setter->arguments.back()->get().type;
const TypeInterface *prop_itype = _get_type_or_singleton_or_null(proptype_name);
- ERR_FAIL_NULL_V(prop_itype, ERR_BUG); // Property type not found
+ ERR_FAIL_NULL_V_MSG(prop_itype, ERR_BUG, "Property type '" + proptype_name.cname + "' was not found.");
ERR_FAIL_COND_V_MSG(prop_itype->is_singleton, ERR_BUG,
"Property type is a singleton: '" + p_itype.name + "." + String(p_iprop.cname) + "'.");
@@ -2651,7 +2651,7 @@ Error BindingsGenerator::_generate_cs_property(const BindingsGenerator::TypeInte
Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterface &p_itype, const BindingsGenerator::MethodInterface &p_imethod, int &p_method_bind_count, StringBuilder &p_output) {
const TypeInterface *return_type = _get_type_or_singleton_or_null(p_imethod.return_type);
- ERR_FAIL_NULL_V(return_type, ERR_BUG); // Return type not found
+ ERR_FAIL_NULL_V_MSG(return_type, ERR_BUG, "Return type '" + p_imethod.return_type.cname + "' was not found.");
ERR_FAIL_COND_V_MSG(return_type->is_singleton, ERR_BUG,
"Method return type is a singleton: '" + p_itype.name + "." + p_imethod.name + "'.");
@@ -2690,7 +2690,7 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf
const ArgumentInterface &first = p_imethod.arguments.front()->get();
for (const ArgumentInterface &iarg : p_imethod.arguments) {
const TypeInterface *arg_type = _get_type_or_singleton_or_null(iarg.type);
- ERR_FAIL_NULL_V(arg_type, ERR_BUG); // Argument type not found
+ ERR_FAIL_NULL_V_MSG(arg_type, ERR_BUG, "Argument type '" + iarg.type.cname + "' was not found.");
ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG,
"Argument type is a singleton: '" + iarg.name + "' of method '" + p_itype.name + "." + p_imethod.name + "'.");
@@ -2944,7 +2944,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
const ArgumentInterface &first = p_isignal.arguments.front()->get();
for (const ArgumentInterface &iarg : p_isignal.arguments) {
const TypeInterface *arg_type = _get_type_or_singleton_or_null(iarg.type);
- ERR_FAIL_NULL_V(arg_type, ERR_BUG); // Argument type not found
+ ERR_FAIL_NULL_V_MSG(arg_type, ERR_BUG, "Argument type '" + iarg.type.cname + "' was not found.");
ERR_FAIL_COND_V_MSG(arg_type->is_singleton, ERR_BUG,
"Argument type is a singleton: '" + iarg.name + "' of signal '" + p_itype.name + "." + p_isignal.name + "'.");
@@ -3013,7 +3013,7 @@ Error BindingsGenerator::_generate_cs_signal(const BindingsGenerator::TypeInterf
int idx = 0;
for (const ArgumentInterface &iarg : p_isignal.arguments) {
const TypeInterface *arg_type = _get_type_or_null(iarg.type);
- ERR_FAIL_NULL_V(arg_type, ERR_BUG); // Argument type not found
+ ERR_FAIL_NULL_V_MSG(arg_type, ERR_BUG, "Argument type '" + iarg.type.cname + "' was not found.");
if (idx != 0) {
p_output << ", ";
@@ -3113,7 +3113,7 @@ Error BindingsGenerator::_generate_cs_native_calls(const InternalCall &p_icall,
bool ret_void = p_icall.return_type.cname == name_cache.type_void;
const TypeInterface *return_type = _get_type_or_null(p_icall.return_type);
- ERR_FAIL_NULL_V(return_type, ERR_BUG); // Return type not found
+ ERR_FAIL_NULL_V_MSG(return_type, ERR_BUG, "Return type '" + p_icall.return_type.cname + "' was not found.");
StringBuilder c_func_sig;
StringBuilder c_in_statements;
@@ -3129,7 +3129,7 @@ Error BindingsGenerator::_generate_cs_native_calls(const InternalCall &p_icall,
int i = 0;
for (const TypeReference &arg_type_ref : p_icall.argument_types) {
const TypeInterface *arg_type = _get_type_or_null(arg_type_ref);
- ERR_FAIL_NULL_V(arg_type, ERR_BUG); // Return type not found
+ ERR_FAIL_NULL_V_MSG(arg_type, ERR_BUG, "Argument type '" + arg_type_ref.cname + "' was not found.");
String c_param_name = "arg" + itos(i + 1);
@@ -3389,7 +3389,7 @@ const String BindingsGenerator::_get_generic_type_parameters(const TypeInterface
String params = "<";
for (const TypeReference &param_type : p_generic_type_parameters) {
const TypeInterface *param_itype = _get_type_or_singleton_or_null(param_type);
- ERR_FAIL_NULL_V(param_itype, ""); // Parameter type not found
+ ERR_FAIL_NULL_V_MSG(param_itype, "", "Parameter type '" + param_type.cname + "' was not found.");
ERR_FAIL_COND_V_MSG(param_itype->is_singleton, "",
"Generic type parameter is a singleton: '" + param_itype->name + "'.");
diff --git a/modules/navigation/nav_base.h b/modules/navigation/nav_base.h
index c28392acf7..d2308abfaf 100644
--- a/modules/navigation/nav_base.h
+++ b/modules/navigation/nav_base.h
@@ -64,7 +64,7 @@ public:
void set_owner_id(ObjectID p_owner_id) { owner_id = p_owner_id; }
ObjectID get_owner_id() const { return owner_id; }
- virtual ~NavBase(){};
+ virtual ~NavBase() {}
};
#endif // NAV_BASE_H
diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h
index 448be9ebe4..c63389b1c6 100644
--- a/modules/text_server_adv/text_server_adv.h
+++ b/modules/text_server_adv/text_server_adv.h
@@ -705,7 +705,7 @@ class TextServerAdvanced : public TextServerExtension {
};
protected:
- static void _bind_methods(){};
+ static void _bind_methods() {}
void full_copy(ShapedTextDataAdvanced *p_shaped);
void invalidate(ShapedTextDataAdvanced *p_shaped, bool p_text = false);
diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h
index ee1f72401f..7f12ad593b 100644
--- a/modules/text_server_fb/text_server_fb.h
+++ b/modules/text_server_fb/text_server_fb.h
@@ -574,7 +574,7 @@ class TextServerFallback : public TextServerExtension {
Mutex ft_mutex;
protected:
- static void _bind_methods(){};
+ static void _bind_methods() {}
void full_copy(ShapedTextDataFallback *p_shaped);
void invalidate(ShapedTextDataFallback *p_shaped);