This is a reland of #5638. We removed the restoreToCount, made doAntiAlias named, and updated the comments.