diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml index 2bea482bc101..5fef56e35483 100644 --- a/doc/classes/ImageTexture.xml +++ b/doc/classes/ImageTexture.xml @@ -18,11 +18,11 @@ var texture = load("res://icon.png") $Sprite2D.texture = texture [/codeblock] - This is because images have to be imported as [StreamTexture2D] first to be loaded with [method @GDScript.load]. If you'd still like to load an image file just like any other [Resource], import it as an [Image] resource instead, and then load it normally using the [method @GDScript.load] method. - But do note that the image data can still be retrieved from an imported texture as well using the [method Texture2D.get_data] method, which returns a copy of the data: + This is because images have to be imported as a [StreamTexture2D] first to be loaded with [method @GDScript.load]. If you'd still like to load an image file just like any other [Resource], import it as an [Image] resource instead, and then load it normally using the [method @GDScript.load] method. + [b]Note:[/b] The image can be retrieved from an imported texture using the [method Texture2D.get_image] method, which returns a copy of the image: [codeblock] var texture = load("res://icon.png") - var image : Image = texture.get_data() + var image : Image = texture.get_image() [/codeblock] An [ImageTexture] is not meant to be operated from within the editor interface directly, and is mostly useful for rendering images on screen dynamically via code. If you need to generate images procedurally from within the editor, consider saving and importing images as custom texture resources implementing a new [EditorImportPlugin]. [b]Note:[/b] The maximum texture size is 16384×16384 pixels due to graphics hardware limitations. diff --git a/doc/classes/Texture2D.xml b/doc/classes/Texture2D.xml index 2270b95c63d5..b648098a940f 100644 --- a/doc/classes/Texture2D.xml +++ b/doc/classes/Texture2D.xml @@ -63,7 +63,7 @@ Draws a part of the texture using a [CanvasItem] with the [RenderingServer] API. - + diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 8120ae539e7e..471d21374d03 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -80,9 +80,9 @@ Returns the viewport's texture. - [b]Note:[/b] Due to the way OpenGL works, the resulting [ViewportTexture] is flipped vertically. You can use [method Image.flip_y] on the result of [method Texture2D.get_data] to flip it back, for example: + [b]Note:[/b] Due to the way OpenGL works, the resulting [ViewportTexture] is flipped vertically. You can use [method Image.flip_y] on the result of [method Texture2D.get_image] to flip it back, for example: [codeblock] - var img = get_viewport().get_texture().get_data() + var img = get_viewport().get_texture().get_image() img.flip_y() [/codeblock] diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index f47fc403ccb5..b737a287d148 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -41,7 +41,7 @@ Error ResourceSaverPNG::save(const String &p_path, const RES &p_resource, uint32 ERR_FAIL_COND_V_MSG(!texture.is_valid(), ERR_INVALID_PARAMETER, "Can't save invalid texture as PNG."); ERR_FAIL_COND_V_MSG(!texture->get_width(), ERR_INVALID_PARAMETER, "Can't save empty texture as PNG."); - Ref img = texture->get_data(); + Ref img = texture->get_image(); Error err = save_image(p_path, img); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 156cb6694aec..21f1d0530487 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1381,14 +1381,14 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { } else if (c3d < c2d) { Ref viewport_texture = scene_root->get_texture(); if (viewport_texture->get_width() > 0 && viewport_texture->get_height() > 0) { - img = viewport_texture->get_data(); + img = viewport_texture->get_image(); } } else { // The 3D editor may be disabled as a feature, but scenes can still be opened. // This check prevents the preview from regenerating in case those scenes are then saved. Ref profile = feature_profile_manager->get_current_profile(); if (profile.is_valid() && !profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D)) { - img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data(); + img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_image(); } } @@ -2835,7 +2835,7 @@ void EditorNode::_save_screenshot(NodePath p_path) { ERR_FAIL_COND_MSG(!viewport, "Cannot get editor main control viewport."); Ref texture = viewport->get_texture(); ERR_FAIL_COND_MSG(texture.is_null(), "Cannot get editor main control viewport texture."); - Ref img = texture->get_data(); + Ref img = texture->get_image(); ERR_FAIL_COND_MSG(img.is_null(), "Cannot get editor main control viewport texture image."); Error error = img->save_png(p_path); ERR_FAIL_COND_MSG(error != OK, "Cannot save screenshot to file '" + p_path + "'."); @@ -5108,8 +5108,8 @@ Variant EditorNode::drag_resource(const Ref &p_res, Control *p_from) { { //todo make proper previews - Ref pic = gui_base->get_theme_icon("FileBigThumb", "EditorIcons"); - Ref img = pic->get_data(); + Ref texture = gui_base->get_theme_icon("FileBigThumb", "EditorIcons"); + Ref img = texture->get_image(); img = img->duplicate(); img->resize(48, 48); //meh Ref resized_pic = Ref(memnew(ImageTexture)); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 77288be61498..138830cdc65d 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -174,7 +174,7 @@ void EditorResourcePreview::_generate_preview(Ref &r_texture, Ref< } if (!r_small_texture.is_valid() && r_texture.is_valid() && preview_generators[i]->generate_small_preview_automatically()) { - Ref small_image = r_texture->get_data(); + Ref small_image = r_texture->get_image(); small_image = small_image->duplicate(); small_image->resize(small_thumbnail_size, small_thumbnail_size, Image::INTERPOLATE_CUBIC); r_small_texture.instance(); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 9b921343685a..1ffa20d1eae8 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -43,7 +43,7 @@ void EditorRunNative::_notification(int p_what) { } Ref icon = eep->get_run_icon(); if (!icon.is_null()) { - Ref im = icon->get_data(); + Ref im = icon->get_image(); im = im->duplicate(); im->clear_mipmaps(); if (!im->is_empty()) { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 4526ded68b9a..35cf330714e3 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -91,7 +91,7 @@ static Ref flip_icon(Ref p_texture, bool p_flip_y = false, } Ref texture(memnew(ImageTexture)); - Ref img = p_texture->get_data(); + Ref img = p_texture->get_image(); img = img->duplicate(); if (p_flip_y) { diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 7c623505b562..03481dfb38f0 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -117,8 +117,8 @@ void AnimationPlayerEditor::_notification(int p_what) { autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons"); reset_icon = get_theme_icon("Reload", "EditorIcons"); { - Ref autoplay_img = autoplay_icon->get_data(); - Ref reset_img = reset_icon->get_data(); + Ref autoplay_img = autoplay_icon->get_image(); + Ref reset_img = reset_icon->get_image(); Ref autoplay_reset_img; Size2 icon_size = Size2(autoplay_img->get_width(), autoplay_img->get_height()); autoplay_reset_img.instance(); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index b7484aa7482a..1345adc8ee65 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -144,8 +144,8 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const for (int i = 0; i < preview_images.size(); i++) { if (preview_images[i].id == p_index) { if (preview_images[i].is_video) { - Ref overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_data(); - Ref thumbnail = p_image->get_data(); + Ref overlay = previews->get_theme_icon("PlayOverlay", "EditorIcons")->get_image(); + Ref thumbnail = p_image->get_image(); thumbnail = thumbnail->duplicate(); Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index eb3c06fba155..d3e585478620 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -88,7 +88,7 @@ Ref EditorTexturePreviewPlugin::generate(const RES &p_from, const Siz return Ref(); } - Ref atlas = tex->get_data(); + Ref atlas = tex->get_image(); if (!atlas.is_valid()) { return Ref(); } @@ -99,7 +99,7 @@ Ref EditorTexturePreviewPlugin::generate(const RES &p_from, const Siz } else { Ref tex = p_from; if (tex.is_valid()) { - img = tex->get_data(); + img = tex->get_image(); if (img.is_valid()) { img = img->duplicate(); } diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp index 4acacf305892..4a7f6c0f7edf 100644 --- a/editor/plugins/sprite_2d_editor_plugin.cpp +++ b/editor/plugins/sprite_2d_editor_plugin.cpp @@ -171,7 +171,7 @@ void Sprite2DEditor::_update_mesh_data() { return; } - Ref image = texture->get_data(); + Ref image = texture->get_image(); ERR_FAIL_COND(image.is_null()); if (image->is_compressed()) { diff --git a/modules/fbx/tools/import_utils.h b/modules/fbx/tools/import_utils.h index 6261138812a4..bea28ffeda11 100644 --- a/modules/fbx/tools/import_utils.h +++ b/modules/fbx/tools/import_utils.h @@ -339,7 +339,7 @@ public: // } else { // Ref texture = ResourceLoader::load(p_path); // ERR_FAIL_COND_V(texture.is_null(), Ref()); - // Ref image = texture->get_data(); + // Ref image = texture->get_image(); // ERR_FAIL_COND_V(image.is_null(), Ref()); // state.path_to_image_cache.insert(p_path, image); // return image; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index d6e67a78d747..8fe83436e09f 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -2821,7 +2821,7 @@ Error GLTFDocument::_serialize_images(Ref state, const String &p_path ERR_CONTINUE(state->images[i].is_null()); - Ref image = state->images[i]->get_data(); + Ref image = state->images[i]->get_image(); ERR_CONTINUE(image.is_null()); if (p_path.to_lower().ends_with("glb")) { @@ -2838,7 +2838,7 @@ Error GLTFDocument::_serialize_images(Ref state, const String &p_path Vector buffer; Ref img_tex = image; if (img_tex.is_valid()) { - image = img_tex->get_data(); + image = img_tex->get_image(); } Error err = PNGDriverCommon::image_to_png(image, buffer); ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG."); @@ -3068,7 +3068,7 @@ GLTFTextureIndex GLTFDocument::_set_texture(Ref state, Ref ERR_FAIL_COND_V(p_texture.is_null(), -1); Ref gltf_texture; gltf_texture.instance(); - ERR_FAIL_COND_V(p_texture->get_data().is_null(), -1); + ERR_FAIL_COND_V(p_texture->get_image().is_null(), -1); GLTFImageIndex gltf_src_image_i = state->images.size(); state->images.push_back(p_texture); gltf_texture->set_src_image(gltf_src_image_i); @@ -3115,7 +3115,7 @@ Error GLTFDocument::_serialize_materials(Ref state) { Ref albedo_texture = material->get_texture(BaseMaterial3D::TEXTURE_ALBEDO); GLTFTextureIndex gltf_texture_index = -1; - if (albedo_texture.is_valid() && albedo_texture->get_data().is_valid()) { + if (albedo_texture.is_valid() && albedo_texture->get_image().is_valid()) { albedo_texture->set_name(material->get_name() + "_albedo"); gltf_texture_index = _set_texture(state, albedo_texture); } @@ -3128,9 +3128,9 @@ Error GLTFDocument::_serialize_materials(Ref state) { mr["metallicFactor"] = material->get_metallic(); mr["roughnessFactor"] = material->get_roughness(); - bool has_roughness = material->get_texture(BaseMaterial3D::TEXTURE_ROUGHNESS).is_valid() && material->get_texture(BaseMaterial3D::TEXTURE_ROUGHNESS)->get_data().is_valid(); + bool has_roughness = material->get_texture(BaseMaterial3D::TEXTURE_ROUGHNESS).is_valid() && material->get_texture(BaseMaterial3D::TEXTURE_ROUGHNESS)->get_image().is_valid(); bool has_ao = material->get_feature(BaseMaterial3D::FEATURE_AMBIENT_OCCLUSION) && material->get_texture(BaseMaterial3D::TEXTURE_AMBIENT_OCCLUSION).is_valid(); - bool has_metalness = material->get_texture(BaseMaterial3D::TEXTURE_METALLIC).is_valid() && material->get_texture(BaseMaterial3D::TEXTURE_METALLIC)->get_data().is_valid(); + bool has_metalness = material->get_texture(BaseMaterial3D::TEXTURE_METALLIC).is_valid() && material->get_texture(BaseMaterial3D::TEXTURE_METALLIC)->get_image().is_valid(); if (has_ao || has_roughness || has_metalness) { Dictionary mrt; Ref roughness_texture = material->get_texture(BaseMaterial3D::TEXTURE_ROUGHNESS); @@ -3149,10 +3149,10 @@ Error GLTFDocument::_serialize_materials(Ref state) { if (has_ao) { height = ao_texture->get_height(); width = ao_texture->get_width(); - ao_image = ao_texture->get_data(); + ao_image = ao_texture->get_image(); Ref img_tex = ao_image; if (img_tex.is_valid()) { - ao_image = img_tex->get_data(); + ao_image = img_tex->get_image(); } if (ao_image->is_compressed()) { ao_image->decompress(); @@ -3162,10 +3162,10 @@ Error GLTFDocument::_serialize_materials(Ref state) { if (has_roughness) { height = roughness_texture->get_height(); width = roughness_texture->get_width(); - roughness_image = roughness_texture->get_data(); + roughness_image = roughness_texture->get_image(); Ref img_tex = roughness_image; if (img_tex.is_valid()) { - roughness_image = img_tex->get_data(); + roughness_image = img_tex->get_image(); } if (roughness_image->is_compressed()) { roughness_image->decompress(); @@ -3175,17 +3175,17 @@ Error GLTFDocument::_serialize_materials(Ref state) { if (has_metalness) { height = metallic_texture->get_height(); width = metallic_texture->get_width(); - metallness_image = metallic_texture->get_data(); + metallness_image = metallic_texture->get_image(); Ref img_tex = metallness_image; if (img_tex.is_valid()) { - metallness_image = img_tex->get_data(); + metallness_image = img_tex->get_image(); } if (metallness_image->is_compressed()) { metallness_image->decompress(); } } Ref albedo_texture = material->get_texture(BaseMaterial3D::TEXTURE_ALBEDO); - if (albedo_texture.is_valid() && albedo_texture->get_data().is_valid()) { + if (albedo_texture.is_valid() && albedo_texture->get_image().is_valid()) { height = albedo_texture->get_height(); width = albedo_texture->get_width(); } @@ -3266,10 +3266,10 @@ Error GLTFDocument::_serialize_materials(Ref state) { { Ref normal_texture = material->get_texture(BaseMaterial3D::TEXTURE_NORMAL); // Code for uncompressing RG normal maps - Ref img = normal_texture->get_data(); + Ref img = normal_texture->get_image(); Ref img_tex = img; if (img_tex.is_valid()) { - img = img_tex->get_data(); + img = img_tex->get_image(); } img->decompress(); img->convert(Image::FORMAT_RGBA8); @@ -3288,7 +3288,7 @@ Error GLTFDocument::_serialize_materials(Ref state) { } Ref normal_texture = material->get_texture(BaseMaterial3D::TEXTURE_NORMAL); GLTFTextureIndex gltf_texture_index = -1; - if (tex.is_valid() && tex->get_data().is_valid()) { + if (tex.is_valid() && tex->get_image().is_valid()) { tex->set_name(material->get_name() + "_normal"); gltf_texture_index = _set_texture(state, tex); } @@ -3311,7 +3311,7 @@ Error GLTFDocument::_serialize_materials(Ref state) { Dictionary et; Ref emission_texture = material->get_texture(BaseMaterial3D::TEXTURE_EMISSION); GLTFTextureIndex gltf_texture_index = -1; - if (emission_texture.is_valid() && emission_texture->get_data().is_valid()) { + if (emission_texture.is_valid() && emission_texture->get_image().is_valid()) { emission_texture->set_name(material->get_name() + "_emission"); gltf_texture_index = _set_texture(state, emission_texture); } @@ -3370,7 +3370,7 @@ Error GLTFDocument::_parse_materials(Ref state) { if (diffuse_texture_dict.has("index")) { Ref diffuse_texture = _get_texture(state, diffuse_texture_dict["index"]); if (diffuse_texture.is_valid()) { - spec_gloss->diffuse_img = diffuse_texture->get_data(); + spec_gloss->diffuse_img = diffuse_texture->get_image(); material->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, diffuse_texture); } } @@ -3398,7 +3398,7 @@ Error GLTFDocument::_parse_materials(Ref state) { if (spec_gloss_texture.has("index")) { const Ref orig_texture = _get_texture(state, spec_gloss_texture["index"]); if (orig_texture.is_valid()) { - spec_gloss->spec_gloss_img = orig_texture->get_data(); + spec_gloss->spec_gloss_img = orig_texture->get_image(); } } } diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml index 86e7f9cc08fe..38c5138482a2 100644 --- a/modules/opensimplex/doc_classes/NoiseTexture.xml +++ b/modules/opensimplex/doc_classes/NoiseTexture.xml @@ -6,11 +6,12 @@ Uses an [OpenSimplexNoise] to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures. NoiseTexture can also generate normal map textures. - The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_data] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the data: + The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_image] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the image and the generated byte data: [codeblock] var texture = preload("res://noise.tres") yield(texture, "changed") - var image = texture.get_data() + var image = texture.get_image() + var data = image.get_data() [/codeblock] diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index f5d401b05805..7272d32facfd 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -81,9 +81,9 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const { } } -void NoiseTexture::_set_texture_data(const Ref &p_image) { - data = p_image; - if (data.is_valid()) { +void NoiseTexture::_set_texture_image(const Ref &p_image) { + image = p_image; + if (image.is_valid()) { if (texture.is_valid()) { RID new_texture = RS::get_singleton()->texture_2d_create(p_image); RS::get_singleton()->texture_replace(texture, new_texture); @@ -95,7 +95,7 @@ void NoiseTexture::_set_texture_data(const Ref &p_image) { } void NoiseTexture::_thread_done(const Ref &p_image) { - _set_texture_data(p_image); + _set_texture_image(p_image); noise_thread.wait_to_finish(); if (regen_queued) { noise_thread.start(_thread_function, this); @@ -159,7 +159,7 @@ void NoiseTexture::_update_texture() { } else { Ref image = _generate_texture(); - _set_texture_data(image); + _set_texture_image(image); } update_queued = false; } @@ -253,6 +253,6 @@ RID NoiseTexture::get_rid() const { return texture; } -Ref NoiseTexture::get_data() const { - return data; +Ref NoiseTexture::get_image() const { + return image; } diff --git a/modules/opensimplex/noise_texture.h b/modules/opensimplex/noise_texture.h index e89479d962fb..6983ae18feb4 100644 --- a/modules/opensimplex/noise_texture.h +++ b/modules/opensimplex/noise_texture.h @@ -43,7 +43,7 @@ class NoiseTexture : public Texture2D { GDCLASS(NoiseTexture, Texture2D); private: - Ref data; + Ref image; Thread noise_thread; @@ -66,7 +66,7 @@ private: void _queue_update(); Ref _generate_texture(); void _update_texture(); - void _set_texture_data(const Ref &p_image); + void _set_texture_image(const Ref &p_image); protected: static void _bind_methods(); @@ -94,7 +94,7 @@ public: virtual RID get_rid() const override; virtual bool has_alpha() const override { return false; } - virtual Ref get_data() const override; + virtual Ref get_image() const override; NoiseTexture(); virtual ~NoiseTexture(); diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index c10fb40ecbcc..fa6f5c1e9e64 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -341,7 +341,7 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso Rect2 atlas_rect; if (texture.is_valid()) { - image = texture->get_data(); + image = texture->get_image(); } if (!image.is_valid() && atlas_texture.is_valid()) { @@ -364,7 +364,7 @@ void DisplayServerJavaScript::cursor_set_custom_image(const RES &p_cursor, Curso ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256); ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height); - image = texture->get_data(); + image = texture->get_image(); ERR_FAIL_COND(!image.is_valid()); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 27b9d9485a9e..d6ed416d7cee 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -1917,7 +1917,7 @@ void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape Rect2i atlas_rect; if (texture.is_valid()) { - image = texture->get_data(); + image = texture->get_image(); } if (!image.is_valid() && atlas_texture.is_valid()) { @@ -1940,7 +1940,7 @@ void DisplayServerX11::cursor_set_custom_image(const RES &p_cursor, CursorShape ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256); ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height); - image = texture->get_data(); + image = texture->get_image(); ERR_FAIL_COND(!image.is_valid()); diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 412dd59f56ab..6b838b6d14a2 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -3117,7 +3117,7 @@ void DisplayServerOSX::cursor_set_custom_image(const RES &p_cursor, CursorShape Rect2 atlas_rect; if (texture.is_valid()) { - image = texture->get_data(); + image = texture->get_image(); } if (!image.is_valid() && atlas_texture.is_valid()) { @@ -3140,7 +3140,7 @@ void DisplayServerOSX::cursor_set_custom_image(const RES &p_cursor, CursorShape ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256); ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height); - image = texture->get_data(); + image = texture->get_image(); ERR_FAIL_COND(!image.is_valid()); diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 1aad2bfa1aae..2a0bc78440f0 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -855,33 +855,33 @@ class EditorExportPlatformUWP : public EditorExportPlatform { Vector _get_image_data(const Ref &p_preset, const String &p_path) { Vector data; - StreamTexture2D *image = nullptr; + StreamTexture2D *texture = nullptr; if (p_path.find("StoreLogo") != -1) { - image = p_preset->get("images/store_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/store_logo"))); + texture = p_preset->get("images/store_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/store_logo"))); } else if (p_path.find("Square44x44Logo") != -1) { - image = p_preset->get("images/square44x44_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square44x44_logo"))); + texture = p_preset->get("images/square44x44_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square44x44_logo"))); } else if (p_path.find("Square71x71Logo") != -1) { - image = p_preset->get("images/square71x71_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square71x71_logo"))); + texture = p_preset->get("images/square71x71_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square71x71_logo"))); } else if (p_path.find("Square150x150Logo") != -1) { - image = p_preset->get("images/square150x150_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square150x150_logo"))); + texture = p_preset->get("images/square150x150_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square150x150_logo"))); } else if (p_path.find("Square310x310Logo") != -1) { - image = p_preset->get("images/square310x310_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square310x310_logo"))); + texture = p_preset->get("images/square310x310_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/square310x310_logo"))); } else if (p_path.find("Wide310x150Logo") != -1) { - image = p_preset->get("images/wide310x150_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/wide310x150_logo"))); + texture = p_preset->get("images/wide310x150_logo").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/wide310x150_logo"))); } else if (p_path.find("SplashScreen") != -1) { - image = p_preset->get("images/splash_screen").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/splash_screen"))); + texture = p_preset->get("images/splash_screen").is_zero() ? nullptr : Object::cast_to(((Object *)p_preset->get("images/splash_screen"))); } else { ERR_PRINT("Unable to load logo"); } - if (!image) { + if (!texture) { return data; } String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("uwp_tmp_logo.png"); - Error err = image->get_data()->save_png(tmp_path); + Error err = texture->get_image()->save_png(tmp_path); if (err != OK) { String err_string = "Couldn't save temp logo file."; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 4d81afc5dde7..78459b4f45dd 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1299,7 +1299,7 @@ void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorSh Rect2 atlas_rect; if (texture.is_valid()) { - image = texture->get_data(); + image = texture->get_image(); } if (!image.is_valid() && atlas_texture.is_valid()) { @@ -1322,7 +1322,7 @@ void DisplayServerWindows::cursor_set_custom_image(const RES &p_cursor, CursorSh ERR_FAIL_COND(texture_size.width > 256 || texture_size.height > 256); ERR_FAIL_COND(p_hotspot.x > texture_size.width || p_hotspot.y > texture_size.height); - image = texture->get_data(); + image = texture->get_image(); ERR_FAIL_COND(!image.is_valid()); diff --git a/scene/3d/voxelizer.cpp b/scene/3d/voxelizer.cpp index 16718b956f1c..1b9ce0201fba 100644 --- a/scene/3d/voxelizer.cpp +++ b/scene/3d/voxelizer.cpp @@ -344,7 +344,7 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref p_material Ref img_albedo; if (albedo_tex.is_valid()) { - img_albedo = albedo_tex->get_data(); + img_albedo = albedo_tex->get_image(); mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), Color(0, 0, 0)); // albedo texture, color is multiplicative } else { mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive @@ -358,7 +358,7 @@ Voxelizer::MaterialCache Voxelizer::_get_material_cache(Ref p_material Ref img_emission; if (emission_tex.is_valid()) { - img_emission = emission_tex->get_data(); + img_emission = emission_tex->get_image(); } if (mat->get_emission_operator() == StandardMaterial3D::EMISSION_OP_ADD) { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 5822119b46bb..a919ae8dd0ee 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -682,7 +682,7 @@ void ColorPicker::_screen_input(const Ref &p_event) { return; } - Ref img = r->get_texture()->get_data(); + Ref img = r->get_texture()->get_image(); if (img.is_valid() && !img->is_empty()) { Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position(); Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y); diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index b18b2afb6dec..55529517f11a 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -1511,9 +1511,9 @@ bool CanvasTexture::has_alpha() const { } } -Ref CanvasTexture::get_data() const { +Ref CanvasTexture::get_image() const { if (diffuse_texture.is_valid()) { - return diffuse_texture->get_data(); + return diffuse_texture->get_image(); } else { return Ref(); } diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h index 0f86f2e0f831..1c64cafab8fd 100644 --- a/scene/main/canvas_item.h +++ b/scene/main/canvas_item.h @@ -475,7 +475,7 @@ public: virtual bool is_pixel_opaque(int p_x, int p_y) const override; virtual bool has_alpha() const override; - virtual Ref get_data() const override; + virtual Ref get_image() const override; virtual RID get_rid() const override; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c6fe1117d105..5df35d1e6a20 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -131,7 +131,7 @@ bool ViewportTexture::has_alpha() const { return false; } -Ref ViewportTexture::get_data() const { +Ref ViewportTexture::get_image() const { ERR_FAIL_COND_V_MSG(!vp, Ref(), "Viewport Texture must be set to use it."); return RS::get_singleton()->texture_2d_get(vp->texture_rid); } diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 0f11e6fb19fb..8e79b5038581 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -77,7 +77,7 @@ public: virtual bool has_alpha() const override; - virtual Ref get_data() const override; + virtual Ref get_image() const override; ViewportTexture(); ~ViewportTexture(); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 854001f39783..85d097aa19c3 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -114,7 +114,7 @@ static Ref flip_icon(Ref p_texture, bool p_flip_y = false, } Ref texture(memnew(ImageTexture)); - Ref img = p_texture->get_data(); + Ref img = p_texture->get_image(); img = img->duplicate(); if (p_flip_y) { diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index d2bb1338d8a5..b6a2f24b8b8f 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -71,7 +71,7 @@ void Texture2D::_bind_methods() { ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false)); ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false)); ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data); + ClassDB::bind_method(D_METHOD("get_image"), &Texture2D::get_image); ADD_GROUP("", ""); } @@ -116,7 +116,7 @@ bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) { bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const { if (p_name == "image") { - r_ret = get_data(); + r_ret = get_image(); } else if (p_name == "size") { r_ret = Size2(w, h); } else { @@ -200,7 +200,7 @@ void ImageTexture::_resource_path_changed() { String path = get_path(); } -Ref ImageTexture::get_data() const { +Ref ImageTexture::get_image() const { if (image_stored) { return RenderingServer::get_singleton()->texture_2d_get(texture); } else { @@ -251,7 +251,7 @@ void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const { if (!alpha_cache.is_valid()) { - Ref img = get_data(); + Ref img = get_image(); if (img.is_valid()) { if (img->is_compressed()) { //must decompress, if compressed Ref decom = img->duplicate(); @@ -661,7 +661,7 @@ bool StreamTexture2D::has_alpha() const { return false; } -Ref StreamTexture2D::get_data() const { +Ref StreamTexture2D::get_image() const { if (texture.is_valid()) { return RS::get_singleton()->texture_2d_get(texture); } else { @@ -671,7 +671,7 @@ Ref StreamTexture2D::get_data() const { bool StreamTexture2D::is_pixel_opaque(int p_x, int p_y) const { if (!alpha_cache.is_valid()) { - Ref img = get_data(); + Ref img = get_image(); if (img.is_valid()) { if (img->is_compressed()) { //must decompress, if compressed Ref decom = img->duplicate(); @@ -1495,7 +1495,7 @@ Ref LargeTexture::get_piece_texture(int p_idx) const { Ref LargeTexture::to_image() const { Ref img = memnew(Image(this->get_width(), this->get_height(), false, Image::FORMAT_RGBA8)); for (int i = 0; i < pieces.size(); i++) { - Ref src_img = pieces[i].texture->get_data(); + Ref src_img = pieces[i].texture->get_image(); img->blit_rect(src_img, Rect2(0, 0, src_img->get_width(), src_img->get_height()), pieces[i].offset); } @@ -1782,7 +1782,7 @@ int GradientTexture::get_width() const { return width; } -Ref GradientTexture::get_data() const { +Ref GradientTexture::get_image() const { if (!texture.is_valid()) { return Ref(); } @@ -2031,14 +2031,14 @@ bool AnimatedTexture::has_alpha() const { return frames[current_frame].texture->has_alpha(); } -Ref AnimatedTexture::get_data() const { +Ref AnimatedTexture::get_image() const { RWLockRead r(rw_lock); if (!frames[current_frame].texture.is_valid()) { return Ref(); } - return frames[current_frame].texture->get_data(); + return frames[current_frame].texture->get_image(); } bool AnimatedTexture::is_pixel_opaque(int p_x, int p_y) const { @@ -2543,7 +2543,7 @@ uint32_t CameraTexture::get_flags() const { return 0; } -Ref CameraTexture::get_data() const { +Ref CameraTexture::get_image() const { // not (yet) supported return Ref(); } diff --git a/scene/resources/texture.h b/scene/resources/texture.h index a0d917fd862a..16c98f28917a 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -71,7 +71,7 @@ public: virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const; virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const; - virtual Ref get_data() const { return Ref(); } + virtual Ref get_image() const { return Ref(); } Texture2D(); }; @@ -108,7 +108,7 @@ public: Image::Format get_format() const; void update(const Ref &p_image, bool p_immediate = false); - Ref get_data() const override; + Ref get_image() const override; int get_width() const override; int get_height() const override; @@ -203,7 +203,7 @@ public: virtual bool has_alpha() const override; bool is_pixel_opaque(int p_x, int p_y) const override; - virtual Ref get_data() const override; + virtual Ref get_image() const override; StreamTexture2D(); ~StreamTexture2D(); @@ -716,7 +716,7 @@ public: virtual int get_height() const override { return 1; } virtual bool has_alpha() const override { return true; } - virtual Ref get_data() const override; + virtual Ref get_image() const override; GradientTexture(); virtual ~GradientTexture(); @@ -812,7 +812,7 @@ public: virtual bool has_alpha() const override; - virtual Ref get_data() const override; + virtual Ref get_image() const override; bool is_pixel_opaque(int p_x, int p_y) const override; @@ -839,7 +839,7 @@ public: virtual void set_flags(uint32_t p_flags); virtual uint32_t get_flags() const; - virtual Ref get_data() const override; + virtual Ref get_image() const override; void set_camera_feed_id(int p_new_id); int get_camera_feed_id() const;