Browse Source

Rename SVGTexture to DPITexture.

Pāvels Nadtočajevs 2 weeks ago
parent
commit
10e11ec87f

+ 7 - 7
doc/classes/SVGTexture.xml → doc/classes/DPITexture.xml

@@ -1,22 +1,22 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<class name="SVGTexture" inherits="Texture2D" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
+<class name="DPITexture" inherits="Texture2D" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
 	<brief_description>
-		A scalable [Texture2D] based on an SVG image.
+		An automatically scalable [Texture2D] based on an SVG image.
 	</brief_description>
 	<description>
-		A scalable [Texture2D] based on an SVG image. [SVGTexture]s are automatically re-rasterized to match font oversampling.
+		An automatically scalable [Texture2D] based on an SVG image. [DPITexture]s are used to automatically re-rasterize icons and other texture based UI theme elements to match viewport scale and font oversampling. See also [member ProjectSettings.display/window/stretch/mode] ("canvas_items" mode) and [member Viewport.oversampling_override].
 	</description>
 	<tutorials>
 	</tutorials>
 	<methods>
 		<method name="create_from_string" qualifiers="static">
-			<return type="SVGTexture" />
+			<return type="DPITexture" />
 			<param index="0" name="source" type="String" />
 			<param index="1" name="scale" type="float" default="1.0" />
 			<param index="2" name="saturation" type="float" default="1.0" />
 			<param index="3" name="color_map" type="Dictionary" default="{}" />
 			<description>
-				Creates a new [SVGTexture] and initializes it by allocating and setting the SVG data from string.
+				Creates a new [DPITexture] and initializes it by allocating and setting the SVG data from string.
 			</description>
 		</method>
 		<method name="get_scaled_rid" qualifiers="const">
@@ -48,10 +48,10 @@
 	</methods>
 	<members>
 		<member name="base_scale" type="float" setter="set_base_scale" getter="get_base_scale" default="1.0">
-			SVG texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
+			Texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
 		</member>
 		<member name="color_map" type="Dictionary" setter="set_color_map" getter="get_color_map" default="{}">
-			If set, remaps SVG texture colors according to [Color]-[Color] map.
+			If set, remaps texture colors according to [Color]-[Color] map.
 		</member>
 		<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="false" />
 		<member name="saturation" type="float" setter="set_saturation" getter="get_saturation" default="1.0">

+ 1 - 1
doc/classes/ProjectSettings.xml

@@ -1194,7 +1194,7 @@
 			Maximum undo/redo history size for [TextEdit] fields.
 		</member>
 		<member name="gui/fonts/dynamic_fonts/use_oversampling" type="bool" setter="" getter="" default="true">
-			If set to [code]true[/code] and [member display/window/stretch/mode] is set to [b]"canvas_items"[/b], font and [SVGTexture] oversampling is enabled in the main window. Use [member Viewport.oversampling] to control oversampling in other viewports and windows.
+			If set to [code]true[/code] and [member display/window/stretch/mode] is set to [b]"canvas_items"[/b], font and [DPITexture] oversampling is enabled in the main window. Use [member Viewport.oversampling] to control oversampling in other viewports and windows.
 		</member>
 		<member name="gui/theme/custom" type="String" setter="" getter="" default="&quot;&quot;">
 			Path to a custom [Theme] resource file to use for the project ([code].theme[/code] or generic [code].tres[/code]/[code].res[/code] extension).

+ 4 - 4
doc/classes/ResourceImporterSVG.xml

@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <class name="ResourceImporterSVG" inherits="ResourceImporter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
 	<brief_description>
-		Imports an SVG file as a scalable texture for use in 2D or 3D rendering.
+		Imports an SVG file as an automatically scalable texture for use in UI elements and 2D rendering.
 	</brief_description>
 	<description>
-		This importer imports [SVGTexture] resources. See also [ResourceImporterTexture] and [ResourceImporterImage].
+		This importer imports [DPITexture] resources. See also [ResourceImporterTexture] and [ResourceImporterImage].
 	</description>
 	<tutorials>
 	</tutorials>
 	<members>
 		<member name="base_scale" type="float" setter="" getter="" default="1.0">
