You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +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:
@@ -519,8 +519,8 @@ void CurveEditor::set_hover_point_index(int index) {
|
||||
}
|
||||
|
||||
void CurveEditor::update_view_transform() {
|
||||
Ref<Font> font = get_theme_font("font", "Label");
|
||||
int font_size = get_theme_font_size("font_size", "Label");
|
||||
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
||||
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
|
||||
|
||||
const real_t margin = font->get_height(font_size) + 2 * EDSCALE;
|
||||
|
||||
@@ -635,7 +635,7 @@ void CurveEditor::_draw() {
|
||||
// Background
|
||||
|
||||
Vector2 view_size = get_rect().size;
|
||||
draw_style_box(get_theme_stylebox("bg", "Tree"), Rect2(Point2(), view_size));
|
||||
draw_style_box(get_theme_stylebox(SNAME("bg"), SNAME("Tree")), Rect2(Point2(), view_size));
|
||||
|
||||
// Grid
|
||||
|
||||
@@ -644,8 +644,8 @@ void CurveEditor::_draw() {
|
||||
Vector2 min_edge = get_world_pos(Vector2(0, view_size.y));
|
||||
Vector2 max_edge = get_world_pos(Vector2(view_size.x, 0));
|
||||
|
||||
const Color grid_color0 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.15);
|
||||
const Color grid_color1 = get_theme_color("mono_color", "Editor") * Color(1, 1, 1, 0.07);
|
||||
const Color grid_color0 = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.15);
|
||||
const Color grid_color1 = get_theme_color(SNAME("mono_color"), SNAME("Editor")) * Color(1, 1, 1, 0.07);
|
||||
draw_line(Vector2(min_edge.x, curve.get_min_value()), Vector2(max_edge.x, curve.get_min_value()), grid_color0);
|
||||
draw_line(Vector2(max_edge.x, curve.get_max_value()), Vector2(min_edge.x, curve.get_max_value()), grid_color0);
|
||||
draw_line(Vector2(0, min_edge.y), Vector2(0, max_edge.y), grid_color0);
|
||||
@@ -665,10 +665,10 @@ void CurveEditor::_draw() {
|
||||
|
||||
draw_set_transform_matrix(Transform2D());
|
||||
|
||||
Ref<Font> font = get_theme_font("font", "Label");
|
||||
int font_size = get_theme_font_size("font_size", "Label");
|
||||
Ref<Font> font = get_theme_font(SNAME("font"), SNAME("Label"));
|
||||
int font_size = get_theme_font_size(SNAME("font_size"), SNAME("Label"));
|
||||
float font_height = font->get_height(font_size);
|
||||
Color text_color = get_theme_color("font_color", "Editor");
|
||||
Color text_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
|
||||
|
||||
{
|
||||
// X axis
|
||||
@@ -695,7 +695,7 @@ void CurveEditor::_draw() {
|
||||
// Draw tangents for current point
|
||||
|
||||
if (_selected_point >= 0) {
|
||||
const Color tangent_color = get_theme_color("accent_color", "Editor");
|
||||
const Color tangent_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
||||
|
||||
int i = _selected_point;
|
||||
Vector2 pos = curve.get_point_position(i);
|
||||
@@ -717,8 +717,8 @@ void CurveEditor::_draw() {
|
||||
|
||||
draw_set_transform_matrix(_world_to_view);
|
||||
|
||||
const Color line_color = get_theme_color("font_color", "Editor");
|
||||
const Color edge_line_color = get_theme_color("highlight_color", "Editor");
|
||||
const Color line_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
|
||||
const Color edge_line_color = get_theme_color(SNAME("highlight_color"), SNAME("Editor"));
|
||||
|
||||
CanvasItemPlotCurve plot_func(*this, line_color, edge_line_color);
|
||||
plot_curve_accurate(curve, 4.f / view_size.x, plot_func);
|
||||
@@ -727,8 +727,8 @@ void CurveEditor::_draw() {
|
||||
|
||||
draw_set_transform_matrix(Transform2D());
|
||||
|
||||
const Color point_color = get_theme_color("font_color", "Editor");
|
||||
const Color selected_point_color = get_theme_color("accent_color", "Editor");
|
||||
const Color point_color = get_theme_color(SNAME("font_color"), SNAME("Editor"));
|
||||
const Color selected_point_color = get_theme_color(SNAME("accent_color"), SNAME("Editor"));
|
||||
|
||||
for (int i = 0; i < curve.get_point_count(); ++i) {
|
||||
Vector2 pos = curve.get_point_position(i);
|
||||
|
||||
Reference in New Issue
Block a user