Australian opener Usman Khawaja ended a lengthy drought, cruising to a century against Sri Lanka on the first day of the Test.