Move SSD rotation dispatch to typed Kotlin

ober

a3e6d776199944b464e68f77b4094f02351dfc26

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 8d5bfca..e739edf 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -1175,6 +1175,7 @@
                 rotatedDisplayWidth rotatedDisplayHeight
                 rotatedDisplayWidthFloat rotatedDisplayHeightFloat
                 viewportCenterOffsetDelta nextRotationDegrees
+                rotationIs90 rotationIs180 rotationIs270
                 touchMoveExceeded shouldCollectSelectionMatches
                 selectionUsesRawRect selectionHasMatches
                 motionActionIsDown motionActionIsMove
@@ -1284,6 +1285,12 @@
           (- (/ (float32 viewportSize) (float32 2.0)) center))
         (def (nextRotationDegrees (rotationDegrees : Int32)) : Int32
           (mod (+ rotationDegrees (int32 90)) (int32 360)))
+        (def (rotationIs90 (rotationDegrees : Int32)) : Bool
+          (= rotationDegrees (int32 90)))
+        (def (rotationIs180 (rotationDegrees : Int32)) : Bool
+          (= rotationDegrees (int32 180)))
+        (def (rotationIs270 (rotationDegrees : Int32)) : Bool
+          (= rotationDegrees (int32 270)))
         (def (touchMoveExceeded (dx : Float32) (dy : Float32)) : Bool
           (or (> (float32-abs dx) (float32 2.0))
               (> (float32-abs dy) (float32 2.0))))
@@ -7573,19 +7580,15 @@
        "        val img = bitmap"
        "        matrix.reset()"
        "        if (img != null) {"
-       "            when (rotationDegrees) {"
-       "                90 -> {"
-       "                    matrix.postRotate(90f)"
-       "                    matrix.postTranslate(img.height.toFloat(), 0f)"
-       "                }"
-       "                180 -> {"
-       "                    matrix.postRotate(180f)"
-       "                    matrix.postTranslate(img.width.toFloat(), img.height.toFloat())"
-       "                }"
-       "                270 -> {"
-       "                    matrix.postRotate(270f)"
-       "                    matrix.postTranslate(0f, img.width.toFloat())"
-       "                }"
+       "            if (rotationIs90(rotationDegrees)) {"
+       "                matrix.postRotate(90f)"
+       "                matrix.postTranslate(img.height.toFloat(), 0f)"
+       "            } else if (rotationIs180(rotationDegrees)) {"
+       "                matrix.postRotate(180f)"
+       "                matrix.postTranslate(img.width.toFloat(), img.height.toFloat())"
+       "            } else if (rotationIs270(rotationDegrees)) {"
+       "                matrix.postRotate(270f)"
+       "                matrix.postTranslate(0f, img.width.toFloat())"
        "            }"
        "        }"
        "        matrix.postScale(scale, scale)"