Skip to content

Commit

Permalink
Merge pull request #66546 from KoBeWi/rfeipletaetr
Browse files Browse the repository at this point in the history
Add methods to get target filter and repeat
  • Loading branch information
clayjohn authored Oct 19, 2022
2 parents f63b2a9 + 4efa851 commit a8c805b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
30 changes: 28 additions & 2 deletions scene/main/canvas_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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();

Expand All @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions scene/main/canvas_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ class CanvasItem : public Node {

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:
Expand Down Expand Up @@ -310,6 +312,9 @@ class CanvasItem : public Node {
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); };

Expand Down

0 comments on commit a8c805b

Please sign in to comment.