Make canvas transform matrix account for devicePixelRatio

Fixes #2477.