add function to disable CPU detection

Might as well make this a real skcms API.

Bug: skia:10009
Change-Id: Ie901405527d24b87a9463dda1c52ec123a12ca1f
Reviewed-on: https://skia-review.googlesource.com/c/skcms/+/291830
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/skcms.cc b/skcms.cc
index 5d6ae3d..92af963 100644
--- a/skcms.cc
+++ b/skcms.cc
@@ -32,6 +32,11 @@
     #endif
 #endif
 
+static bool runtime_cpu_detection = true;
+void skcms_DisableRuntimeCPUDetection() {
+    runtime_cpu_detection = false;
+}
+
 // sizeof(x) will return size_t, which is 32-bit on some machines and 64-bit on others.
 // We have better testing on 64-bit machines, so force 32-bit machines to behave like 64-bit.
 //
@@ -2143,6 +2148,9 @@
         enum class CpuType { None, HSW, SKX };
         static CpuType cpu_type() {
             static const CpuType type = []{
+                if (!runtime_cpu_detection) {
+                    return CpuType::None;
+                }
                 // See http://www.sandpile.org/x86/cpuid.htm
 
                 // First, a basic cpuid(1) lets us check prerequisites for HSW, SKX.
diff --git a/skcms.h b/skcms.h
index 486844a..eec1442 100644
--- a/skcms.h
+++ b/skcms.h
@@ -307,6 +307,9 @@
                                        float wx, float wy,
                                        skcms_Matrix3x3* toXYZD50);
 
+// Call before your first call to skcms_Transform() to skip runtime CPU detection.
+SKCMS_API void skcms_DisableRuntimeCPUDetection(void);
+
 // Utilities for programmatically constructing profiles
 static inline void skcms_Init(skcms_ICCProfile* p) {
     memset(p, 0, sizeof(*p));