You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
This commit is contained in:
@@ -47,14 +47,14 @@ void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
|
||||
edit_draw->draw_line(
|
||||
from,
|
||||
to,
|
||||
EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor").inverted() * Color(1, 1, 1, 0.5),
|
||||
EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5),
|
||||
Math::round(2 * EDSCALE));
|
||||
|
||||
while ((to - from).length_squared() > 200) {
|
||||
edit_draw->draw_line(
|
||||
from,
|
||||
from + line,
|
||||
EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"),
|
||||
EditorNode::get_singleton()->get_theme_base()->get_theme_color(SNAME("mono_color"), SNAME("Editor")),
|
||||
Math::round(2 * EDSCALE));
|
||||
|
||||
from += line * 2;
|
||||
@@ -159,7 +159,7 @@ void TextureRegionEditor::_region_draw() {
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Texture2D> select_handle = get_theme_icon("EditorHandle", "EditorIcons");
|
||||
Ref<Texture2D> select_handle = get_theme_icon(SNAME("EditorHandle"), SNAME("EditorIcons"));
|
||||
|
||||
Rect2 scroll_rect(Point2(), base_tex->get_size());
|
||||
|
||||
@@ -175,7 +175,7 @@ void TextureRegionEditor::_region_draw() {
|
||||
mtx.basis_xform(raw_endpoints[2]),
|
||||
mtx.basis_xform(raw_endpoints[3])
|
||||
};
|
||||
Color color = get_theme_color("mono_color", "Editor");
|
||||
Color color = get_theme_color(SNAME("mono_color"), SNAME("Editor"));
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int prev = (i + 3) % 4;
|
||||
int next = (i + 1) % 4;
|
||||
@@ -799,12 +799,12 @@ void TextureRegionEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
edit_draw->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
|
||||
edit_draw->add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
|
||||
} break;
|
||||
case NOTIFICATION_READY: {
|
||||
zoom_out->set_icon(get_theme_icon("ZoomLess", "EditorIcons"));
|
||||
zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons"));
|
||||
zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons"));
|
||||
zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
|
||||
zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
|
||||
zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
|
||||
|
||||
vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE);
|
||||
hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE);
|
||||
|
||||
Reference in New Issue
Block a user