Factorize some rendering loops.