CPU optimisation. Use a copy of canvas dimensions.