Move RenderState manipulation out of a loop so that we thrash it less

It doesn't really make sense to say that we're idle when we're
potentially still rendering.