-			SVG texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
+			Texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
 		</member>
 		<member name="color_map" type="Dictionary" setter="" getter="" default="{}">
-			If set, remaps SVG texture colors according to [Color]-[Color] map.
+			If set, remaps texture colors according to [Color]-[Color] map.
 		</member>
 		<member name="compress" type="bool" setter="" getter="" default="true">
 			If [code]true[/code], uses lossless compression for the SVG source.

+ 1 - 1
doc/classes/Viewport.xml

@@ -376,7 +376,7 @@
 			See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa_3d] and [method RenderingServer.viewport_set_msaa_3d].
 		</member>
 		<member name="oversampling" type="bool" setter="set_use_oversampling" getter="is_using_oversampling" default="true">
-			If [code]true[/code] and one of the following conditions is true: [member SubViewport.size_2d_override_stretch] and [member SubViewport.size_2d_override] are set, [member Window.content_scale_factor] is set and scaling is enabled, [member oversampling_override] is set, font and [SVGTexture] oversampling is enabled.
+			If [code]true[/code] and one of the following conditions are true: [member SubViewport.size_2d_override_stretch] and [member SubViewport.size_2d_override] are set, [member Window.content_scale_factor] is set and scaling is enabled, [member oversampling_override] is set, font and [DPITexture] oversampling are enabled.
 		</member>
 		<member name="oversampling_override" type="float" setter="set_oversampling_override" getter="get_oversampling_override" default="0.0">
 			If greater than zero, this value is used as the font oversampling factor, otherwise oversampling is equal to viewport scale.

+ 15 - 15
editor/import/resource_importer_svg.cpp

@@ -31,14 +31,14 @@
 #include "resource_importer_svg.h"
 
 #include "core/io/file_access.h"
-#include "scene/resources/svg_texture.h"
+#include "scene/resources/dpi_texture.h"
 
 String ResourceImporterSVG::get_importer_name() const {
 	return "svg";
 }
 
 String ResourceImporterSVG::get_visible_name() const {
-	return "SVGTexture";
+	return "DPITexture";
 }
 
 void ResourceImporterSVG::get_recognized_extensions(List<String> *p_extensions) const {
@@ -46,11 +46,11 @@ void ResourceImporterSVG::get_recognized_extensions(List<String> *p_extensions)
 }
 
 String ResourceImporterSVG::get_save_extension() const {
-	return "svgtex";
+	return "dpitex";
 }
 
 String ResourceImporterSVG::get_resource_type() const {
-	return "SVGTexture";
+	return "DPITexture";
 }
 
 bool ResourceImporterSVG::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
@@ -73,8 +73,8 @@ void ResourceImporterSVG::get_import_options(const String &p_path, List<ImportOp
 }
 
 Error ResourceImporterSVG::import(ResourceUID::ID p_source_id, const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
-	Ref<SVGTexture> svg_tex;
-	svg_tex.instantiate();
+	Ref<DPITexture> dpi_tex;
+	dpi_tex.instantiate();
 
 	String source = FileAccess::get_file_as_string(p_source_file);
 	ERR_FAIL_COND_V_MSG(source.is_empty(), ERR_CANT_OPEN, vformat("Cannot open file from path \"%s\".", p_source_file));
@@ -83,22 +83,22 @@ Error ResourceImporterSVG::import(ResourceUID::ID p_source_id, const String &p_s
 	double saturation = p_options["saturation"];
 	Dictionary color_map = p_options["color_map"];
 
-	svg_tex->set_base_scale(base_scale);
-	svg_tex->set_saturation(saturation);
-	svg_tex->set_color_map(color_map);
-	svg_tex->set_source(source);
+	dpi_tex->set_base_scale(base_scale);
+	dpi_tex->set_saturation(saturation);
+	dpi_tex->set_color_map(color_map);
+	dpi_tex->set_source(source);
 
-	ERR_FAIL_COND_V_MSG(svg_tex->get_rid().is_null(), ERR_CANT_OPEN, vformat("Failed loading SVG, unsupported or invalid SVG data in \"%s\".", p_source_file));
+	ERR_FAIL_COND_V_MSG(dpi_tex->get_rid().is_null(), ERR_CANT_OPEN, vformat("Failed loading SVG, unsupported or invalid SVG data in \"%s\".", p_source_file));
 
 	int flg = 0;
 	if ((bool)p_options["compress"]) {
 		flg |= ResourceSaver::SaverFlags::FLAG_COMPRESS;
 	}
 
-	print_verbose("Saving to: " + p_save_path + ".svgtex");
-	Error err = ResourceSaver::save(svg_tex, p_save_path + ".svgtex", flg);
-	ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot save SVG texture to file \"%s.svgtex\".", p_save_path));
-	print_verbose("Done saving to: " + p_save_path + ".svgtex");
+	print_verbose("Saving to: " + p_save_path + ".dpitex");
+	Error err = ResourceSaver::save(dpi_tex, p_save_path + ".dpitex", flg);
+	ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot save DPI texture to file \"%s.dpitex\".", p_save_path));
+	print_verbose("Done saving to: " + p_save_path + ".dpitex");
 
 	return OK;
 }

