26f3ef
# HG changeset patch
763d03
# Parent  9fcbd287056a40084b1e679f787bf683b291f323
26f3ef
Taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1504834
26f3ef
26f3ef
diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp
26f3ef
--- a/gfx/2d/DrawTargetSkia.cpp
26f3ef
+++ b/gfx/2d/DrawTargetSkia.cpp
763d03
@@ -156,7 +156,8 @@ static IntRect CalculateSurfaceBounds(co
83ba88
 }
83ba88
 
763d03
 static const int kARGBAlphaOffset =
83ba88
-    SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0;
763d03
+    0;  // Skia is always BGRA SurfaceFormat::A8R8G8B8_UINT32 ==
763d03
+        // SurfaceFormat::B8G8R8A8 ? 3 : 0;
83ba88
 
83ba88
 static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize,
83ba88
                              const int32_t aStride, SurfaceFormat aFormat) {
26f3ef
diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h
26f3ef
--- a/gfx/2d/Types.h
26f3ef
+++ b/gfx/2d/Types.h
763d03
@@ -89,18 +89,11 @@ enum class SurfaceFormat : int8_t {
26f3ef
   // This represents the unknown format.
763d03
   UNKNOWN,  // TODO: Replace uses with Maybe<SurfaceFormat>.
26f3ef
 
763d03
-// The following values are endian-independent synonyms. The _UINT32 suffix
763d03
-// indicates that the name reflects the layout when viewed as a uint32_t
763d03
-// value.
83ba88
-#if MOZ_LITTLE_ENDIAN()
763d03
+  // The following values are endian-independent synonyms. The _UINT32 suffix
763d03
+  // indicates that the name reflects the layout when viewed as a uint32_t
763d03
+  // value.
83ba88
   A8R8G8B8_UINT32 = B8G8R8A8,  // 0xAARRGGBB
83ba88
   X8R8G8B8_UINT32 = B8G8R8X8,  // 0x00RRGGBB
83ba88
-#elif MOZ_BIG_ENDIAN()
83ba88
-  A8R8G8B8_UINT32 = A8R8G8B8,  // 0xAARRGGBB
83ba88
-  X8R8G8B8_UINT32 = X8R8G8B8,  // 0x00RRGGBB
83ba88
-#else
83ba88
-#  error "bad endianness"
83ba88
-#endif
83ba88
 
83ba88
   // The following values are OS and endian-independent synonyms.
83ba88
   //
763d03
diff --git a/gfx/skia/skia/modules/skcms/skcms.cc b/gfx/skia/skia/modules/skcms/skcms.cc
763d03
--- a/gfx/skia/skia/modules/skcms/skcms.cc
763d03
+++ b/gfx/skia/skia/modules/skcms/skcms.cc
763d03
@@ -30,6 +30,8 @@
83ba88
         #include <avx512fintrin.h>
83ba88
         #include <avx512dqintrin.h>
83ba88
     #endif
83ba88
+#else
83ba88
+    #define SKCMS_PORTABLE
83ba88
 #endif
83ba88
 
763d03
 static bool runtime_cpu_detection = true;
763d03
@@ -324,20 +326,28 @@ enum {
83ba88
 static uint16_t read_big_u16(const uint8_t* ptr) {
83ba88
     uint16_t be;
83ba88
     memcpy(&be, ptr, sizeof(be));
83ba88
-#if defined(_MSC_VER)
763d03
-    return _byteswap_ushort(be);
83ba88
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
83ba88
+    return be;
763d03
 #else
763d03
-    return __builtin_bswap16(be);
83ba88
+    #if defined(_MSC_VER)
763d03
+     return _byteswap_ushort(be);
83ba88
+    #else
763d03
+     return __builtin_bswap16(be);
83ba88
+    #endif
83ba88
 #endif
83ba88
 }
83ba88
 
83ba88
 static uint32_t read_big_u32(const uint8_t* ptr) {
83ba88
     uint32_t be;
83ba88
     memcpy(&be, ptr, sizeof(be));
83ba88
-#if defined(_MSC_VER)
763d03
-    return _byteswap_ulong(be);
83ba88
+#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__
83ba88
+    return be;
763d03
 #else
763d03
-    return __builtin_bswap32(be);
83ba88
+    #if defined(_MSC_VER)
763d03
+     return _byteswap_ulong(be);
83ba88
+    #else
763d03
+     return __builtin_bswap32(be);
83ba88
+    #endif
83ba88
 #endif
83ba88
 }
83ba88