Skip to content

Commit 597170a

Browse files
committed
Merge pull request #109811 from bruvzg/svg_rename
Rename SVGTexture to DPITexture.
2 parents dcfddd4 + 10e11ec commit 597170a

File tree

13 files changed

+107
-107
lines changed

13 files changed

+107
-107
lines changed

doc/classes/SVGTexture.xml renamed to doc/classes/DPITexture.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="SVGTexture" inherits="Texture2D" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
2+
<class name="DPITexture" inherits="Texture2D" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
4-
A scalable [Texture2D] based on an SVG image.
4+
An automatically scalable [Texture2D] based on an SVG image.
55
</brief_description>
66
<description>
7-
A scalable [Texture2D] based on an SVG image. [SVGTexture]s are automatically re-rasterized to match font oversampling.
7+
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].
88
</description>
99
<tutorials>
1010
</tutorials>
1111
<methods>
1212
<method name="create_from_string" qualifiers="static">
13-
<return type="SVGTexture" />
13+
<return type="DPITexture" />
1414
<param index="0" name="source" type="String" />
1515
<param index="1" name="scale" type="float" default="1.0" />
1616
<param index="2" name="saturation" type="float" default="1.0" />
1717
<param index="3" name="color_map" type="Dictionary" default="{}" />
1818
<description>
19-
Creates a new [SVGTexture] and initializes it by allocating and setting the SVG data from string.
19+
Creates a new [DPITexture] and initializes it by allocating and setting the SVG data from string.
2020
</description>
2121
</method>
2222
<method name="get_scaled_rid" qualifiers="const">
@@ -48,10 +48,10 @@
4848
</methods>
4949
<members>
5050
<member name="base_scale" type="float" setter="set_base_scale" getter="get_base_scale" default="1.0">
51-
SVG texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
51+
Texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
5252
</member>
5353
<member name="color_map" type="Dictionary" setter="set_color_map" getter="get_color_map" default="{}">
54-
If set, remaps SVG texture colors according to [Color]-[Color] map.
54+
If set, remaps texture colors according to [Color]-[Color] map.
5555
</member>
5656
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" overrides="Resource" default="false" />
5757
<member name="saturation" type="float" setter="set_saturation" getter="get_saturation" default="1.0">

doc/classes/ProjectSettings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@
11941194
Maximum undo/redo history size for [TextEdit] fields.
11951195
</member>
11961196
<member name="gui/fonts/dynamic_fonts/use_oversampling" type="bool" setter="" getter="" default="true">
1197-
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.
1197+
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.
11981198
</member>
11991199
<member name="gui/theme/custom" type="String" setter="" getter="" default="&quot;&quot;">
12001200
Path to a custom [Theme] resource file to use for the project ([code].theme[/code] or generic [code].tres[/code]/[code].res[/code] extension).

doc/classes/ResourceImporterSVG.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<class name="ResourceImporterSVG" inherits="ResourceImporter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
4-
Imports an SVG file as a scalable texture for use in 2D or 3D rendering.
4+
Imports an SVG file as an automatically scalable texture for use in UI elements and 2D rendering.
55
</brief_description>
66
<description>
7-
This importer imports [SVGTexture] resources. See also [ResourceImporterTexture] and [ResourceImporterImage].
7+
This importer imports [DPITexture] resources. See also [ResourceImporterTexture] and [ResourceImporterImage].
88
</description>
99
<tutorials>
1010
</tutorials>
1111
<members>
1212
<member name="base_scale" type="float" setter="" getter="" default="1.0">
13-
SVG texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
13+
Texture scale. [code]1.0[/code] is the original SVG size. Higher values result in a larger image.
1414
</member>
1515
<member name="color_map" type="Dictionary" setter="" getter="" default="{}">
16-
If set, remaps SVG texture colors according to [Color]-[Color] map.
16+
If set, remaps texture colors according to [Color]-[Color] map.
1717
</member>
1818
<member name="compress" type="bool" setter="" getter="" default="true">
1919
If [code]true[/code], uses lossless compression for the SVG source.

doc/classes/Viewport.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376
See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa_3d] and [method RenderingServer.viewport_set_msaa_3d].
377377
</member>
378378
<member name="oversampling" type="bool" setter="set_use_oversampling" getter="is_using_oversampling" default="true">
379-
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.
379+
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.
380380
</member>
381381
<member name="oversampling_override" type="float" setter="set_oversampling_override" getter="get_oversampling_override" default="0.0">
382382
If greater than zero, this value is used as the font oversampling factor, otherwise oversampling is equal to viewport scale.

editor/import/resource_importer_svg.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,26 @@
3131
#include "resource_importer_svg.h"
3232

3333
#include "core/io/file_access.h"
34-
#include "scene/resources/svg_texture.h"
34+
#include "scene/resources/dpi_texture.h"
3535

