From 1075931c64716f634ed5efb842e6173d813ab03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 17 Feb 2023 12:28:39 +0100 Subject: Remove unexposed ProxyTexture, mark AnimatedTexture as deprecated According to reduz: > [AnimatedTexture] should be removed together with ProxyTexture, its just > not efficient at all in Vulkan and causes invalidation of all descriptor > sets depending on it > it was needed mostly for animated tilemaps, but nowadays there is not a lot > of reason for it Marking AnimatedTexture as deprecated accordingly, until we reach consensus for removing it completely. --- doc/classes/AnimatedTexture.xml | 3 +- scene/resources/texture.cpp | 67 ----------------------------------------- scene/resources/texture.h | 23 -------------- 3 files changed, 2 insertions(+), 91 deletions(-) diff --git a/doc/classes/AnimatedTexture.xml b/doc/classes/AnimatedTexture.xml index 454b9c1c32..052c55dfb6 100644 --- a/doc/classes/AnimatedTexture.xml +++ b/doc/classes/AnimatedTexture.xml @@ -1,5 +1,5 @@ - + Proxy texture for simple frame-based animations. @@ -8,6 +8,7 @@ The playback of the animation is controlled by the [member speed_scale] property, as well as each frame's duration (see [method set_frame_duration]). The animation loops, i.e. it will restart at frame 0 automatically after playing the last frame. [AnimatedTexture] currently requires all frame textures to have the same size, otherwise the bigger ones will be cropped to match the smallest one. [b]Note:[/b] AnimatedTexture doesn't support using [AtlasTexture]s. Each frame needs to be a separate [Texture2D]. + [b]Warning:[/b] AnimatedTexture is deprecated, and might be removed in a future release. Its current implementation is not efficient for the modern renderers. diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 085becb033..05be40c446 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -2566,73 +2566,6 @@ void GradientTexture2D::_bind_methods() { ////////////////////////////////////// -void ProxyTexture::set_base(const Ref &p_texture) { - ERR_FAIL_COND(p_texture == this); - - base = p_texture; - if (base.is_valid()) { - ERR_FAIL_NULL(RenderingServer::get_singleton()); - if (proxy_ph.is_valid()) { - RS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); - RS::get_singleton()->free(proxy_ph); - proxy_ph = RID(); - } else if (proxy.is_valid()) { - RS::get_singleton()->texture_proxy_update(proxy, base->get_rid()); - } else { - proxy = RS::get_singleton()->texture_proxy_create(base->get_rid()); - } - } -} - -Ref ProxyTexture::get_base() const { - return base; -} - -int ProxyTexture::get_width() const { - if (base.is_valid()) { - return base->get_width(); - } - return 1; -} - -int ProxyTexture::get_height() const { - if (base.is_valid()) { - return base->get_height(); - } - return 1; -} - -RID ProxyTexture::get_rid() const { - if (proxy.is_null()) { - proxy_ph = RS::get_singleton()->texture_2d_placeholder_create(); - proxy = RS::get_singleton()->texture_proxy_create(proxy_ph); - } - return proxy; -} - -bool ProxyTexture::has_alpha() const { - if (base.is_valid()) { - return base->has_alpha(); - } - return false; -} - -ProxyTexture::ProxyTexture() { - //proxy = RS::get_singleton()->texture_create(); -} - -ProxyTexture::~ProxyTexture() { - ERR_FAIL_NULL(RenderingServer::get_singleton()); - if (proxy_ph.is_valid()) { - RS::get_singleton()->free(proxy_ph); - } - if (proxy.is_valid()) { - RS::get_singleton()->free(proxy); - } -} - -////////////////////////////////////////////// - void AnimatedTexture::_update_proxy() { RWLockRead r(rw_lock); diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 7f74ae6941..7c4d479da8 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -892,29 +892,6 @@ public: VARIANT_ENUM_CAST(GradientTexture2D::Fill); VARIANT_ENUM_CAST(GradientTexture2D::Repeat); -class ProxyTexture : public Texture2D { -private: - mutable RID proxy_ph; - mutable RID proxy; - Ref base; - -protected: - static void _bind_methods(); - -public: - void set_base(const Ref &p_texture); - Ref get_base() const; - - virtual int get_width() const override; - virtual int get_height() const override; - virtual RID get_rid() const override; - - virtual bool has_alpha() const override; - - ProxyTexture(); - ~ProxyTexture(); -}; - class AnimatedTexture : public Texture2D { GDCLASS(AnimatedTexture, Texture2D); -- cgit v1.2.3