pin in Sk4f_toL32()

It's looking too hairy to make SkNx_cast() itself pin.

There will be more of these that I'll have to work
through as they come up, hopefully by funneling them
through to this function.

Change-Id: I534e2dc612f30f2ea9692fd6b466ba59692ef4e2
Reviewed-on: https://skia-review.googlesource.com/154400
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkPM4fPriv.h b/src/core/SkPM4fPriv.h
index 5c02e90..6c98cbc 100644
--- a/src/core/SkPM4fPriv.h
+++ b/src/core/SkPM4fPriv.h
@@ -32,8 +32,19 @@
 }
 
 static inline uint32_t Sk4f_toL32(const Sk4f& px) {
+    Sk4f v = px;
+
+#if !defined(SKNX_NO_SIMD) && SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+    // SkNx_cast<uint8_t, int32_t>() pins, and we don't anticipate giant floats
+#elif !defined(SKNX_NO_SIMD) && defined(SK_ARM_HAS_NEON)
+    // SkNx_cast<uint8_t, int32_t>() pins, and so does Sk4f_round().
+#else
+    // No guarantee of a pin.
+    v = Sk4f::Max(0, Sk4f::Min(v, 1));
+#endif
+
     uint32_t l32;
-    SkNx_cast<uint8_t>(Sk4f_round(px * 255.0f)).store(&l32);
+    SkNx_cast<uint8_t>(Sk4f_round(v * 255.0f)).store(&l32);
     return l32;
 }