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()) {
return;
}
@ -1107,6 +1107,14 @@ void CanvasItem::_update_texture_filter_changed(bool p_propagate) {
} else {
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);
queue_redraw();
@ -1133,7 +1141,7 @@ CanvasItem::TextureFilter CanvasItem::get_texture_filter() const {
return texture_filter;
}
void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
void CanvasItem::_refresh_texture_repeat_cache() {
if (!is_inside_tree()) {
return;
}
@ -1148,6 +1156,14 @@ void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
} else {
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);
queue_redraw();
if (p_propagate) {
@ -1189,6 +1205,16 @@ CanvasItem::TextureRepeat CanvasItem::get_texture_repeat() const {
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() :
xform_change(this) {
canvas_item = RenderingServer::get_singleton()->canvas_item_create();

View File

@ -121,7 +121,9 @@ private:
static CanvasItem *current_item_drawn;
friend class Viewport;
void _refresh_texture_repeat_cache();
void _update_texture_repeat_changed(bool p_propagate);
void _refresh_texture_filter_cache();
void _update_texture_filter_changed(bool p_propagate);
protected:
@ -310,6 +312,9 @@ public:
virtual void set_texture_repeat(TextureRepeat p_texture_repeat);
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
virtual Rect2 get_anchorable_rect() const { return Rect2(0, 0, 0, 0); };