Repository: godotengine/godot
File: editor/plugins/texture_3d_editor_plugin.cpp (C++)

Code before:
		COLOR = filter_preview_colors(COLOR, u_channel_factors);
	}
)";

void Texture3DEditor::_texture_rect_draw() {
	texture_rect->draw_rect(Rect2(Point2(), texture_rect->get_size()), Color(1, 1, 1, 1));
}

void Texture3DEditor::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_RESIZED: {
			_texture_rect_update_area();
		} break;

		case NOTIFICATION_DRAW: {
			Ref<Texture2D> checkerboard = get_editor_theme_icon(SNAME("Checkerboard"));
			draw_texture_rect(checkerboard, texture_rect->get_rect(), true);
			_draw_outline();
		} break;

		case NOTIFICATION_THEME_CHANGED: {
			if (info) {
				Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), EditorStringName(EditorFonts));
				info->add_theme_font_override(SceneStringName(font), metadata_label_font);
			}
			cached_outline_color = get_theme_color(SNAME("extra_border_color_1"), EditorStringName(Editor));
		} break;
	}
}

void Texture3DEditor::_texture_changed() {
	if (!is_visible()) {
		return;
	}

	setting = true;
	_update_gui();
	setting = false;

	_update_material(true);
	queue_redraw();
}

void Texture3DEditor::_update_material(bool p_texture_changed) {
	material->set_shader_parameter("layer", (layer->get_value() + 0.5) / texture->get_depth());

	if (p_texture_changed) {
		material->set_shader_parameter("tex", texture->get_rid());
	}

	material->set_shader_parameter("u_channel_factors", channel_selector->get_selected_channel_factors());

Review comment (performance):
We tend to use a standardized theme cache struct for things like this. Example in the header:

```cpp
	struct ThemeCache {
		Color valid_color;
		Color warning_color;
		Color error_color;
	} theme_cache;
```

You can then use it as `theme_cache.property` within the C++ file. Even if there's one property, this ensures future properties are also added to it to encourage theme caching.

Code after:
		COLOR = filter_preview_colors(COLOR, u_channel_factors);
	}
)";

void Texture3DEditor::_texture_rect_draw() {
	texture_rect->draw_rect(Rect2(Point2(), texture_rect->get_size()), Color(1, 1, 1, 1));
}

void Texture3DEditor::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_RESIZED: {
			_texture_rect_update_area();
		} break;

		case NOTIFICATION_DRAW: {
			Ref<Texture2D> checkerboard = get_editor_theme_icon(SNAME("Checkerboard"));
			draw_texture_rect(checkerboard, texture_rect->get_rect(), true);
			_draw_outline();
		} break;

		case NOTIFICATION_THEME_CHANGED: {
			if (info) {
				Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), EditorStringName(EditorFonts));
				info->add_theme_font_override(SceneStringName(font), metadata_label_font);
			}
			theme_cache.outline_color = get_theme_color(SNAME("extra_border_color_1"), EditorStringName(Editor));
		} break;
	}
}

void Texture3DEditor::_texture_changed() {
	if (!is_visible()) {
		return;
	}

	setting = true;
	_update_gui();
	setting = false;

	_update_material(true);
	queue_redraw();
}

void Texture3DEditor::_update_material(bool p_texture_changed) {
	material->set_shader_parameter("layer", (layer->get_value() + 0.5) / texture->get_depth());

	if (p_texture_changed) {
		material->set_shader_parameter("tex", texture->get_rid());
	}

	material->set_shader_parameter("u_channel_factors", channel_selector->get_selected_channel_factors());