optimize 2d rendering