summaryrefslogtreecommitdiff
path: root/servers/rendering/renderer_rd
diff options
context:
space:
mode:
authorSlugFiller <5435495+SlugFiller@users.noreply.github.com>2023-03-07 08:09:39 +0200
committerYuri Sizov <yuris@humnom.net>2023-03-14 13:59:03 +0100
commitd508d0a6423627859a92c4b4bd45ffa176114066 (patch)
tree7eb53490b014c8fb8ba2caa32c14008fa163f6a4 /servers/rendering/renderer_rd
parent18bf2663f92e2dee528d23a18e336214c8581879 (diff)
Fixes a canvas item set to clip children being drawn as black if no children are visible
(cherry picked from commit f25508befb4f0358ba8a8aaa35cdee4d9c20637c)
Diffstat (limited to 'servers/rendering/renderer_rd')
-rw-r--r--servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
index 78bdd3f541..f49d8be37a 100644
--- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp
@@ -1110,11 +1110,9 @@ void RendererCanvasRenderRD::_render_items(RID p_to_render_target, int p_item_co
RID material = ci->material_owner == nullptr ? ci->material : ci->material_owner->material;
- if (ci->canvas_group != nullptr) {
+ if (ci->use_canvas_group) {
if (ci->canvas_group->mode == RS::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
- if (!p_to_backbuffer) {
- material = default_clip_children_material;
- }
+ material = default_clip_children_material;
} else {
if (material.is_null()) {
if (ci->canvas_group->mode == RS::CANVAS_GROUP_MODE_CLIP_ONLY) {
@@ -1381,6 +1379,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
bool backbuffer_gen_mipmaps = false;
Item *canvas_group_owner = nullptr;
+ bool skip_item = false;
bool update_skeletons = false;
bool time_used = false;
@@ -1453,6 +1452,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
Rect2i group_rect = ci->canvas_group_owner->global_rect_cache;
texture_storage->render_target_copy_to_back_buffer(p_to_render_target, group_rect, false);
if (ci->canvas_group_owner->canvas_group->mode == RS::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
+ ci->canvas_group_owner->use_canvas_group = false;
items[item_count++] = ci->canvas_group_owner;
}
} else if (!backbuffer_cleared) {
@@ -1467,9 +1467,8 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
ci->canvas_group_owner = nullptr; //must be cleared
}
- if (!backbuffer_cleared && canvas_group_owner == nullptr && ci->canvas_group != nullptr && !backbuffer_copy) {
- texture_storage->render_target_clear_back_buffer(p_to_render_target, Rect2i(), Color(0, 0, 0, 0));
- backbuffer_cleared = true;
+ if (canvas_group_owner == nullptr && ci->canvas_group != nullptr && ci->canvas_group->mode != RS::CANVAS_GROUP_MODE_CLIP_AND_DRAW) {
+ skip_item = true;
}
if (ci == canvas_group_owner) {
@@ -1488,6 +1487,11 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
canvas_group_owner = nullptr;
// Backbuffer is dirty now and needs to be re-cleared if another CanvasGroup needs it.
backbuffer_cleared = false;
+
+ // Tell the renderer to paint this as a canvas group
+ ci->use_canvas_group = true;
+ } else {
+ ci->use_canvas_group = false;
}
if (backbuffer_copy) {
@@ -1503,9 +1507,9 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
texture_storage->render_target_copy_to_back_buffer(p_to_render_target, back_buffer_rect, backbuffer_gen_mipmaps);
backbuffer_copy = false;
- backbuffer_gen_mipmaps = false;
material_screen_texture_cached = true; // After a backbuffer copy, screen texture makes no further copies.
material_screen_texture_mipmaps_cached = backbuffer_gen_mipmaps;
+ backbuffer_gen_mipmaps = false;
}
if (backbuffer_gen_mipmaps) {
@@ -1515,7 +1519,11 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
material_screen_texture_mipmaps_cached = true;
}
- items[item_count++] = ci;
+ if (skip_item) {
+ skip_item = false;
+ } else {
+ items[item_count++] = ci;
+ }
if (!ci->next || item_count == MAX_RENDER_ITEMS - 1) {
if (update_skeletons) {
@@ -1523,7 +1531,7 @@ void RendererCanvasRenderRD::canvas_render_items(RID p_to_render_target, Item *p
update_skeletons = false;
}
- _render_items(p_to_render_target, item_count, canvas_transform_inverse, p_light_list, r_sdf_used, false);
+ _render_items(p_to_render_target, item_count, canvas_transform_inverse, p_light_list, r_sdf_used, canvas_group_owner != nullptr);
//then reset
item_count = 0;
}