godot/core/io/resource_loader.cpp

/**************************************************************************/
/*  resource_loader.cpp                                                   */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "resource_loader.h"

#include "core/config/project_settings.h"
#include "core/io/file_access.h"
#include "core/io/resource_importer.h"
#include "core/object/script_language.h"
#include "core/os/condition_variable.h"
#include "core/os/os.h"
#include "core/os/safe_binary_mutex.h"
#include "core/string/print_string.h"
#include "core/string/translation_server.h"
#include "core/variant/variant_parser.h"
#include "servers/rendering_server.h"

#ifdef DEBUG_LOAD_THREADED
#define print_lt
#else
#define print_lt(m_text)
#endif

Ref<ResourceFormatLoader> ResourceLoader::loader[ResourceLoader::MAX_LOADERS];

int ResourceLoader::loader_count =;

bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_for_type) const {}

bool ResourceFormatLoader::handles_type(const String &p_type) const {}

void ResourceFormatLoader::get_classes_used(const String &p_path, HashSet<StringName> *r_classes) {}

String ResourceFormatLoader::get_resource_type(const String &p_path) const {}

String ResourceFormatLoader::get_resource_script_class(const String &p_path) const {}

ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const {}

void ResourceFormatLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {}

void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) {}

bool ResourceFormatLoader::exists(const String &p_path) const {}

void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions) const {}

Ref<Resource> ResourceFormatLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {}

void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {}

Error ResourceFormatLoader::rename_dependencies(const String &p_path, const HashMap<String, String> &p_map) {}

void ResourceFormatLoader::_bind_methods() {}

///////////////////////////////////

// These are used before and after a wait for a WorkerThreadPool task
// because that can lead to another load started in the same thread,
// something we must treat as a different stack for the purposes
// of tracking nesting.

#define PREPARE_FOR_WTP_WAIT

#define RESTORE_AFTER_WTP_WAIT

// This should be robust enough to be called redundantly without issues.
void ResourceLoader::LoadToken::clear() {}

ResourceLoader::LoadToken::~LoadToken() {}

Ref<Resource> ResourceLoader::_load(const String &p_path, const String &p_original_path, const String &p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error *r_error, bool p_use_sub_threads, float *r_progress) {}

// This implementation must allow re-entrancy for a task that started awaiting in a deeper stack frame.
void ResourceLoader::_run_load_task(void *p_userdata) {}

static String _validate_local_path(const String &p_path) {}

Error ResourceLoader::load_threaded_request(const String &p_path, const String &p_type_hint, bool p_use_sub_threads, ResourceFormatLoader::CacheMode p_cache_mode) {}

ResourceLoader::LoadToken *ResourceLoader::_load_threaded_request_reuse_user_token(const String &p_path) {}

void ResourceLoader::_load_threaded_request_setup_user_token(LoadToken *p_token, const String &p_path) {}

Ref<Resource> ResourceLoader::load(const String &p_path, const String &p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error *r_error) {}

Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path, const String &p_type_hint, LoadThreadMode p_thread_mode, ResourceFormatLoader::CacheMode p_cache_mode, bool p_for_user) {}

float ResourceLoader::_dependency_get_progress(const String &p_path) {}

ResourceLoader::ThreadLoadStatus ResourceLoader::load_threaded_get_status(const String &p_path, float *r_progress) {}

Ref<Resource> ResourceLoader::load_threaded_get(const String &p_path, Error *r_error) {}

Ref<Resource> ResourceLoader::_load_complete(LoadToken &p_load_token, Error *r_error) {}

Ref<Resource> ResourceLoader::_load_complete_inner(LoadToken &p_load_token, Error *r_error, MutexLock<SafeBinaryMutex<BINARY_MUTEX_TAG>> &p_thread_load_lock) {}

bool ResourceLoader::_ensure_load_progress() {}

Ref<Resource> ResourceLoader::ensure_resource_ref_override_for_outer_load(const String &p_path, const String &p_res_type) {}

Ref<Resource> ResourceLoader::get_resource_ref_override(const String &p_path) {}

bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) {}

void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {}

void ResourceLoader::remove_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader) {}

int ResourceLoader::get_import_order(const String &p_path) {}

String ResourceLoader::get_import_group_file(const String &p_path) {}

bool ResourceLoader::is_import_valid(const String &p_path) {}

bool ResourceLoader::is_imported(const String &p_path) {}

void ResourceLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {}

Error ResourceLoader::rename_dependencies(const String &p_path, const HashMap<String, String> &p_map) {}

void ResourceLoader::get_classes_used(const String &p_path, HashSet<StringName> *r_classes) {}

String ResourceLoader::get_resource_type(const String &p_path) {}

String ResourceLoader::get_resource_script_class(const String &p_path) {}

ResourceUID::ID ResourceLoader::get_resource_uid(const String &p_path) {}

String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_remapped) {}

String ResourceLoader::import_remap(const String &p_path) {}

String ResourceLoader::path_remap(const String &p_path) {}

void ResourceLoader::reload_translation_remaps() {}

void ResourceLoader::load_translation_remaps() {}

void ResourceLoader::clear_translation_remaps() {}

void ResourceLoader::clear_thread_load_tasks() {}

void ResourceLoader::load_path_remaps() {}

void ResourceLoader::clear_path_remaps() {}

void ResourceLoader::set_load_callback(ResourceLoadedCallback p_callback) {}

ResourceLoadedCallback ResourceLoader::_loaded_callback =;

Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(const String &path) {}

bool ResourceLoader::add_custom_resource_format_loader(const String &script_path) {}

void ResourceLoader::set_create_missing_resources_if_class_unavailable(bool p_enable) {}

void ResourceLoader::add_custom_loaders() {}

void ResourceLoader::remove_custom_loaders() {}

bool ResourceLoader::is_cleaning_tasks() {}

void ResourceLoader::initialize() {}

void ResourceLoader::finalize() {}

ResourceLoadErrorNotify ResourceLoader::err_notify =;
DependencyErrorNotify ResourceLoader::dep_err_notify =;

bool ResourceLoader::create_missing_resources_if_class_unavailable =;
bool ResourceLoader::abort_on_missing_resource =;
bool ResourceLoader::timestamp_on_load =;

thread_local int ResourceLoader::load_nesting =;
thread_local Vector<String> ResourceLoader::load_paths_stack;
thread_local HashMap<int, HashMap<String, Ref<Resource>>> ResourceLoader::res_ref_overrides;

SafeBinaryMutex<ResourceLoader::BINARY_MUTEX_TAG> &_get_res_loader_mutex() {}

template <>
thread_local SafeBinaryMutex<ResourceLoader::BINARY_MUTEX_TAG>::TLSData SafeBinaryMutex<ResourceLoader::BINARY_MUTEX_TAG>::tls_data(_get_res_loader_mutex());
SafeBinaryMutex<ResourceLoader::BINARY_MUTEX_TAG> ResourceLoader::thread_load_mutex;
HashMap<String, ResourceLoader::ThreadLoadTask> ResourceLoader::thread_load_tasks;
bool ResourceLoader::cleaning_tasks =;

HashMap<String, ResourceLoader::LoadToken *> ResourceLoader::user_load_tokens;

SelfList<Resource>::List ResourceLoader::remapped_list;
HashMap<String, Vector<String>> ResourceLoader::translation_remaps;
HashMap<String, String> ResourceLoader::path_remaps;

ResourceLoaderImport ResourceLoader::import =;