diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-05-17 07:36:47 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-05-17 07:37:45 -0300 |
commit | 98a329670227c726a5d7a196e5cba8dbdd54301b (patch) | |
tree | 7346f7a3e38eb35b784ac1a68a227d07cc8881b4 /editor | |
parent | d801ff2b3db2de105c1b36a74ce116e360143d4e (diff) |
Removal of Image from Variant, converted to a Resource.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/asset_library_editor_plugin.cpp | 9 | ||||
-rw-r--r-- | editor/connections_dialog.cpp | 2 | ||||
-rw-r--r-- | editor/doc/doc_data.cpp | 4 | ||||
-rw-r--r-- | editor/doc/doc_dump.cpp | 4 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 10 | ||||
-rw-r--r-- | editor/editor_node.cpp | 5 | ||||
-rw-r--r-- | editor/editor_profiler.cpp | 6 | ||||
-rw-r--r-- | editor/editor_run_native.cpp | 9 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 9 | ||||
-rw-r--r-- | editor/icons/SCsub | 6 | ||||
-rw-r--r-- | editor/import/resource_importer_texture.cpp | 67 | ||||
-rw-r--r-- | editor/import/resource_importer_texture.h | 4 | ||||
-rw-r--r-- | editor/plugins/baked_light_baker.h | 2 | ||||
-rw-r--r-- | editor/plugins/gradient_texture_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/particles_2d_editor_plugin.cpp | 15 | ||||
-rw-r--r-- | editor/plugins/particles_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/texture_region_editor_plugin.cpp | 9 | ||||
-rw-r--r-- | editor/project_manager.cpp | 7 | ||||
-rw-r--r-- | editor/property_editor.cpp | 72 | ||||
-rw-r--r-- | editor/property_selector.cpp | 1 | ||||
-rw-r--r-- | editor/pvrtc_compress.cpp | 4 |
22 files changed, 93 insertions, 161 deletions
diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp index 971adb14cf..fcb92e13b4 100644 --- a/editor/asset_library_editor_plugin.cpp +++ b/editor/asset_library_editor_plugin.cpp @@ -683,17 +683,18 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt int len = image_data.size(); PoolByteArray::Read r = image_data.read(); - Image image(r.ptr(), len); - if (!image.empty()) { + Ref<Image> image = Ref<Image>(memnew(Image(r.ptr(), len))); + + if (!image->empty()) { float max_height = 10000; switch (image_queue[p_queue_id].image_type) { case IMAGE_QUEUE_ICON: max_height = 80; break; case IMAGE_QUEUE_THUMBNAIL: max_height = 80; break; case IMAGE_QUEUE_SCREENSHOT: max_height = 345; break; } - float scale_ratio = max_height / image.get_height(); + float scale_ratio = max_height / image->get_height(); if (scale_ratio < 1) { - image.resize(image.get_width() * scale_ratio, image.get_height() * scale_ratio, Image::INTERPOLATE_CUBIC); + image->resize(image->get_width() * scale_ratio, image->get_height() * scale_ratio, Image::INTERPOLATE_CUBIC); } Ref<ImageTexture> tex; diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 93c2b7493c..e623d00cc9 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -239,7 +239,6 @@ void ConnectDialog::_add_bind() { case Variant::BASIS: value = Basis(); break; case Variant::TRANSFORM: value = Transform(); break; case Variant::COLOR: value = Color(); break; - case Variant::IMAGE: value = Image(); break; default: { ERR_FAIL(); } break; } @@ -327,7 +326,6 @@ ConnectDialog::ConnectDialog() { type_list->add_item("Transform", Variant::TRANSFORM); //type_list->add_separator(); type_list->add_item("Color", Variant::COLOR); - type_list->add_item("Image", Variant::IMAGE); type_list->select(0); Button *add_bind = memnew(Button); diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index af95f8d919..aea1c231aa 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -335,11 +335,7 @@ void DocData::generate(bool p_basic_types) { case Variant::DICTIONARY: // 20 case Variant::ARRAY: case Variant::_RID: - case Variant::IMAGE: - //case Variant::RESOURCE: - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()"; - break; default: {} } diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index bda4d80f4d..d8608a00d0 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -198,11 +198,7 @@ void DocDump::dump(const String &p_file) { case Variant::DICTIONARY: // 20 case Variant::ARRAY: case Variant::_RID: - case Variant::IMAGE: - //case Variant::RESOURCE: - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "()"; - break; default: {} } diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index c2e829e312..c47e3fc0de 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -488,8 +488,9 @@ void EditorFileDialog::update_file_list() { if (!has_icon("ResizedFolder", "EditorIcons")) { Ref<ImageTexture> folder = get_icon("FolderBig", "EditorIcons"); - Image img = folder->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = folder->get_data(); + img = img->duplicate(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_folder = Ref<ImageTexture>(memnew(ImageTexture)); resized_folder->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder); @@ -499,8 +500,9 @@ void EditorFileDialog::update_file_list() { if (!has_icon("ResizedFile", "EditorIcons")) { Ref<ImageTexture> file = get_icon("FileBig", "EditorIcons"); - Image img = file->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = file->get_data(); + img = img->duplicate(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture)); resized_file->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 698066f188..f0152b4be2 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4463,8 +4463,9 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { { //todo make proper previews Ref<ImageTexture> pic = gui_base->get_icon("FileBig", "EditorIcons"); - Image img = pic->get_data(); - img.resize(48, 48); //meh + Ref<Image> img = pic->get_data(); + img = img->duplicate(); + img->resize(48, 48); //meh Ref<ImageTexture> resized_pic = Ref<ImageTexture>(memnew(ImageTexture)); resized_pic->create_from_image(img); preview = resized_pic; diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index 8f4312111a..9d12ad687e 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -344,14 +344,16 @@ void EditorProfiler::_update_plot() { wr = PoolVector<uint8_t>::Write(); - Image img(w, h, 0, Image::FORMAT_RGBA8, graph_image); + Ref<Image> img; + img.instance(); + img->create(w, h, 0, Image::FORMAT_RGBA8, graph_image); if (reset_texture) { if (graph_texture.is_null()) { graph_texture.instance(); } - graph_texture->create(img.get_width(), img.get_height(), img.get_format(), Texture::FLAG_VIDEO_SURFACE); + graph_texture->create(img->get_width(), img->get_height(), img->get_format(), Texture::FLAG_VIDEO_SURFACE); } graph_texture->set_data(img); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 5a519a1dbd..4a767621ef 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -43,11 +43,12 @@ void EditorRunNative::_notification(int p_what) { continue; Ref<ImageTexture> icon = eep->get_logo(); if (!icon.is_null()) { - Image im = icon->get_data(); - im.clear_mipmaps(); - if (!im.empty()) { + Ref<Image> im = icon->get_data(); + im = im->duplicate(); + im->clear_mipmaps(); + if (!im->empty()) { - im.resize(16, 16); + im->resize(16, 16); Ref<ImageTexture> small_icon; small_icon.instance(); small_icon->create_from_image(im, 0); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index c324f474bb..71e43216b3 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -416,8 +416,9 @@ void FileSystemDock::_update_files(bool p_keep_selection) { if (!has_icon("ResizedFolder", "EditorIcons")) { Ref<ImageTexture> folder = get_icon("FolderBig", "EditorIcons"); - Image img = folder->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = folder->get_data(); + img = img->duplicate(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_folder = Ref<ImageTexture>(memnew(ImageTexture)); resized_folder->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFolder", "EditorIcons", resized_folder); @@ -427,8 +428,8 @@ void FileSystemDock::_update_files(bool p_keep_selection) { if (!has_icon("ResizedFile", "EditorIcons")) { Ref<ImageTexture> file = get_icon("FileBig", "EditorIcons"); - Image img = file->get_data(); - img.resize(thumbnail_size, thumbnail_size); + Ref<Image> img = file->get_data(); + img->resize(thumbnail_size, thumbnail_size); Ref<ImageTexture> resized_file = Ref<ImageTexture>(memnew(ImageTexture)); resized_file->create_from_image(img, 0); Theme::get_default()->set_icon("ResizedFile", "EditorIcons", resized_file); diff --git a/editor/icons/SCsub b/editor/icons/SCsub index 3fc8e5461f..20a381cc78 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -62,9 +62,9 @@ def make_editor_icons_action(target, source, env): s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") s.write("\tbool use_hidpi_image=(editor_get_scale()>1.0&&p_hidpi_png);\n") - s.write("\tImage img(use_hidpi_image?p_hidpi_png:p_png);\n") - s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA8); img.expand_x2_hq2x(); use_hidpi_image=true;}\n") - s.write("\timg.resize(img.get_width()*EDSCALE/(use_hidpi_image?2:1),img.get_height()*EDSCALE/(use_hidpi_image?2:1));\n") + s.write("\tRef<Image> img = memnew(Image(use_hidpi_image?p_hidpi_png:p_png));\n") + s.write("\tif (editor_get_scale()>1.0 && !p_hidpi_png) { img->convert(Image::FORMAT_RGBA8); img->expand_x2_hq2x(); use_hidpi_image=true;}\n") + s.write("\timg->resize(img->get_width()*EDSCALE/(use_hidpi_image?2:1),img->get_height()*EDSCALE/(use_hidpi_image?2:1));\n") s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") s.write("\treturn texture;\n") s.write("}\n\n") diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index f0dcc4a298..c115f0014a 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -181,7 +181,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT)); } -void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) { +void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb) { FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE); f->store_8('G'); @@ -189,8 +189,8 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t f->store_8('S'); f->store_8('T'); //godot streamable texture - f->store_32(p_image.get_width()); - f->store_32(p_image.get_height()); + f->store_32(p_image->get_width()); + f->store_32(p_image->get_height()); f->store_32(p_texture_flags); uint32_t format = 0; @@ -207,14 +207,14 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t switch (p_compress_mode) { case COMPRESS_LOSSLESS: { - Image image = p_image; + Ref<Image> image = p_image->duplicate(); if (p_mipmaps) { - image.generate_mipmaps(); + image->generate_mipmaps(); } else { - image.clear_mipmaps(); + image->clear_mipmaps(); } - int mmc = image.get_mipmap_count() + 1; + int mmc = image->get_mipmap_count() + 1; format |= StreamTexture::FORMAT_BIT_LOSSLESS; f->store_32(format); @@ -223,7 +223,7 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t for (int i = 0; i < mmc; i++) { if (i > 0) { - image.shrink_x2(); + image->shrink_x2(); } PoolVector<uint8_t> data = Image::lossless_packer(image); @@ -236,14 +236,14 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t } break; case COMPRESS_LOSSY: { - Image image = p_image; + Ref<Image> image = p_image->duplicate(); if (p_mipmaps) { - image.generate_mipmaps(); + image->generate_mipmaps(); } else { - image.clear_mipmaps(); + image->clear_mipmaps(); } - int mmc = image.get_mipmap_count() + 1; + int mmc = image->get_mipmap_count() + 1; format |= StreamTexture::FORMAT_BIT_LOSSY; f->store_32(format); @@ -252,7 +252,7 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t for (int i = 0; i < mmc; i++) { if (i > 0) { - image.shrink_x2(); + image->shrink_x2(); } PoolVector<uint8_t> data = Image::lossy_packer(image, p_lossy_quality); @@ -265,15 +265,15 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t } break; case COMPRESS_VIDEO_RAM: { - Image image = p_image; - image.generate_mipmaps(); - image.compress(p_vram_compression); + Ref<Image> image = p_image->duplicate(); + image->generate_mipmaps(); + image->compress(p_vram_compression); - format |= image.get_format(); + format |= image->get_format(); f->store_32(format); - PoolVector<uint8_t> data = image.get_data(); + PoolVector<uint8_t> data = image->get_data(); int dl = data.size(); PoolVector<uint8_t>::Read r = data.read(); f->store_buffer(r.ptr(), dl); @@ -281,17 +281,17 @@ void ResourceImporterTexture::_save_stex(const Image &p_image, const String &p_t } break; case COMPRESS_UNCOMPRESSED: { - Image image = p_image; + Ref<Image> image = p_image->duplicate(); if (p_mipmaps) { - image.generate_mipmaps(); + image->generate_mipmaps(); } else { - image.clear_mipmaps(); + image->clear_mipmaps(); } - format |= image.get_format(); + format |= image->get_format(); f->store_32(format); - PoolVector<uint8_t> data = image.get_data(); + PoolVector<uint8_t> data = image->get_data(); int dl = data.size(); PoolVector<uint8_t>::Read r = data.read(); @@ -317,8 +317,9 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String bool stream = p_options["stream"]; int size_limit = p_options["size_limit"]; - Image image; - Error err = ImageLoader::load_image(p_source_file, &image); + Ref<Image> image; + image.instance(); + Error err = ImageLoader::load_image(p_source_file, image); if (err != OK) return err; @@ -336,28 +337,28 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (srgb == 1) tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR; - if (size_limit > 0 && (image.get_width() > size_limit || image.get_height() > size_limit)) { + if (size_limit > 0 && (image->get_width() > size_limit || image->get_height() > size_limit)) { //limit size - if (image.get_width() >= image.get_height()) { + if (image->get_width() >= image->get_height()) { int new_width = size_limit; - int new_height = image.get_height() * new_width / image.get_width(); + int new_height = image->get_height() * new_width / image->get_width(); - image.resize(new_width, new_height, Image::INTERPOLATE_CUBIC); + image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } else { int new_height = size_limit; - int new_width = image.get_width() * new_height / image.get_height(); + int new_width = image->get_width() * new_height / image->get_height(); - image.resize(new_width, new_height, Image::INTERPOLATE_CUBIC); + image->resize(new_width, new_height, Image::INTERPOLATE_CUBIC); } } if (fix_alpha_border) { - image.fix_alpha_edges(); + image->fix_alpha_edges(); } if (premult_alpha) { - image.premultiply_alpha(); + image->premultiply_alpha(); } bool detect_3d = p_options["detect_3d"]; diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index 196eb48469..e782fc2978 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -30,7 +30,9 @@ #ifndef RESOURCEIMPORTTEXTURE_H #define RESOURCEIMPORTTEXTURE_H +#include "image.h" #include "io/resource_import.h" + class StreamTexture; class ResourceImporterTexture : public ResourceImporter { @@ -78,7 +80,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _save_stex(const Image &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb); + void _save_stex(const Ref<Image> &p_image, const String &p_to_path, int p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, int p_texture_flags, bool p_streamable, bool p_detect_3d, bool p_detect_srgb); virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); diff --git a/editor/plugins/baked_light_baker.h b/editor/plugins/baked_light_baker.h index 5f32e236c0..123812fc07 100644 --- a/editor/plugins/baked_light_baker.h +++ b/editor/plugins/baked_light_baker.h @@ -31,7 +31,7 @@ #define BAKED_LIGHT_BAKER_H #include "os/thread.h" -#include "scene/3d/baked_light_instance.h" + #include "scene/3d/light.h" #include "scene/3d/mesh_instance.h" diff --git a/editor/plugins/gradient_texture_editor_plugin.cpp b/editor/plugins/gradient_texture_editor_plugin.cpp index 41dd64d931..005633a10e 100644 --- a/editor/plugins/gradient_texture_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_editor_plugin.cpp @@ -48,7 +48,8 @@ GradientTextureEdit::GradientTextureEdit() { add_child(popup); checker = Ref<ImageTexture>(memnew(ImageTexture)); - checker->create_from_image(Image(checker_bg_png), ImageTexture::FLAG_REPEAT); + Ref<Image> checker_bg = memnew(Image(checker_bg_png)); + checker->create_from_image(checker_bg, ImageTexture::FLAG_REPEAT); } int GradientTextureEdit::_get_point_from_pos(int x) { diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index 35743ce0b3..c6c85d8be2 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -64,17 +64,18 @@ void Particles2DEditorPlugin::_file_selected(const String &p_file) { int epc = epoints->get_value(); - Image img; - Error err = ImageLoader::load_image(p_file, &img); + Ref<Image> img; + img.instance(); + Error err = ImageLoader::load_image(p_file, img); ERR_EXPLAIN(TTR("Error loading image:") + " " + p_file); ERR_FAIL_COND(err != OK); - img.convert(Image::FORMAT_LA8); - ERR_FAIL_COND(img.get_format() != Image::FORMAT_LA8); - Size2i s = Size2(img.get_width(), img.get_height()); + img->convert(Image::FORMAT_LA8); + ERR_FAIL_COND(img->get_format() != Image::FORMAT_LA8); + Size2i s = Size2(img->get_width(), img->get_height()); ERR_FAIL_COND(s.width == 0 || s.height == 0); - PoolVector<uint8_t> data = img.get_data(); + PoolVector<uint8_t> data = img->get_data(); PoolVector<uint8_t>::Read r = data.read(); Vector<Point2i> valid_positions; @@ -98,7 +99,7 @@ void Particles2DEditorPlugin::_file_selected(const String &p_file) { epoints.resize(epc); PoolVector<Point2>::Write w = epoints.write(); - Size2 extents = Size2(img.get_width() * 0.5, img.get_height() * 0.5); + Size2 extents = Size2(img->get_width() * 0.5, img->get_height() * 0.5); for (int i = 0; i < epc; i++) { diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 4c84e831c1..dc2da80b06 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -329,7 +329,7 @@ void ParticlesEditor::_generate_emission_points() { copymem(iw.ptr(), r.ptr(), point_count * sizeof(float) * 3); } - Image image(w, h, false, Image::FORMAT_RGBF, point_img); + Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img)); Ref<ImageTexture> tex; tex.instance(); @@ -354,7 +354,7 @@ void ParticlesEditor::_generate_emission_points() { copymem(iw.ptr(), r.ptr(), point_count * sizeof(float) * 3); } - Image image2(w, h, false, Image::FORMAT_RGBF, point_img2); + Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2)); Ref<ImageTexture> tex2; tex2.instance(); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 01435028ac..3e46724efc 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -428,7 +428,7 @@ private: ViewportContainer *settings_light_base; Viewport *settings_light_vp; ColorPickerButton *settings_ambient_color; - Image settings_light_dir_image; + Ref<Image> settings_light_dir_image; void _xform_dialog_action(); void _menu_item_pressed(int p_option); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 4c49b467d8..89995edf05 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -678,12 +678,13 @@ void TextureRegionEditor::_edit_region() { } autoslice_cache.clear(); - Image i; - if (i.load(texture->get_path()) == OK) { + Ref<Image> i; + i.instance(); + if (i->load(texture->get_path()) == OK) { BitMap bm; bm.create_from_image_alpha(i); - for (int y = 0; y < i.get_height(); y++) { - for (int x = 0; x < i.get_width(); x++) { + for (int y = 0; y < i->get_height(); y++) { + for (int x = 0; x < i->get_width(); x++) { if (bm.get_bit(Point2(x, y))) { bool found = false; for (List<Rect2>::Element *E = autoslice_cache.front(); E; E = E->next()) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 289655e9da..2d3b3a2200 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -806,11 +806,12 @@ void ProjectManager::_load_recent_projects() { if (cf->has_section_key("application", "icon")) { String appicon = cf->get_value("application", "icon"); if (appicon != "") { - Image img; - Error err = img.load(appicon.replace_first("res://", path + "/")); + Ref<Image> img; + img.instance(); + Error err = img->load(appicon.replace_first("res://", path + "/")); if (err == OK) { - img.resize(64, 64); + img->resize(64, 64); Ref<ImageTexture> it = memnew(ImageTexture); it->create_from_image(img); icon = it; diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 3dd9ba080c..1bd00f3d1e 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -861,15 +861,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: */ } break; - case Variant::IMAGE: { - List<String> names; - names.push_back(TTR("New")); - names.push_back(TTR("Load")); - names.push_back(TTR("Clear")); - config_action_buttons(names); - - } break; case Variant::NODE_PATH: { List<String> names; @@ -1061,16 +1053,6 @@ void CustomPropertyEditor::_file_selected(String p_file) { emit_signal("variant_changed"); hide(); } break; - case Variant::IMAGE: { - - Image image; - Error err = ImageLoader::load_image(p_file, &image); - ERR_EXPLAIN(TTR("Couldn't load image")); - ERR_FAIL_COND(err); - v = image; - emit_signal("variant_changed"); - hide(); - } break; default: {} } } @@ -1387,36 +1369,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) { } } break; - case Variant::IMAGE: { - if (p_which == 0) { - //new image too difficult - ERR_PRINT("New Image Unimplemented"); - - } else if (p_which == 1) { - - file->set_access(EditorFileDialog::ACCESS_RESOURCES); - file->set_mode(EditorFileDialog::MODE_OPEN_FILE); - List<String> extensions; - ImageLoader::get_recognized_extensions(&extensions); - - file->clear_filters(); - - for (List<String>::Element *E = extensions.front(); E; E = E->next()) { - - file->add_filter("*." + E->get() + " ; " + E->get().to_upper()); - } - - file->popup_centered_ratio(); - - } else if (p_which == 2) { - - v = Image(); - emit_signal("variant_changed"); - hide(); - } - - } break; default: {}; } } @@ -1756,9 +1709,7 @@ void CustomPropertyEditor::_modified(String p_string) { emit_signal("variant_changed"); */ } break; - case Variant::IMAGE: { - } break; case Variant::NODE_PATH: { v = NodePath(value_editor[0]->get_text()); @@ -2357,15 +2308,6 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p //p_item->set_text(1,obj->get(p_name)); } break; - case Variant::IMAGE: { - - Image img = obj->get(p_name); - if (img.empty()) - p_item->set_text(1, "[Image (empty)]"); - else - p_item->set_text(1, "[Image " + itos(img.get_width()) + "x" + itos(img.get_height()) + "-" + String(Image::get_format_name(img.get_format())) + "]"); - - } break; case Variant::NODE_PATH: { p_item->set_text(1, obj->get(p_name)); @@ -3588,19 +3530,7 @@ void PropertyEditor::update_tree() { item->set_icon(0, get_icon("Color", "EditorIcons")); } break; - case Variant::IMAGE: { - item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); - item->set_editable(1, !read_only); - Image img = obj->get(p.name); - if (img.empty()) - item->set_text(1, "[Image (empty)]"); - else - item->set_text(1, "[Image " + itos(img.get_width()) + "x" + itos(img.get_height()) + "-" + String(Image::get_format_name(img.get_format())) + "]"); - if (show_type_icons) - item->set_icon(0, get_icon("Image", "EditorIcons")); - - } break; case Variant::NODE_PATH: { item->set_cell_mode(1, TreeItem::CELL_MODE_STRING); @@ -3922,9 +3852,7 @@ void PropertyEditor::_item_edited() { case Variant::COLOR: { //_edit_set(name,item->get_custom_bg_color(0)); } break; - case Variant::IMAGE: { - } break; case Variant::NODE_PATH: { _edit_set(name, NodePath(item->get_text(1)), refresh_all); diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 565d25e0e5..752965c806 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -136,7 +136,6 @@ void PropertySelector::_update_search() { 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/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 6edcd60188..ef875bbead 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -89,7 +89,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { args.push_back("-m"); Ref<ImageTexture> t = memnew(ImageTexture); - t->create_from_image(*p_image, 0); + t->create_from_image(Ref<Image>(p_image), 0); ResourceSaver::save(src_img, t); Error err = OS::get_singleton()->execute(ttpath, args, true); @@ -101,7 +101,7 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { ERR_EXPLAIN(TTR("Can't load back converted image using PVRTC tool:") + " " + dst_img); ERR_FAIL_COND(t.is_null()); - *p_image = t->get_data(); + p_image->copy_internals_from(t->get_data()); } static void _compress_pvrtc2(Image *p_image) { |