diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/surface_tool.cpp | 2 | ||||
-rw-r--r-- | scene/resources/surface_tool.h | 2 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 20 | ||||
-rw-r--r-- | scene/resources/texture.h | 5 | ||||
-rw-r--r-- | scene/resources/theme.cpp | 29 | ||||
-rw-r--r-- | scene/resources/theme.h | 1 |
6 files changed, 42 insertions, 17 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 1684cbf15f..2116dd0b1e 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -1021,8 +1021,6 @@ void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &SurfaceTool::generate_normals, DEFVAL(false)); ClassDB::bind_method(D_METHOD("generate_tangents"), &SurfaceTool::generate_tangents); - ClassDB::bind_method(D_METHOD("add_to_format", "flags"), &SurfaceTool::add_to_format); - ClassDB::bind_method(D_METHOD("set_material", "material"), &SurfaceTool::set_material); ClassDB::bind_method(D_METHOD("clear"), &SurfaceTool::clear); diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index 754254150d..ef13238c13 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -118,8 +118,6 @@ public: void generate_normals(bool p_flip = false); void generate_tangents(); - void add_to_format(int p_flags) { format |= p_flags; } - void set_material(const Ref<Material> &p_material); void clear(); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 3870916779..26036c08a9 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -178,6 +178,12 @@ void ImageTexture::_reload_hook(const RID &p_hook) { _change_notify(); } +bool ImageTexture::keep_images_cached = false; + +void ImageTexture::set_keep_images_cached(bool p_enable) { + keep_images_cached = p_enable; +} + void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags) { flags = p_flags; @@ -198,6 +204,10 @@ void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags VisualServer::get_singleton()->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_flags); VisualServer::get_singleton()->texture_set_data(texture, p_image); _change_notify(); + + if (keep_images_cached) { + image_cache = p_image; + } } void ImageTexture::set_flags(uint32_t p_flags) { @@ -245,6 +255,10 @@ void ImageTexture::set_data(const Ref<Image> &p_image) { _change_notify(); alpha_cache.unref(); + + if (keep_images_cached) { + image_cache = p_image; + } } void ImageTexture::_resource_path_changed() { @@ -254,7 +268,11 @@ void ImageTexture::_resource_path_changed() { Ref<Image> ImageTexture::get_data() const { - return VisualServer::get_singleton()->texture_get_data(texture); + if (image_cache.is_valid()) { + return image_cache; + } else { + return VisualServer::get_singleton()->texture_get_data(texture); + } } int ImageTexture::get_width() const { diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 2b67ebec62..4b5b504510 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -111,6 +111,7 @@ private: Size2 size_override; float lossy_storage_quality; mutable Ref<BitMap> alpha_cache; + Ref<Image> image_cache; protected: virtual void reload_from_file(); @@ -125,7 +126,11 @@ protected: void _set_data(Dictionary p_data); + static bool keep_images_cached; + public: + static void set_keep_images_cached(bool p_enable); + void create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT); void create_from_image(const Ref<Image> &p_image, uint32_t p_flags = FLAGS_DEFAULT); diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 786a136040..87b40d5447 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -622,43 +622,47 @@ void Theme::clear() { void Theme::copy_default_theme() { Ref<Theme> default_theme = get_default(); + copy_theme(default_theme); +} + +void Theme::copy_theme(const Ref<Theme> &p_other) { //these need reconnecting, so add normally { const StringName *K = NULL; - while ((K = default_theme->icon_map.next(K))) { + while ((K = p_other->icon_map.next(K))) { const StringName *L = NULL; - while ((L = default_theme->icon_map[*K].next(L))) { - set_icon(*K, *L, default_theme->icon_map[*K][*L]); + while ((L = p_other->icon_map[*K].next(L))) { + set_icon(*L, *K, p_other->icon_map[*K][*L]); } } } { const StringName *K = NULL; - while ((K = default_theme->style_map.next(K))) { + while ((K = p_other->style_map.next(K))) { const StringName *L = NULL; - while ((L = default_theme->style_map[*K].next(L))) { - set_stylebox(*K, *L, default_theme->style_map[*K][*L]); + while ((L = p_other->style_map[*K].next(L))) { + set_stylebox(*L, *K, p_other->style_map[*K][*L]); } } } { const StringName *K = NULL; - while ((K = default_theme->font_map.next(K))) { + while ((K = p_other->font_map.next(K))) { const StringName *L = NULL; - while ((L = default_theme->font_map[*K].next(L))) { - set_font(*K, *L, default_theme->font_map[*K][*L]); + while ((L = p_other->font_map[*K].next(L))) { + set_font(*L, *K, p_other->font_map[*K][*L]); } } } //these are ok to just copy - color_map = default_theme->color_map; - constant_map = default_theme->constant_map; - shader_map = default_theme->shader_map; + color_map = p_other->color_map; + constant_map = p_other->constant_map; + shader_map = p_other->shader_map; _change_notify(); emit_changed(); @@ -752,6 +756,7 @@ void Theme::_bind_methods() { ClassDB::bind_method(D_METHOD("_emit_theme_changed"), &Theme::_emit_theme_changed); ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme); + ClassDB::bind_method("copy_theme", &Theme::copy_theme); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "default_font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_default_font", "get_default_font"); } diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 021a2936bd..fb59073cbe 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -184,6 +184,7 @@ public: void get_type_list(List<StringName> *p_list) const; void copy_default_theme(); + void copy_theme(const Ref<Theme> &p_other); void clear(); Theme(); |