diff options
author | Juan Linietsky <juan@godotengine.org> | 2019-02-21 20:49:42 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2019-02-21 20:49:42 -0300 |
commit | 8b231b96e347b677ea4189784c960bc4517b8e6a (patch) | |
tree | b5bf271cdce01341e4b221badcdc2c67bbef24f3 /scene/resources/texture.cpp | |
parent | 5784caae73dbb9dcb1e6640884782859c5ab94b6 (diff) |
Implement a cleaner (and better) way to save imagedata from ImageTexture, fixes #18801
Diffstat (limited to 'scene/resources/texture.cpp')
-rw-r--r-- | scene/resources/texture.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 85c22f7bf9..e8cc160acf 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -157,7 +157,7 @@ bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const { void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat")); - p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image")); + p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)); p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, "")); } @@ -178,12 +178,6 @@ 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; @@ -205,9 +199,7 @@ void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags VisualServer::get_singleton()->texture_set_data(texture, p_image); _change_notify(); - if (keep_images_cached) { - image_cache = p_image; - } + image_stored = true; } void ImageTexture::set_flags(uint32_t p_flags) { @@ -255,10 +247,7 @@ void ImageTexture::set_data(const Ref<Image> &p_image) { _change_notify(); alpha_cache.unref(); - - if (keep_images_cached) { - image_cache = p_image; - } + image_stored = true; } void ImageTexture::_resource_path_changed() { @@ -268,10 +257,10 @@ void ImageTexture::_resource_path_changed() { Ref<Image> ImageTexture::get_data() const { - if (image_cache.is_valid()) { - return image_cache; - } else { + if (image_stored) { return VisualServer::get_singleton()->texture_get_data(texture); + } else { + return Ref<Image>(); } } |