+ 8 - 8
editor/themes/editor_icons.cpp

@@ -34,8 +34,8 @@
 #include "editor/themes/editor_color_map.h"
 #include "editor/themes/editor_icons.gen.h"
 #include "editor/themes/editor_scale.h"
+#include "scene/resources/dpi_texture.h"
 #include "scene/resources/image_texture.h"
-#include "scene/resources/svg_texture.h"
 
 #include "modules/svg/image_loader_svg.h"
 
@@ -48,8 +48,8 @@ void editor_configure_icons(bool p_dark_theme) {
 }
 
 // See also `generate_icon()` in `scene/theme/default_theme.cpp`.
-Ref<SVGTexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const Dictionary &p_convert_colors = Dictionary()) {
-	return SVGTexture::create_from_string(editor_icons_sources[p_index], p_scale, p_saturation, p_convert_colors);
+Ref<DPITexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const Dictionary &p_convert_colors = Dictionary()) {
+	return DPITexture::create_from_string(editor_icons_sources[p_index], p_scale, p_saturation, p_convert_colors);
 }
 
 float get_gizmo_handle_scale(const String &p_gizmo_handle_name, float p_gizmo_handle_scale) {
@@ -154,14 +154,14 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
 					saturation = 1.0;
 				}
 
-				Ref<SVGTexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
-				Ref<SVGTexture> icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light);
+				Ref<DPITexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
+				Ref<DPITexture> icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light);
 
 				p_theme->set_icon(editor_icon_name + "Dark", EditorStringName(EditorIcons), icon_dark);
 				p_theme->set_icon(editor_icon_name + "Light", EditorStringName(EditorIcons), icon_light);
 				p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), p_dark_theme ? icon_dark : icon_light);
 			} else {
-				Ref<SVGTexture> icon;
+				Ref<DPITexture> icon;
 				if (accent_color_icons.has(editor_icon_name)) {
 					icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), 1.0, accent_color_map);
 				} else {
@@ -188,7 +188,7 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
 		const float scale = (float)p_thumb_size / 64.0 * EDSCALE;
 		for (int i = 0; i < editor_bg_thumbs_count; i++) {
 			const int index = editor_bg_thumbs_indices[i];
-			Ref<SVGTexture> icon;
+			Ref<DPITexture> icon;
 
 			if (accent_color_icons.has(editor_icons_names[index])) {
 				icon = editor_generate_icon(index, scale, 1.0, accent_color_map);
@@ -211,7 +211,7 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
 		const float scale = (float)p_thumb_size / 32.0 * EDSCALE;
 		for (int i = 0; i < editor_md_thumbs_count; i++) {
 			const int index = editor_md_thumbs_indices[i];
-			Ref<SVGTexture> icon;
+			Ref<DPITexture> icon;
 
 			if (accent_color_icons.has(editor_icons_names[index])) {
 				icon = editor_generate_icon(index, scale, 1.0, accent_color_map);

+ 2 - 2
editor/themes/editor_theme_manager.cpp

@@ -41,11 +41,11 @@
 #include "editor/themes/editor_scale.h"
 #include "editor/themes/editor_theme.h"
 #include "scene/gui/graph_edit.h"
+#include "scene/resources/dpi_texture.h"
 #include "scene/resources/image_texture.h"
 #include "scene/resources/style_box_flat.h"
 #include "scene/resources/style_box_line.h"
 #include "scene/resources/style_box_texture.h"
-#include "scene/resources/svg_texture.h"
 #include "scene/resources/texture.h"
 
 // Theme configuration.
@@ -1726,7 +1726,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
 			p_theme->set_constant("port_h_offset", "GraphNode", 1);
 			p_theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
 
-			Ref<SVGTexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
+			Ref<DPITexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
 			// The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%).
 			port_icon->set_size_override(Size2(12, 12));
 			p_theme->set_icon("port", "GraphNode", port_icon);

+ 1 - 1
misc/extension_api_validation/4.4-stable.expected

@@ -327,4 +327,4 @@ GH-108825
 ---------
 Validate extension JSON: Error: Field 'classes/EditorExportPlatformExtension/methods/_get_option_icon/return_value': type changed value in new API, from "ImageTexture" to "Texture2D".
 
-Return type changed to allow returning both ImageTexture and SVGTexture. Compatibility method registered.
+Return type changed to allow returning both ImageTexture and DPITexture. Compatibility method registered.

+ 3 - 3
scene/main/viewport.cpp

@@ -43,8 +43,8 @@
 #include "scene/gui/subviewport_container.h"
 #include "scene/main/canvas_layer.h"
 #include "scene/main/window.h"
+#include "scene/resources/dpi_texture.h"
 #include "scene/resources/mesh.h"
-#include "scene/resources/svg_texture.h"
 #include "scene/resources/text_line.h"
 #include "scene/resources/world_2d.h"
 #include "servers/audio_server.h"
@@ -1090,8 +1090,8 @@ bool Viewport::_set_size(const Size2i &p_size, const Size2 &p_size_2d_override,
 		TS->reference_oversampling_level(new_font_oversampling);
 		TS->unreference_oversampling_level(font_oversampling);
 
-		SVGTexture::reference_scaling_level(new_font_oversampling);
-		SVGTexture::unreference_scaling_level(font_oversampling);
+		DPITexture::reference_scaling_level(new_font_oversampling);
+		DPITexture::unreference_scaling_level(font_oversampling);
 	}
 
 	size = new_size;

+ 2 - 2
scene/register_scene_types.cpp

@@ -134,6 +134,7 @@
 #if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
 #include "scene/resources/navigation_mesh.h"
 #endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
+#include "scene/resources/dpi_texture.h"
 #include "scene/resources/packed_scene.h"
 #include "scene/resources/particle_process_material.h"
 #include "scene/resources/placeholder_textures.h"
@@ -147,7 +148,6 @@
 #include "scene/resources/style_box_line.h"
 #include "scene/resources/style_box_texture.h"
 #include "scene/resources/surface_tool.h"
-#include "scene/resources/svg_texture.h"
 #include "scene/resources/syntax_highlighter.h"
 #include "scene/resources/text_line.h"
 #include "scene/resources/text_paragraph.h"
@@ -1039,7 +1039,7 @@ void register_scene_types() {
 	GDREGISTER_CLASS(PlaceholderTexture2DArray);
 	GDREGISTER_CLASS(PlaceholderCubemap);
 	GDREGISTER_CLASS(PlaceholderCubemapArray);
-	GDREGISTER_CLASS(SVGTexture);
+	GDREGISTER_CLASS(DPITexture);
 #ifndef DISABLE_DEPRECATED
 	GDREGISTER_CLASS(AnimatedTexture);
 #endif

+ 53 - 53
scene/resources/svg_texture.cpp → scene/resources/dpi_texture.cpp

@@ -1,5 +1,5 @@
 /**************************************************************************/
-/*  svg_texture.cpp                                                       */
+/*  dpi_texture.cpp                                                       */
 /**************************************************************************/
 /*                         This file is part of:                          */
 /*                             GODOT ENGINE                               */
@@ -28,7 +28,7 @@
 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
 /**************************************************************************/
 
-#include "svg_texture.h"
+#include "dpi_texture.h"
 
 #include "core/io/image_loader.h"
 #include "scene/main/canvas_item.h"
@@ -41,10 +41,10 @@
 #include "modules/svg/image_loader_svg.h"
 #endif
 
-Mutex SVGTexture::mutex;
-HashMap<double, SVGTexture::ScalingLevel> SVGTexture::scaling_levels;
+Mutex DPITexture::mutex;
+HashMap<double, DPITexture::ScalingLevel> DPITexture::scaling_levels;
 
-void SVGTexture::reference_scaling_level(double p_scale) {
+void DPITexture::reference_scaling_level(double p_scale) {
 	uint32_t oversampling = CLAMP(p_scale, 0.1, 100.0) * 64;
 	if (oversampling == 64) {
 		return;
@@ -61,7 +61,7 @@ void SVGTexture::reference_scaling_level(double p_scale) {
 	}
 }
 
-void SVGTexture::unreference_scaling_level(double p_scale) {
+void DPITexture::unreference_scaling_level(double p_scale) {
 	uint32_t oversampling = CLAMP(p_scale, 0.1, 100.0) * 64;
 	if (oversampling == 64) {
 		return;
@@ -73,7 +73,7 @@ void SVGTexture::unreference_scaling_level(double p_scale) {
 	if (sl) {
 		sl->refcount--;
 		if (sl->refcount == 0) {
-			for (SVGTexture *tx : sl->textures) {
+			for (DPITexture *tx : sl->textures) {
 				tx->_remove_scale(scale);
 			}
 			sl->textures.clear();
@@ -82,17 +82,17 @@ void SVGTexture::unreference_scaling_level(double p_scale) {
 	}
 }
 
-Ref<SVGTexture> SVGTexture::create_from_string(const String &p_source, float p_scale, float p_saturation, const Dictionary &p_color_map) {
-	Ref<SVGTexture> svg_texture;
-	svg_texture.instantiate();
-	svg_texture->set_source(p_source);
-	svg_texture->set_base_scale(p_scale);
-	svg_texture->set_saturation(p_saturation);
-	svg_texture->set_color_map(p_color_map);
-	return svg_texture;
+Ref<DPITexture> DPITexture::create_from_string(const String &p_source, float p_scale, float p_saturation, const Dictionary &p_color_map) {
+	Ref<DPITexture> dpi_texture;
+	dpi_texture.instantiate();
+	dpi_texture->set_source(p_source);
+	dpi_texture->set_base_scale(p_scale);
+	dpi_texture->set_saturation(p_saturation);
+	dpi_texture->set_color_map(p_color_map);
+	return dpi_texture;
 }
 
-void SVGTexture::set_source(const String &p_source) {
+void DPITexture::set_source(const String &p_source) {
 	if (source == p_source) {
 		return;
 	}
@@ -100,11 +100,11 @@ void SVGTexture::set_source(const String &p_source) {
 	_update_texture();
 }
 
-String SVGTexture::get_source() const {
+String DPITexture::get_source() const {
 	return source;
 }
 
-void SVGTexture::set_base_scale(float p_scale) {
+void DPITexture::set_base_scale(float p_scale) {
 	if (base_scale == p_scale) {
 		return;
 	}
@@ -114,11 +114,11 @@ void SVGTexture::set_base_scale(float p_scale) {
 	_update_texture();
 }
 
-float SVGTexture::get_base_scale() const {
+float DPITexture::get_base_scale() const {
 	return base_scale;
 }
 
-void SVGTexture::set_saturation(float p_saturation) {
+void DPITexture::set_saturation(float p_saturation) {
 	if (saturation == p_saturation) {
 		return;
 	}
@@ -127,11 +127,11 @@ void SVGTexture::set_saturation(float p_saturation) {
 	_update_texture();
 }
 
-float SVGTexture::get_saturation() const {
+float DPITexture::get_saturation() const {
 	return saturation;
 }
 
-void SVGTexture::set_color_map(const Dictionary &p_color_map) {
+void DPITexture::set_color_map(const Dictionary &p_color_map) {
 	if (color_map == p_color_map) {
 		return;
 	}
@@ -143,11 +143,11 @@ void SVGTexture::set_color_map(const Dictionary &p_color_map) {
 	_update_texture();
 }
 
-Dictionary SVGTexture::get_color_map() const {
+Dictionary DPITexture::get_color_map() const {
 	return color_map;
 }
 
-void SVGTexture::_remove_scale(double p_scale) {
+void DPITexture::_remove_scale(double p_scale) {
 	if (Math::is_equal_approx(p_scale, 1.0)) {
 		return;
 	}
@@ -161,7 +161,7 @@ void SVGTexture::_remove_scale(double p_scale) {
 	}
 }
 
-RID SVGTexture::_ensure_scale(double p_scale) const {
+RID DPITexture::_ensure_scale(double p_scale) const {
 	uint32_t oversampling = CLAMP(p_scale, 0.1, 100.0) * 64;
 	if (oversampling == 64) {
 		if (base_texture.is_null()) {
@@ -179,14 +179,14 @@ RID SVGTexture::_ensure_scale(double p_scale) const {
 	MutexLock lock(mutex);
 	ScalingLevel *sl = scaling_levels.getptr(scale);
 	ERR_FAIL_NULL_V_MSG(sl, RID(), "Invalid scaling level");
-	sl->textures.insert(const_cast<SVGTexture *>(this));
+	sl->textures.insert(const_cast<DPITexture *>(this));
 
 	RID new_rid = _load_at_scale(scale, false);
 	texture_cache[scale] = new_rid;
 	return new_rid;
 }
 
-RID SVGTexture::_load_at_scale(double p_scale, bool p_set_size) const {
+RID DPITexture::_load_at_scale(double p_scale, bool p_set_size) const {
 	Ref<Image> img;
 	img.instantiate();
 #ifdef MODULE_SVG_ENABLED
@@ -227,7 +227,7 @@ RID SVGTexture::_load_at_scale(double p_scale, bool p_set_size) const {
 	return rid;
 }
 
-void SVGTexture::_clear() {
+void DPITexture::_clear() {
 	for (KeyValue<double, RID> &tx : texture_cache) {
 		if (tx.value.is_valid()) {
 			RenderingServer::get_singleton()->free(tx.value);
@@ -241,12 +241,12 @@ void SVGTexture::_clear() {
 	alpha_cache.unref();
 }
 
-void SVGTexture::_update_texture() {
+void DPITexture::_update_texture() {
 	_clear();
 	emit_changed();
 }
 
-Ref<Image> SVGTexture::get_image() const {
+Ref<Image> DPITexture::get_image() const {
 	RID rid = _ensure_scale(1.0);
 	if (rid.is_valid()) {
 		return RenderingServer::get_singleton()->texture_2d_get(rid);
@@ -255,25 +255,25 @@ Ref<Image> SVGTexture::get_image() const {
 	}
 }
 
-int SVGTexture::get_width() const {
+int DPITexture::get_width() const {
 	_ensure_scale(1.0);
 	return size.x;
 }
 
-int SVGTexture::get_height() const {
+int DPITexture::get_height() const {
 	_ensure_scale(1.0);
 	return size.y;
 }
 
-RID SVGTexture::get_rid() const {
+RID DPITexture::get_rid() const {
 	return _ensure_scale(1.0);
 }
 
-bool SVGTexture::has_alpha() const {
+bool DPITexture::has_alpha() const {
 	return true;
 }
 
-RID SVGTexture::get_scaled_rid() const {
+RID DPITexture::get_scaled_rid() const {
 	double scale = 1.0;
 	CanvasItem *ci = CanvasItem::get_current_item_drawn();
 	if (ci) {
@@ -285,19 +285,19 @@ RID SVGTexture::get_scaled_rid() const {
 	return _ensure_scale(scale);
 }
 
-void SVGTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
+void DPITexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
 	RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, size), get_scaled_rid(), false, p_modulate, p_transpose);
 }
 
-void SVGTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
+void DPITexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
 	RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_scaled_rid(), p_tile, p_modulate, p_transpose);
 }
 
-void SVGTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
+void DPITexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
 	RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_scaled_rid(), p_src_rect, p_modulate, p_transpose, p_clip_uv);
 }
 
-bool SVGTexture::is_pixel_opaque(int p_x, int p_y) const {
+bool DPITexture::is_pixel_opaque(int p_x, int p_y) const {
 	if (alpha_cache.is_null()) {
 		Ref<Image> img = get_image();
 		if (img.is_valid()) {
@@ -325,7 +325,7 @@ bool SVGTexture::is_pixel_opaque(int p_x, int p_y) const {
 	return true;
 }
 
-void SVGTexture::set_size_override(const Size2i &p_size) {
+void DPITexture::set_size_override(const Size2i &p_size) {
 	if (size_override == p_size) {
 		return;
 	}
@@ -352,19 +352,19 @@ void SVGTexture::set_size_override(const Size2i &p_size) {
 	emit_changed();
 }
 
-void SVGTexture::_bind_methods() {
-	ClassDB::bind_static_method("SVGTexture", D_METHOD("create_from_string", "source", "scale", "saturation", "color_map"), &SVGTexture::create_from_string, DEFVAL(1.0), DEFVAL(1.0), DEFVAL(Dictionary()));
+void DPITexture::_bind_methods() {
+	ClassDB::bind_static_method("DPITexture", D_METHOD("create_from_string", "source", "scale", "saturation", "color_map"), &DPITexture::create_from_string, DEFVAL(1.0), DEFVAL(1.0), DEFVAL(Dictionary()));
 
-	ClassDB::bind_method(D_METHOD("set_source", "source"), &SVGTexture::set_source);
-	ClassDB::bind_method(D_METHOD("get_source"), &SVGTexture::get_source);
-	ClassDB::bind_method(D_METHOD("set_base_scale", "base_scale"), &SVGTexture::set_base_scale);
-	ClassDB::bind_method(D_METHOD("get_base_scale"), &SVGTexture::get_base_scale);
-	ClassDB::bind_method(D_METHOD("set_saturation", "saturation"), &SVGTexture::set_saturation);
-	ClassDB::bind_method(D_METHOD("get_saturation"), &SVGTexture::get_saturation);
-	ClassDB::bind_method(D_METHOD("set_color_map", "color_map"), &SVGTexture::set_color_map);
-	ClassDB::bind_method(D_METHOD("get_color_map"), &SVGTexture::get_color_map);
-	ClassDB::bind_method(D_METHOD("set_size_override", "size"), &SVGTexture::set_size_override);
-	ClassDB::bind_method(D_METHOD("get_scaled_rid"), &SVGTexture::get_scaled_rid);
+	ClassDB::bind_method(D_METHOD("set_source", "source"), &DPITexture::set_source);
+	ClassDB::bind_method(D_METHOD("get_source"), &DPITexture::get_source);
+	ClassDB::bind_method(D_METHOD("set_base_scale", "base_scale"), &DPITexture::set_base_scale);
+	ClassDB::bind_method(D_METHOD("get_base_scale"), &DPITexture::get_base_scale);
+	ClassDB::bind_method(D_METHOD("set_saturation", "saturation"), &DPITexture::set_saturation);
+	ClassDB::bind_method(D_METHOD("get_saturation"), &DPITexture::get_saturation);
+	ClassDB::bind_method(D_METHOD("set_color_map", "color_map"), &DPITexture::set_color_map);
+	ClassDB::bind_method(D_METHOD("get_color_map"), &DPITexture::get_color_map);
+	ClassDB::bind_method(D_METHOD("set_size_override", "size"), &DPITexture::set_size_override);
+	ClassDB::bind_method(D_METHOD("get_scaled_rid"), &DPITexture::get_scaled_rid);
 
 	ADD_PROPERTY(PropertyInfo(Variant::STRING, "_source", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_STORAGE), "set_source", "get_source");
 	ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "base_scale", PROPERTY_HINT_RANGE, "0.01,10.0,0.01"), "set_base_scale", "get_base_scale");
@@ -372,7 +372,7 @@ void SVGTexture::_bind_methods() {
 	ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "color_map", PROPERTY_HINT_DICTIONARY_TYPE, "Color;Color"), "set_color_map", "get_color_map");
 }
 
-SVGTexture::~SVGTexture() {
+DPITexture::~DPITexture() {
 	_clear();
 
 	MutexLock lock(mutex);

+ 7 - 7
scene/resources/svg_texture.h → scene/resources/dpi_texture.h

@@ -1,5 +1,5 @@
 /**************************************************************************/
-/*  svg_texture.h                                                         */
+/*  dpi_texture.h                                                         */
 /**************************************************************************/
 /*                         This file is part of:                          */
 /*                             GODOT ENGINE                               */
@@ -35,9 +35,9 @@
 
 class BitMap;
 
-class SVGTexture : public Texture2D {
-	GDCLASS(SVGTexture, Texture2D);
-	RES_BASE_EXTENSION("svgtex");
+class DPITexture : public Texture2D {
+	GDCLASS(DPITexture, Texture2D);
+	RES_BASE_EXTENSION("dpitex");
 
 	String source;
 	float base_scale = 1.0;
@@ -46,7 +46,7 @@ class SVGTexture : public Texture2D {
 	Size2 size_override;
 
 	struct ScalingLevel {
-		HashSet<SVGTexture *> textures;
+		HashSet<DPITexture *> textures;
 		int32_t refcount = 1;
 	};
 	static Mutex mutex;
@@ -69,7 +69,7 @@ protected:
 	static void _bind_methods();
 
 public:
-	static Ref<SVGTexture> create_from_string(const String &p_source, float p_scale = 1.0, float p_saturation = 1.0, const Dictionary &p_color_map = Dictionary());
+	static Ref<DPITexture> create_from_string(const String &p_source, float p_scale = 1.0, float p_saturation = 1.0, const Dictionary &p_color_map = Dictionary());
 
 	void set_source(const String &p_source);
 	String get_source() const;
@@ -102,5 +102,5 @@ public:
 	static void reference_scaling_level(double p_scale);
 	static void unreference_scaling_level(double p_scale);
 
-	~SVGTexture();
+	~DPITexture();
 };

+ 3 - 3
scene/theme/default_theme.cpp

@@ -31,12 +31,12 @@
 #include "default_theme.h"
 
 #include "core/io/image.h"
+#include "scene/resources/dpi_texture.h"
 #include "scene/resources/font.h"
 #include "scene/resources/gradient_texture.h"
 #include "scene/resources/image_texture.h"
 #include "scene/resources/style_box_flat.h"
 #include "scene/resources/style_box_line.h"
-#include "scene/resources/svg_texture.h"
 #include "scene/resources/theme.h"
 #include "scene/scene_string_names.h"
 #include "scene/theme/default_theme_icons.gen.h"
@@ -79,8 +79,8 @@ static Ref<StyleBoxFlat> sb_expand(Ref<StyleBoxFlat> p_sbox, float p_left, float
 }
 
 // See also `editor_generate_icon()` in `editor/themes/editor_icons.cpp`.
-static Ref<SVGTexture> generate_icon(int p_index) {
-	return SVGTexture::create_from_string(default_theme_icons_sources[p_index], scale);
+static Ref<DPITexture> generate_icon(int p_index) {
+	return DPITexture::create_from_string(default_theme_icons_sources[p_index], scale);
 }
 
 static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {