move all duplicated viewport code to drawable.cpp