Add support for retina displays to sk_app.

The macOS view system is in "big pixel" units, so translate these
into "physical pixel" units.

To compensate, add sk_app::Window::scaleFactor() which returns the
scale factor. The viewer app is modified to apply the inverse of
this scale factor to the current zoom level.

Change-Id: I4fac066a230c87793fc5a0e5a582d60d25e46e7b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361558
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index c90236c..7a2dd0c 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -376,6 +376,11 @@
     fDisplay = fWindow->getRequestedDisplayParams();
     fRefresh = FLAGS_redraw;
 
+    // computePreTouchMatrix uses exp(fZoomLevel) to compute the scale.
+    float scaleFactor = fWindow->scaleFactor();
+    fZoomLevel = log(scaleFactor);
+    fImGuiLayer.setScaleFactor(scaleFactor);
+
     // Configure timers
     fStatsLayer.setActive(FLAGS_stats);
     fAnimateTimer = fStatsLayer.addTimer("Animate", SK_ColorMAGENTA, 0xffff66ff);