[refactor] use precomputed viewport dimensions