summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-07-27 10:23:24 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 11:53:29 +0100
commit0586e184490fd132f99acb1a67c788959cfdbade (patch)
tree194972ba608705445c9ee084f908e183a9792760 /core
parent8bbbb973361f367a4888629c571fb6f43581269d (diff)
Custom material support seems complete.
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp16
-rw-r--r--core/image.h3
2 files changed, 17 insertions, 2 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 09b07bba13..6283b93f25 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1215,7 +1215,7 @@ void Image::flip_x() {
}
}
-int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps) {
+int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps, int *r_mm_width, int *r_mm_height) {
int size = 0;
int w = p_width;
@@ -1242,6 +1242,13 @@ int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int &
size += s;
+ if (r_mm_width) {
+ *r_mm_width = bw;
+ }
+ if (r_mm_height) {
+ *r_mm_height = bh;
+ }
+
if (p_mipmaps >= 0 && mm == p_mipmaps)
break;
@@ -1914,6 +1921,13 @@ int Image::get_image_required_mipmaps(int p_width, int p_height, Format p_format
return mm;
}
+Size2i Image::get_image_mipmap_size(int p_width, int p_height, Format p_format, int p_mipmap) {
+ int mm;
+ Size2i ret;
+ _get_dst_image_size(p_width, p_height, p_format, mm, p_mipmap, &ret.x, &ret.y);
+ return ret;
+}
+
int Image::get_image_mipmap_offset(int p_width, int p_height, Format p_format, int p_mipmap) {
if (p_mipmap <= 0) {
diff --git a/core/image.h b/core/image.h
index c15cfc9f6f..87387ec38e 100644
--- a/core/image.h
+++ b/core/image.h
@@ -177,7 +177,7 @@ private:
_FORCE_INLINE_ void _get_mipmap_offset_and_size(int p_mipmap, int &r_offset, int &r_width, int &r_height) const; //get where the mipmap begins in data
- static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1);
+ static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1, int *r_mm_width = NULL, int *r_mm_height = NULL);
bool _can_modify(Format p_format) const;
_FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel);
@@ -290,6 +290,7 @@ public:
static int get_image_data_size(int p_width, int p_height, Format p_format, bool p_mipmaps = false);
static int get_image_required_mipmaps(int p_width, int p_height, Format p_format);
+ static Size2i get_image_mipmap_size(int p_width, int p_height, Format p_format, int p_mipmap);
static int get_image_mipmap_offset(int p_width, int p_height, Format p_format, int p_mipmap);
enum CompressMode {