summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/etc/image_etc.cpp20
-rw-r--r--modules/gdnative/gdnative/string.cpp6
2 files changed, 22 insertions, 4 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index e56ec774dd..8a674bc8c1 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -118,7 +118,6 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
}
uint32_t imgw = p_img->get_width(), imgh = p_img->get_height();
- ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh);
Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);
@@ -127,6 +126,25 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
if (img->get_format() != Image::FORMAT_RGBA8)
img->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
+ if (img->has_mipmaps()) {
+ if (next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh) {
+ img->resize_to_po2();
+ imgw = img->get_width();
+ imgh = img->get_height();
+ }
+ } else {
+ if (imgw % 4 != 0 || imgh % 4 != 0) {
+ if (imgw % 4) {
+ imgw += 4 - imgw % 4;
+ }
+ if (imgh % 4) {
+ imgh += 4 - imgh % 4;
+ }
+
+ img->resize(imgw, imgh);
+ }
+ }
+
PoolVector<uint8_t>::Read r = img->get_data().read();
int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps() ? -1 : 0);
diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp
index 9ce2b1406d..7f5dbc12be 100644
--- a/modules/gdnative/gdnative/string.cpp
+++ b/modules/gdnative/gdnative/string.cpp
@@ -932,7 +932,7 @@ godot_char_string GDAPI godot_string_ascii(const godot_string *p_self) {
const String *self = (const String *)p_self;
godot_char_string result;
- memnew_placement(&result, String(self->ascii()));
+ memnew_placement(&result, CharString(self->ascii()));
return result;
}
@@ -942,7 +942,7 @@ godot_char_string GDAPI godot_string_ascii_extended(const godot_string *p_self)
godot_char_string result;
- memnew_placement(&result, String(self->ascii(true)));
+ memnew_placement(&result, CharString(self->ascii(true)));
return result;
}
@@ -952,7 +952,7 @@ godot_char_string GDAPI godot_string_utf8(const godot_string *p_self) {
godot_char_string result;
- memnew_placement(&result, String(self->utf8()));
+ memnew_placement(&result, CharString(self->utf8()));
return result;
}