Merge pull request #66546 from KoBeWi/rfeipletaetr

Add methods to get target filter and repeat
This commit is contained in:
Clay John 2022-10-19 13:55:57 -07:00 committed by GitHub
commit a8c805be29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

@ -1092,7 +1092,7 @@ int CanvasItem::get_canvas_layer() const {
} }
} }
void CanvasItem::_update_texture_filter_changed(bool p_propagate) { void CanvasItem::_refresh_texture_filter_cache() {
if (!is_inside_tree()) { if (!is_inside_tree()) {
return; return;
} }
@ -1107,6 +1107,14 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) {
} else { } else {
texture_filter_cache = RS::CanvasItemTextureFilter(texture_filter); texture_filter_cache = RS::CanvasItemTextureFilter(texture_filter);
} }
}
void CanvasItem::_update_texture_filter_changed(bool p_propagate) {
if (!is_inside_tree()) {
return;
}
_refresh_texture_filter_cache();
RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache); RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache);
queue_redraw(); queue_redraw();
@ -1133,7 +1141,7 @@ CanvasItem::TextureFilter CanvasItem::get_texture_filter() const {
return texture_filter; return texture_filter;
} }
void CanvasItem::_update_texture_repeat_changed(bool p_propagate) { void CanvasItem::_refresh_texture_repeat_cache() {
if (!is_inside_tree()) { if (!is_inside_tree()) {
return; return;
} }
@ -1148,6 +1156,14 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
} else { } else {
texture_repeat_cache = RS::CanvasItemTextureRepeat(texture_repeat); texture_repeat_cache = RS::CanvasItemTextureRepeat(texture_repeat);
} }
}
void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
if (!is_inside_tree()) {
return;
}
_refresh_texture_repeat_cache();
RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache); RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache);
queue_redraw(); queue_redraw();
if (p_propagate) { if (p_propagate) {
@ -1189,6 +1205,16 @@ CanvasItem::TextureRepeat CanvasItem::get_texture_repeat() const {
return texture_repeat; return texture_repeat;
} }
CanvasItem::TextureFilter CanvasItem::get_texture_filter_in_tree() {
_refresh_texture_filter_cache();
return (TextureFilter)texture_filter_cache;
}
CanvasItem::TextureRepeat CanvasItem::get_texture_repeat_in_tree() {
_refresh_texture_repeat_cache();
return (TextureRepeat)texture_repeat_cache;
}
CanvasItem::CanvasItem() : CanvasItem::CanvasItem() :
xform_change(this) { xform_change(this) {
canvas_item = RenderingServer::get_singleton()->canvas_item_create(); canvas_item = RenderingServer::get_singleton()->canvas_item_create();

View File

@ -121,7 +121,9 @@ private:
static CanvasItem *current_item_drawn; static CanvasItem *current_item_drawn;
friend class Viewport; friend class Viewport;
void _refresh_texture_repeat_cache();
void _update_texture_repeat_changed(bool p_propagate); void _update_texture_repeat_changed(bool p_propagate);
void _refresh_texture_filter_cache();
void _update_texture_filter_changed(bool p_propagate); void _update_texture_filter_changed(bool p_propagate);
protected: protected:
@ -310,6 +312,9 @@ public:
virtual void set_texture_repeat(TextureRepeat p_texture_repeat); virtual void set_texture_repeat(TextureRepeat p_texture_repeat);
TextureRepeat get_texture_repeat() const; TextureRepeat get_texture_repeat() const;
TextureFilter get_texture_filter_in_tree();
TextureRepeat get_texture_repeat_in_tree();
// Used by control nodes to retrieve the parent's anchorable area // Used by control nodes to retrieve the parent's anchorable area
virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); }; virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); };