fix refresh with rotation and viewport

Unfortunately, not yet tested, so handle with care.