From d2900429e81175a9f48240b180f1d8e3ab52865c Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 4 May 2022 01:49:20 +0200 Subject: Add static methods for creating Image and ImageTexture --- platform/android/export/export_plugin.cpp | 9 ++------- platform/iphone/export/export_plugin.cpp | 6 +----- platform/javascript/export/export_plugin.cpp | 9 ++------- platform/linuxbsd/export/export.cpp | 7 +------ platform/osx/display_server_osx.mm | 5 +---- platform/osx/export/export_plugin.cpp | 6 ++---- platform/uwp/export/export_plugin.cpp | 4 +--- platform/windows/export/export.cpp | 7 +------ 8 files changed, 11 insertions(+), 42 deletions(-) (limited to 'platform') diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index d72137e523..2cfb152804 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -3118,13 +3118,8 @@ void EditorExportPlatformAndroid::resolve_platform_feature_priorities(const Ref< } EditorExportPlatformAndroid::EditorExportPlatformAndroid() { - Ref img = memnew(Image(_android_logo)); - logo.instantiate(); - logo->create_from_image(img); - - img = Ref(memnew(Image(_android_run_icon))); - run_icon.instantiate(); - run_icon->create_from_image(img); + logo = ImageTexture::create_from_image(memnew(Image(_android_logo))); + run_icon = ImageTexture::create_from_image(memnew(Image(_android_run_icon))); devices_changed.set(); plugins_changed.set(); diff --git a/platform/iphone/export/export_plugin.cpp b/platform/iphone/export/export_plugin.cpp index 4cf1c279eb..3b92bd19be 100644 --- a/platform/iphone/export/export_plugin.cpp +++ b/platform/iphone/export/export_plugin.cpp @@ -1838,12 +1838,8 @@ bool EditorExportPlatformIOS::can_export(const Ref &p_preset } EditorExportPlatformIOS::EditorExportPlatformIOS() { - Ref img = memnew(Image(_iphone_logo)); - logo.instantiate(); - logo->create_from_image(img); - + logo = ImageTexture::create_from_image(memnew(Image(_iphone_logo))); plugins_changed.set(); - check_for_changes_thread.start(_check_for_changes_poll_thread, this); } diff --git a/platform/javascript/export/export_plugin.cpp b/platform/javascript/export/export_plugin.cpp index 901580c140..e2ae45627e 100644 --- a/platform/javascript/export/export_plugin.cpp +++ b/platform/javascript/export/export_plugin.cpp @@ -661,13 +661,8 @@ EditorExportPlatformJavaScript::EditorExportPlatformJavaScript() { server.instantiate(); server_thread.start(_server_thread_poll, this); - Ref img = memnew(Image(_javascript_logo)); - logo.instantiate(); - logo->create_from_image(img); - - img = Ref(memnew(Image(_javascript_run_icon))); - run_icon.instantiate(); - run_icon->create_from_image(img); + logo = ImageTexture::create_from_image(memnew(Image(_javascript_logo))); + run_icon = ImageTexture::create_from_image(memnew(Image(_javascript_run_icon))); Ref theme = EditorNode::get_singleton()->get_editor_theme(); if (theme.is_valid()) { diff --git a/platform/linuxbsd/export/export.cpp b/platform/linuxbsd/export/export.cpp index 965b969ba8..4240e9adc0 100644 --- a/platform/linuxbsd/export/export.cpp +++ b/platform/linuxbsd/export/export.cpp @@ -35,12 +35,7 @@ void register_linuxbsd_exporter() { Ref platform; platform.instantiate(); - - Ref img = memnew(Image(_linuxbsd_logo)); - Ref logo; - logo.instantiate(); - logo->create_from_image(img); - platform->set_logo(logo); + platform->set_logo(ImageTexture::create_from_image(memnew(Image(_linuxbsd_logo)))); platform->set_name("Linux/X11"); platform->set_extension("x86_32"); platform->set_extension("x86_64", "binary_format/64_bits"); diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 4307685422..91d64b50f0 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -1178,10 +1178,7 @@ Ref DisplayServerOSX::global_menu_get_item_icon(const String &p_menu_ GodotMenuItem *obj = [menu_item representedObject]; if (obj) { if (obj->img.is_valid()) { - Ref txt; - txt.instantiate(); - txt->create_from_image(obj->img); - return txt; + return ImageTexture::create_from_image(obj->img); } } } diff --git a/platform/osx/export/export_plugin.cpp b/platform/osx/export/export_plugin.cpp index 00a7e54131..a22d7e5e3d 100644 --- a/platform/osx/export/export_plugin.cpp +++ b/platform/osx/export/export_plugin.cpp @@ -252,7 +252,7 @@ void EditorExportPlatformOSX::_make_icon(const Ref &p_icon, Vectorcreate_from_image(copy); + it->set_image(copy); String path = EditorPaths::get_singleton()->get_cache_dir().plus_file("icon.png"); ResourceSaver::save(path, it); @@ -1666,9 +1666,7 @@ bool EditorExportPlatformOSX::can_export(const Ref &p_preset } EditorExportPlatformOSX::EditorExportPlatformOSX() { - Ref img = memnew(Image(_osx_logo)); - logo.instantiate(); - logo->create_from_image(img); + logo = ImageTexture::create_from_image(memnew(Image(_osx_logo))); } EditorExportPlatformOSX::~EditorExportPlatformOSX() { diff --git a/platform/uwp/export/export_plugin.cpp b/platform/uwp/export/export_plugin.cpp index 01683c656c..19b43d50be 100644 --- a/platform/uwp/export/export_plugin.cpp +++ b/platform/uwp/export/export_plugin.cpp @@ -503,7 +503,5 @@ void EditorExportPlatformUWP::resolve_platform_feature_priorities(const Ref img = memnew(Image(_uwp_logo)); - logo.instantiate(); - logo->create_from_image(img); + logo = ImageTexture::create_from_image(memnew(Image(_uwp_logo))); } diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 0fa2913218..af19f24f09 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -48,12 +48,7 @@ void register_windows_exporter() { Ref platform; platform.instantiate(); - - Ref img = memnew(Image(_windows_logo)); - Ref logo; - logo.instantiate(); - logo->create_from_image(img); - platform->set_logo(logo); + platform->set_logo(ImageTexture::create_from_image(memnew(Image(_windows_logo)))); platform->set_name("Windows Desktop"); platform->set_os_name("Windows"); -- cgit v1.2.3