viewport: Clean up drawing of borders and paths.

Simplify variable usage, merge common code.