3636
String ResourceImporterSVG::get_importer_name() const {
3737
return "svg";
3838
}
3939

4040
String ResourceImporterSVG::get_visible_name() const {
41-
return "SVGTexture";
41+
return "DPITexture";
4242
}
4343

4444
void ResourceImporterSVG::get_recognized_extensions(List<String> *p_extensions) const {
4545
p_extensions->push_back("svg");
4646
}
4747

4848
String ResourceImporterSVG::get_save_extension() const {
49-
return "svgtex";
49+
return "dpitex";
5050
}
5151

5252
String ResourceImporterSVG::get_resource_type() const {
53-
return "SVGTexture";
53+
return "DPITexture";
5454
}
5555

5656
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
7373
}
7474

7575
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) {
76-
Ref<SVGTexture> svg_tex;
77-
svg_tex.instantiate();
76+
Ref<DPITexture> dpi_tex;
77+
dpi_tex.instantiate();
7878

7979
String source = FileAccess::get_file_as_string(p_source_file);
8080
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
8383
double saturation = p_options["saturation"];
8484
Dictionary color_map = p_options["color_map"];
8585

86-
svg_tex->set_base_scale(base_scale);
87-
svg_tex->set_saturation(saturation);
88-
svg_tex->set_color_map(color_map);
89-
svg_tex->set_source(source);
86+
dpi_tex->set_base_scale(base_scale);
87+
dpi_tex->set_saturation(saturation);
88+
dpi_tex->set_color_map(color_map);
89+
dpi_tex->set_source(source);
9090

91-
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));
91+
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));
9292

9393
int flg = 0;
9494
if ((bool)p_options["compress"]) {
9595
flg |= ResourceSaver::SaverFlags::FLAG_COMPRESS;
9696
}
9797

98-
print_verbose("Saving to: " + p_save_path + ".svgtex");
99-
Error err = ResourceSaver::save(svg_tex, p_save_path + ".svgtex", flg);
100-
ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot save SVG texture to file \"%s.svgtex\".", p_save_path));
101-
print_verbose("Done saving to: " + p_save_path + ".svgtex");
98+
print_verbose("Saving to: " + p_save_path + ".dpitex");
99+
Error err = ResourceSaver::save(dpi_tex, p_save_path + ".dpitex", flg);
100+
ERR_FAIL_COND_V_MSG(err != OK, err, vformat("Cannot save DPI texture to file \"%s.dpitex\".", p_save_path));
101+
print_verbose("Done saving to: " + p_save_path + ".dpitex");
102102

103103
return OK;
104104
}

editor/themes/editor_icons.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#include "editor/themes/editor_color_map.h"
3535
#include "editor/themes/editor_icons.gen.h"
3636
#include "editor/themes/editor_scale.h"
37+
#include "scene/resources/dpi_texture.h"
3738
#include "scene/resources/image_texture.h"
38-
#include "scene/resources/svg_texture.h"
3939

4040
#include "modules/svg/image_loader_svg.h"
4141

@@ -48,8 +48,8 @@ void editor_configure_icons(bool p_dark_theme) {
4848
}
4949

5050
// See also `generate_icon()` in `scene/theme/default_theme.cpp`.
51-
Ref<SVGTexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const Dictionary &p_convert_colors = Dictionary()) {
52-
return SVGTexture::create_from_string(editor_icons_sources[p_index], p_scale, p_saturation, p_convert_colors);
51+
Ref<DPITexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const Dictionary &p_convert_colors = Dictionary()) {
52+
return DPITexture::create_from_string(editor_icons_sources[p_index], p_scale, p_saturation, p_convert_colors);
5353
}
5454

5555
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
154154
saturation = 1.0;
155155
}
156156

157-
Ref<SVGTexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
158-
Ref<SVGTexture> icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light);
157+
Ref<DPITexture> icon_dark = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_dark);
158+
Ref<DPITexture> icon_light = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), saturation, color_conversion_map_light);
159159

