Skip to content

Commit 39423d9

Browse files
committed
Faster exit from _cull_canvas_item if alpha is zero
1 parent 1ba920f commit 39423d9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

servers/rendering/renderer_canvas_cull.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,19 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2
239239
ci->children_order_dirty = false;
240240
}
241241

242+
if (ci->use_parent_material && p_material_owner) {
243+
ci->material_owner = p_material_owner;
244+
} else {
245+
p_material_owner = ci;
246+
ci->material_owner = nullptr;
247+
}
248+
249+
Color modulate = ci->modulate * p_modulate;
250+
251+
if (modulate.a < 0.007) {
252+
return;
253+
}
254+
242255
Rect2 rect = ci->get_rect();
243256

244257
if (ci->visibility_notifier) {
@@ -256,19 +269,6 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2
256269
Rect2 global_rect = xform.xform(rect);
257270
global_rect.position += p_clip_rect.position;
258271

259-
if (ci->use_parent_material && p_material_owner) {
260-
ci->material_owner = p_material_owner;
261-
} else {
262-
p_material_owner = ci;
263-
ci->material_owner = nullptr;
264-
}
265-
266-
Color modulate(ci->modulate.r * p_modulate.r, ci->modulate.g * p_modulate.g, ci->modulate.b * p_modulate.b, ci->modulate.a * p_modulate.a);
267-
268-
if (modulate.a < 0.007) {
269-
return;
270-
}
271-
272272
int child_item_count = ci->child_items.size();
273273
Item **child_items = ci->child_items.ptrw();
274274

0 commit comments

Comments
 (0)