diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/dds/texture_loader_dds.cpp | 2 | ||||
-rw-r--r-- | modules/etc1/image_etc.cpp | 19 | ||||
-rw-r--r-- | modules/etc1/texture_loader_pkm.cpp | 2 | ||||
-rw-r--r-- | modules/gdnative/config.py | 2 | ||||
-rw-r--r-- | modules/gdnative/godot/godot_variant.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_function.cpp | 18 | ||||
-rw-r--r-- | modules/gdscript/gd_function.h | 2 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 1 | ||||
-rw-r--r-- | modules/jpg/image_loader_jpegd.cpp | 11 | ||||
-rw-r--r-- | modules/jpg/image_loader_jpegd.h | 2 | ||||
-rw-r--r-- | modules/pvr/texture_loader_pvr.cpp | 43 | ||||
-rw-r--r-- | modules/theora/video_stream_theora.cpp | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 3 | ||||
-rw-r--r-- | modules/webp/image_loader_webp.cpp | 35 | ||||
-rw-r--r-- | modules/webp/image_loader_webp.h | 2 |
16 files changed, 80 insertions, 68 deletions
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index d79b7685d1..4448c80387 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -441,7 +441,7 @@ RES ResourceFormatDDS::load(const String &p_path, const String &p_original_path, wb = PoolVector<uint8_t>::Write(); } - Image img(width, height, mipmaps - 1, info.format, src_data); + Ref<Image> img = memnew(Image(width, height, mipmaps - 1, info.format, src_data)); Ref<ImageTexture> texture = memnew(ImageTexture); texture->create_from_image(img); diff --git a/modules/etc1/image_etc.cpp b/modules/etc1/image_etc.cpp index 60544594f6..121f50684d 100644 --- a/modules/etc1/image_etc.cpp +++ b/modules/etc1/image_etc.cpp @@ -88,25 +88,26 @@ static void _decompress_etc(Image *p_img) { r = PoolVector<uint8_t>::Read(); //print_line("Re Creating ETC into regular image: w "+itos(p_img->get_width())+" h "+itos(p_img->get_height())+" mm "+itos(p_img->get_mipmaps())); - *p_img = Image(p_img->get_width(), p_img->get_height(), p_img->has_mipmaps(), Image::FORMAT_RGB8, dst); - if (p_img->has_mipmaps()) + bool needs_mipmaps = p_img->has_mipmaps(); + p_img->create(p_img->get_width(), p_img->get_height(), p_img->has_mipmaps(), Image::FORMAT_RGB8, dst); + if (needs_mipmaps) p_img->generate_mipmaps(); } static void _compress_etc(Image *p_img) { - Image img = *p_img; + Ref<Image> img = p_img->duplicate(); - int imgw = img.get_width(), imgh = img.get_height(); + int imgw = img->get_width(), imgh = img->get_height(); ERR_FAIL_COND(nearest_power_of_2(imgw) != imgw || nearest_power_of_2(imgh) != imgh); - if (img.get_format() != Image::FORMAT_RGB8) - img.convert(Image::FORMAT_RGB8); + if (img->get_format() != Image::FORMAT_RGB8) + img->convert(Image::FORMAT_RGB8); PoolVector<uint8_t> res_data; PoolVector<uint8_t> dst_data; - PoolVector<uint8_t>::Read r = img.get_data().read(); + PoolVector<uint8_t>::Read r = img->get_data().read(); int target_size = Image::get_image_data_size(p_img->get_width(), p_img->get_height(), Image::FORMAT_ETC, p_img->has_mipmaps() ? -1 : 0); int mmc = p_img->has_mipmaps() ? Image::get_image_required_mipmaps(p_img->get_width(), p_img->get_height(), Image::FORMAT_ETC) : 0; @@ -122,7 +123,7 @@ static void _compress_etc(Image *p_img) { int bw = MAX(imgw / 4, 1); int bh = MAX(imgh / 4, 1); - const uint8_t *src = &r[img.get_mipmap_offset(i)]; + const uint8_t *src = &r[img->get_mipmap_offset(i)]; int mmsize = MAX(bw, 1) * MAX(bh, 1) * 8; uint8_t *dst = &w[ofs]; @@ -171,7 +172,7 @@ static void _compress_etc(Image *p_img) { mc++; } - *p_img = Image(p_img->get_width(), p_img->get_height(), (mc - 1) ? true : false, Image::FORMAT_ETC, dst_data); + p_img->create(p_img->get_width(), p_img->get_height(), (mc - 1) ? true : false, Image::FORMAT_ETC, dst_data); } void _register_etc1_compress_func() { diff --git a/modules/etc1/texture_loader_pkm.cpp b/modules/etc1/texture_loader_pkm.cpp index 9817de3a0f..c04528d2a0 100644 --- a/modules/etc1/texture_loader_pkm.cpp +++ b/modules/etc1/texture_loader_pkm.cpp @@ -85,7 +85,7 @@ RES ResourceFormatPKM::load(const String &p_path, const String &p_original_path, int width = h.origWidth; int height = h.origHeight; - Image img(width, height, mipmaps, Image::FORMAT_ETC, src_data); + Ref<Image> img = memnew(Image(width, height, mipmaps, Image::FORMAT_ETC, src_data)); Ref<ImageTexture> texture = memnew(ImageTexture); texture->create_from_image(img); diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py index 9f57b9bb74..4f89ca0d4c 100644 --- a/modules/gdnative/config.py +++ b/modules/gdnative/config.py @@ -1,7 +1,7 @@ def can_build(platform): - return True + return False def configure(env): diff --git a/modules/gdnative/godot/godot_variant.h b/modules/gdnative/godot/godot_variant.h index 0a5771d2f6..bf0e2bf64e 100644 --- a/modules/gdnative/godot/godot_variant.h +++ b/modules/gdnative/godot/godot_variant.h @@ -62,7 +62,7 @@ typedef enum godot_variant_type { GODOT_VARIANT_TYPE_TRANSFORM2D, GODOT_VARIANT_TYPE_PLANE, GODOT_VARIANT_TYPE_QUAT, // 10 - GODOT_VARIANT_TYPE_RECT3, //sorry naming convention fail :( not like it's used often + GODOT_VARIANT_TYPE_RECT3, GODOT_VARIANT_TYPE_BASIS, GODOT_VARIANT_TYPE_TRANSFORM, diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 5d404e2f7d..7d5ba08d6c 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -1321,7 +1321,7 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o static const char *_type_names[Variant::VARIANT_MAX] = { "null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform", - "Color", "Image", "NodePath", "RID", "Object", "InputEvent", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray", + "Color", "NodePath", "RID", "Object", "InputEvent", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray", "Vector2Array", "Vector3Array", "ColorArray" }; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 608256c88a..fb32d23ad5 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -1433,9 +1433,21 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount return ret; } -bool GDFunctionState::is_valid() const { +bool GDFunctionState::is_valid(bool p_extended_check) const { + + if (function == NULL) + return false; + + if (p_extended_check) { + //class instance gone? + if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) + return false; + //script gone? + if (state.script_id && !ObjectDB::get_instance(state.script_id)) + return false; + } - return function != NULL; + return true; } Variant GDFunctionState::resume(const Variant &p_arg) { @@ -1464,7 +1476,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) { void GDFunctionState::_bind_methods() { ClassDB::bind_method(D_METHOD("resume:Variant", "arg"), &GDFunctionState::resume, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("is_valid"), &GDFunctionState::is_valid); + ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false)); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback")); } diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index f0bf33147b..6d20b19777 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -237,7 +237,7 @@ protected: static void _bind_methods(); public: - bool is_valid() const; + bool is_valid(bool p_extended_check = false) const; Variant resume(const Variant &p_arg = Variant()); GDFunctionState(); ~GDFunctionState(); diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 13674f1f9a..c26ba03a64 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -800,7 +800,6 @@ void GDTokenizerText::_advance() { { Variant::BASIS, "Basis" }, { Variant::TRANSFORM, "Transform" }, { Variant::COLOR, "Color" }, - { Variant::IMAGE, "Image" }, { Variant::_RID, "RID" }, { Variant::OBJECT, "Object" }, { Variant::INPUT_EVENT, "InputEvent" }, diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index 83685d6446..0741dd198a 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -89,7 +89,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p return OK; } -Error ImageLoaderJPG::load_image(Image *p_image, FileAccess *f) { +Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f) { PoolVector<uint8_t> src_image; int src_image_len = f->get_len(); @@ -102,7 +102,7 @@ Error ImageLoaderJPG::load_image(Image *p_image, FileAccess *f) { f->close(); - Error err = jpeg_load_image_from_buffer(p_image, w.ptr(), src_image_len); + Error err = jpeg_load_image_from_buffer(p_image.ptr(), w.ptr(), src_image_len); w = PoolVector<uint8_t>::Write(); @@ -115,10 +115,11 @@ void ImageLoaderJPG::get_recognized_extensions(List<String> *p_extensions) const p_extensions->push_back("jpeg"); } -static Image _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) { +static Ref<Image> _jpegd_mem_loader_func(const uint8_t *p_png, int p_size) { - Image img; - Error err = jpeg_load_image_from_buffer(&img, p_png, p_size); + Ref<Image> img; + img.instance(); + Error err = jpeg_load_image_from_buffer(img.ptr(), p_png, p_size); if (err) ERR_PRINT("Couldn't initialize ImageLoaderJPG with the given resource."); diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h index d23e8a7d48..57d7a2bb1c 100644 --- a/modules/jpg/image_loader_jpegd.h +++ b/modules/jpg/image_loader_jpegd.h @@ -38,7 +38,7 @@ class ImageLoaderJPG : public ImageFormatLoader { public: - virtual Error load_image(Image *p_image, FileAccess *f); + virtual Error load_image(Ref<Image> p_image, FileAccess *f); virtual void get_recognized_extensions(List<String> *p_extensions) const; ImageLoaderJPG(); }; diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 62cbd9cd8d..bdd4779e28 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -164,8 +164,8 @@ RES ResourceFormatPVR::load(const String &p_path, const String &p_original_path, print_line("flip: " + itos(flags & PVR_VFLIP)); - Image image(width, height, mipmaps, format, data); - ERR_FAIL_COND_V(image.empty(), RES()); + Ref<Image> image = memnew(Image(width, height, mipmaps, format, data)); + ERR_FAIL_COND_V(image->empty(), RES()); Ref<ImageTexture> texture = memnew(ImageTexture); texture->create_from_image(image, tex_flags); @@ -193,30 +193,32 @@ String ResourceFormatPVR::get_resource_type(const String &p_path) const { static void _compress_pvrtc4(Image *p_img) { - Image img = *p_img; + Ref<Image> img = p_img->duplicate(); bool make_mipmaps = false; - if (img.get_width() % 8 || img.get_height() % 8) { - make_mipmaps = img.has_mipmaps(); - img.resize(img.get_width() + (8 - (img.get_width() % 8)), img.get_height() + (8 - (img.get_height() % 8))); + if (img->get_width() % 8 || img->get_height() % 8) { + make_mipmaps = img->has_mipmaps(); + img->resize(img->get_width() + (8 - (img->get_width() % 8)), img->get_height() + (8 - (img->get_height() % 8))); } - img.convert(Image::FORMAT_RGBA8); - if (!img.has_mipmaps() && make_mipmaps) - img.generate_mipmaps(); + img->convert(Image::FORMAT_RGBA8); + if (!img->has_mipmaps() && make_mipmaps) + img->generate_mipmaps(); - bool use_alpha = img.detect_alpha(); + bool use_alpha = img->detect_alpha(); - Image new_img; - new_img.create(img.get_width(), img.get_height(), true, use_alpha ? Image::FORMAT_PVRTC4A : Image::FORMAT_PVRTC4); - PoolVector<uint8_t> data = new_img.get_data(); + Ref<Image> new_img; + new_img.instance(); + new_img->create(img->get_width(), img->get_height(), true, use_alpha ? Image::FORMAT_PVRTC4A : Image::FORMAT_PVRTC4); + + PoolVector<uint8_t> data = new_img->get_data(); { PoolVector<uint8_t>::Write wr = data.write(); - PoolVector<uint8_t>::Read r = img.get_data().read(); + PoolVector<uint8_t>::Read r = img->get_data().read(); - for (int i = 0; i <= new_img.get_mipmap_count(); i++) { + for (int i = 0; i <= new_img->get_mipmap_count(); i++) { int ofs, size, w, h; - img.get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); + img->get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); Javelin::RgbaBitmap bm(w, h); copymem(bm.GetData(), &r[ofs], size); { @@ -226,12 +228,12 @@ static void _compress_pvrtc4(Image *p_img) { } } - new_img.get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); + new_img->get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); Javelin::PvrTcEncoder::EncodeRgba4Bpp(&wr[ofs], bm); } } - *p_img = Image(new_img.get_width(), new_img.get_height(), new_img.has_mipmaps(), new_img.get_format(), data); + p_img->create(new_img->get_width(), new_img->get_height(), new_img->has_mipmaps(), new_img->get_format(), data); } ResourceFormatPVR::ResourceFormatPVR() { @@ -676,8 +678,7 @@ static void _pvrtc_decompress(Image *p_img) { r = PoolVector<uint8_t>::Read(); bool make_mipmaps = p_img->has_mipmaps(); - Image newimg(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata); + p_img->create(p_img->get_width(), p_img->get_height(), false, Image::FORMAT_RGBA8, newdata); if (make_mipmaps) - newimg.generate_mipmaps(); - *p_img = newimg; + p_img->generate_mipmaps(); } diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index 61112f20b4..d895f60280 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -138,7 +138,7 @@ void VideoStreamPlaybackTheora::video_write(void) { format = Image::FORMAT_RGBA8; } - Image img(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data); //zero copy image creation + Ref<Image> img = memnew(Image(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation texture->set_data(img); //zero copy send to visual server diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index d515f301ce..340e2fe637 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -346,7 +346,6 @@ static Color _color_from_type(Variant::Type p_type) { case Variant::TRANSFORM: color = Color::html("f6a86e"); break; case Variant::COLOR: color = Color::html("9dff70"); break; - case Variant::IMAGE: color = Color::html("93f1b9"); break; case Variant::NODE_PATH: color = Color::html("6993ec"); break; case Variant::_RID: color = Color::html("69ec9a"); break; case Variant::OBJECT: color = Color::html("79f3e8"); break; @@ -451,7 +450,6 @@ void VisualScriptEditor::_update_graph(int p_only_id) { Control::get_icon("MiniBasis", "EditorIcons"), Control::get_icon("MiniTransform", "EditorIcons"), Control::get_icon("MiniColor", "EditorIcons"), - Control::get_icon("MiniImage", "EditorIcons"), Control::get_icon("MiniPath", "EditorIcons"), Control::get_icon("MiniRid", "EditorIcons"), Control::get_icon("MiniObject", "EditorIcons"), @@ -735,7 +733,6 @@ void VisualScriptEditor::_update_members() { Control::get_icon("MiniMatrix3", "EditorIcons"), Control::get_icon("MiniTransform", "EditorIcons"), Control::get_icon("MiniColor", "EditorIcons"), - Control::get_icon("MiniImage", "EditorIcons"), Control::get_icon("MiniPath", "EditorIcons"), Control::get_icon("MiniRid", "EditorIcons"), Control::get_icon("MiniObject", "EditorIcons"), diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index 889eac71a7..7313cb6c7c 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -37,23 +37,23 @@ #include <webp/decode.h> #include <webp/encode.h> -static PoolVector<uint8_t> _webp_lossy_pack(const Image &p_image, float p_quality) { +static PoolVector<uint8_t> _webp_lossy_pack(const Ref<Image> &p_image, float p_quality) { - ERR_FAIL_COND_V(p_image.empty(), PoolVector<uint8_t>()); + ERR_FAIL_COND_V(p_image.is_null() || p_image->empty(), PoolVector<uint8_t>()); - Image img = p_image; - if (img.detect_alpha()) - img.convert(Image::FORMAT_RGBA8); + Ref<Image> img = p_image->duplicate(); + if (img->detect_alpha()) + img->convert(Image::FORMAT_RGBA8); else - img.convert(Image::FORMAT_RGB8); + img->convert(Image::FORMAT_RGB8); - Size2 s(img.get_width(), img.get_height()); - PoolVector<uint8_t> data = img.get_data(); + Size2 s(img->get_width(), img->get_height()); + PoolVector<uint8_t> data = img->get_data(); PoolVector<uint8_t>::Read r = data.read(); uint8_t *dst_buff = NULL; size_t dst_size = 0; - if (img.get_format() == Image::FORMAT_RGB8) { + if (img->get_format() == Image::FORMAT_RGB8) { dst_size = WebPEncodeRGB(r.ptr(), s.width, s.height, 3 * s.width, CLAMP(p_quality * 100.0, 0, 100.0), &dst_buff); } else { @@ -74,17 +74,17 @@ static PoolVector<uint8_t> _webp_lossy_pack(const Image &p_image, float p_qualit return dst; } -static Image _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) { +static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) { int size = p_buffer.size() - 4; - ERR_FAIL_COND_V(size <= 0, Image()); + ERR_FAIL_COND_V(size <= 0, Ref<Image>()); PoolVector<uint8_t>::Read r = p_buffer.read(); - ERR_FAIL_COND_V(r[0] != 'W' || r[1] != 'E' || r[2] != 'B' || r[3] != 'P', Image()); + ERR_FAIL_COND_V(r[0] != 'W' || r[1] != 'E' || r[2] != 'B' || r[3] != 'P', Ref<Image>()); WebPBitstreamFeatures features; if (WebPGetFeatures(&r[4], size, &features) != VP8_STATUS_OK) { ERR_EXPLAIN("Error unpacking WEBP image:"); - ERR_FAIL_V(Image()); + ERR_FAIL_V(Ref<Image>()); } /* @@ -107,14 +107,15 @@ static Image _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) { } //ERR_EXPLAIN("Error decoding webp! - "+p_file); - ERR_FAIL_COND_V(errdec, Image()); + ERR_FAIL_COND_V(errdec, Ref<Image>()); dst_w = PoolVector<uint8_t>::Write(); - return Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image); + Ref<Image> img = memnew(Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image)); + return img; } -Error ImageLoaderWEBP::load_image(Image *p_image, FileAccess *f) { +Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f) { uint32_t size = f->get_len(); PoolVector<uint8_t> src_image; @@ -160,7 +161,7 @@ Error ImageLoaderWEBP::load_image(Image *p_image, FileAccess *f) { src_r = PoolVector<uint8_t>::Read(); dst_w = PoolVector<uint8_t>::Write(); - *p_image = Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image); + p_image->create(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image); return OK; } diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h index 2d0ac796d3..ba817e0ecd 100644 --- a/modules/webp/image_loader_webp.h +++ b/modules/webp/image_loader_webp.h @@ -38,7 +38,7 @@ class ImageLoaderWEBP : public ImageFormatLoader { public: - virtual Error load_image(Image *p_image, FileAccess *f); + virtual Error load_image(Ref<Image> p_image, FileAccess *f); virtual void get_recognized_extensions(List<String> *p_extensions) const; ImageLoaderWEBP(); }; |