160160
p_theme->set_icon(editor_icon_name + "Dark", EditorStringName(EditorIcons), icon_dark);
161161
p_theme->set_icon(editor_icon_name + "Light", EditorStringName(EditorIcons), icon_light);
162162
p_theme->set_icon(editor_icon_name, EditorStringName(EditorIcons), p_dark_theme ? icon_dark : icon_light);
163163
} else {
164-
Ref<SVGTexture> icon;
164+
Ref<DPITexture> icon;
165165
if (accent_color_icons.has(editor_icon_name)) {
166166
icon = editor_generate_icon(i, get_gizmo_handle_scale(editor_icon_name, p_gizmo_handle_scale), 1.0, accent_color_map);
167167
} else {
@@ -188,7 +188,7 @@ void editor_register_icons(const Ref<Theme> &p_theme, bool p_dark_theme, float p
188188
const float scale = (float)p_thumb_size / 64.0 * EDSCALE;
189189
for (int i = 0; i < editor_bg_thumbs_count; i++) {
190190
const int index = editor_bg_thumbs_indices[i];
191-
Ref<SVGTexture> icon;
191+
Ref<DPITexture> icon;
192192

193193
if (accent_color_icons.has(editor_icons_names[index])) {
194194
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
211211
const float scale = (float)p_thumb_size / 32.0 * EDSCALE;
212212
for (int i = 0; i < editor_md_thumbs_count; i++) {
213213
const int index = editor_md_thumbs_indices[i];
214-
Ref<SVGTexture> icon;
214+
Ref<DPITexture> icon;
215215

216216
if (accent_color_icons.has(editor_icons_names[index])) {
217217
icon = editor_generate_icon(index, scale, 1.0, accent_color_map);

editor/themes/editor_theme_manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
#include "editor/themes/editor_scale.h"
4242
#include "editor/themes/editor_theme.h"
4343
#include "scene/gui/graph_edit.h"
44+
#include "scene/resources/dpi_texture.h"
4445
#include "scene/resources/image_texture.h"
4546
#include "scene/resources/style_box_flat.h"
4647
#include "scene/resources/style_box_line.h"
4748
#include "scene/resources/style_box_texture.h"
48-
#include "scene/resources/svg_texture.h"
4949
#include "scene/resources/texture.h"
5050

5151
// Theme configuration.
@@ -1726,7 +1726,7 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
17261726
p_theme->set_constant("port_h_offset", "GraphNode", 1);
17271727
p_theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
17281728

1729-
Ref<SVGTexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
1729+
Ref<DPITexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
17301730
// The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%).
17311731
port_icon->set_size_override(Size2(12, 12));
17321732
p_theme->set_icon("port", "GraphNode", port_icon);

misc/extension_api_validation/4.4-stable.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,4 @@ GH-108825
327327
---------
328328
Validate extension JSON: Error: Field 'classes/EditorExportPlatformExtension/methods/_get_option_icon/return_value': type changed value in new API, from "ImageTexture" to "Texture2D".
329329

330-
Return type changed to allow returning both ImageTexture and SVGTexture. Compatibility method registered.
330+
Return type changed to allow returning both ImageTexture and DPITexture. Compatibility method registered.

scene/main/viewport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
#include "scene/gui/subviewport_container.h"
4444
#include "scene/main/canvas_layer.h"
4545
#include "scene/main/window.h"
46+
#include "scene/resources/dpi_texture.h"
4647
#include "scene/resources/mesh.h"
47-
#include "scene/resources/svg_texture.h"
4848
#include "scene/resources/text_line.h"
4949
#include "scene/resources/world_2d.h"
5050
#include "servers/audio_server.h"
@@ -1090,8 +1090,8 @@ bool Viewport::_set_size(const Size2i &p_size, const Size2 &p_size_2d_override,
10901090
TS->reference_oversampling_level(new_font_oversampling);
10911091
TS->unreference_oversampling_level(font_oversampling);
10921092

1093-
SVGTexture::reference_scaling_level(new_font_oversampling);
1094-
SVGTexture::unreference_scaling_level(font_oversampling);
1093+
DPITexture::reference_scaling_level(new_font_oversampling);
1094+
DPITexture::unreference_scaling_level(font_oversampling);
10951095
}
10961096

10971097
size = new_size;

scene/register_scene_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
135135
#include "scene/resources/navigation_mesh.h"
136136
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
137+
#include "scene/resources/dpi_texture.h"
137138
#include "scene/resources/packed_scene.h"
138139
#include "scene/resources/particle_process_material.h"
139140
#include "scene/resources/placeholder_textures.h"
@@ -147,7 +148,6 @@
147148
#include "scene/resources/style_box_line.h"
148149
#include "scene/resources/style_box_texture.h"
149150
#include "scene/resources/surface_tool.h"
150-
#include "scene/resources/svg_texture.h"
151151
#include "scene/resources/syntax_highlighter.h"
152152
#include "scene/resources/text_line.h"
153153
#include "scene/resources/text_paragraph.h"
@@ -1039,7 +1039,7 @@ void register_scene_types() {
10391039
GDREGISTER_CLASS(PlaceholderTexture2DArray);
10401040
GDREGISTER_CLASS(PlaceholderCubemap);
10411041
GDREGISTER_CLASS(PlaceholderCubemapArray);
1042-
GDREGISTER_CLASS(SVGTexture);
1042+
GDREGISTER_CLASS(DPITexture);
10431043
#ifndef DISABLE_DEPRECATED
10441044
GDREGISTER_CLASS(AnimatedTexture);
10451045
#endif

0 commit comments

Comments
 (0)