mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
2D: Fix CanvasTexture rendering when updating channels
This commit is contained in:
parent
b0655dc86f
commit
663917449b
4 changed files with 55 additions and 0 deletions
|
|
@ -43,9 +43,15 @@ using namespace RendererRD;
|
|||
void TextureStorage::CanvasTexture::clear_cache() {
|
||||
info_cache[0] = CanvasTextureCache();
|
||||
info_cache[1] = CanvasTextureCache();
|
||||
if (invalidated_callback != nullptr) {
|
||||
invalidated_callback(false, invalidated_callback_userdata);
|
||||
}
|
||||
}
|
||||
|
||||
TextureStorage::CanvasTexture::~CanvasTexture() {
|
||||
if (invalidated_callback != nullptr) {
|
||||
invalidated_callback(true, invalidated_callback_userdata);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -735,6 +741,16 @@ TextureStorage::CanvasTextureInfo TextureStorage::canvas_texture_get_info(RID p_
|
|||
return res;
|
||||
}
|
||||
|
||||
void TextureStorage::canvas_texture_set_invalidation_callback(RID p_canvas_texture, InvalidationCallback p_callback, void *p_userdata) {
|
||||
CanvasTexture *ct = canvas_texture_owner.get_or_null(p_canvas_texture);
|
||||
if (!ct) {
|
||||
return;
|
||||
}
|
||||
|
||||
ct->invalidated_callback = p_callback;
|
||||
ct->invalidated_callback_userdata = p_userdata;
|
||||
}
|
||||
|
||||
/* Texture API */
|
||||
|
||||
RID TextureStorage::texture_allocate() {
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ public:
|
|||
_FORCE_INLINE_ bool is_null() const { return diffuse.is_null(); }
|
||||
};
|
||||
|
||||
typedef void (*InvalidationCallback)(bool p_deleted, void *p_userdata);
|
||||
|
||||
private:
|
||||
friend class LightStorage;
|
||||
friend class MaterialStorage;
|
||||
|
|
@ -118,6 +120,9 @@ private:
|
|||
RS::CanvasItemTextureRepeat texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
|
||||
CanvasTextureCache info_cache[2];
|
||||
|
||||
InvalidationCallback invalidated_callback = nullptr;
|
||||
void *invalidated_callback_userdata = nullptr;
|
||||
|
||||
Size2i size_cache = Size2i(1, 1);
|
||||
bool use_normal_cache = false;
|
||||
bool use_specular_cache = false;
|
||||
|
|
@ -499,6 +504,7 @@ public:
|
|||
virtual void canvas_texture_set_texture_repeat(RID p_item, RS::CanvasItemTextureRepeat p_repeat) override;
|
||||
|
||||
CanvasTextureInfo canvas_texture_get_info(RID p_texture, RS::CanvasItemTextureFilter p_base_filter, RS::CanvasItemTextureRepeat p_base_repeat, bool p_use_srgb, bool p_texture_is_data);
|
||||
void canvas_texture_set_invalidation_callback(RID p_canvas_texture, InvalidationCallback p_callback, void *p_userdata);
|
||||
|
||||
/* Texture API */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue