26f3ef
# HG changeset patch
26f3ef
# Parent  b5471d23321d16a0bacc25b7afd27d2e16adba1a
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
26f3ef
@@ -130,18 +130,17 @@ static IntRect CalculateSurfaceBounds(co
26f3ef
   Rect sampledBounds = inverse.TransformBounds(*aBounds);
26f3ef
   if (!sampledBounds.ToIntRect(&bounds)) {
26f3ef
     return surfaceBounds;
26f3ef
   }
26f3ef
 
83ba88
   return surfaceBounds.Intersect(bounds);
83ba88
 }
83ba88
 
83ba88
-static const int kARGBAlphaOffset =
83ba88
-    SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0;
83ba88
+static const int kARGBAlphaOffset = 0;  // Skia is always BGRA SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0;
83ba88
 
83ba88
 static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize,
83ba88
                              const int32_t aStride, SurfaceFormat aFormat) {
26f3ef
   if (aFormat != SurfaceFormat::B8G8R8X8 || aSize.IsEmpty()) {
26f3ef
     return true;
26f3ef
   }
26f3ef
   // We should've initialized the data to be opaque already
26f3ef
   // On debug builds, verify that this is actually true.
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
26f3ef
@@ -84,25 +84,18 @@ enum class SurfaceFormat : int8_t {
26f3ef
   Depth,
26f3ef
 
26f3ef
   // This represents the unknown format.
26f3ef
   UNKNOWN,
26f3ef
 
83ba88
 // The following values are endian-independent synonyms. The _UINT32 suffix
83ba88
 // indicates that the name reflects the layout when viewed as a uint32_t
83ba88
 // value.
83ba88
-#if MOZ_LITTLE_ENDIAN()
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
   //
26f3ef
   // TODO(aosmond): When everything blocking bug 1581828 has been resolved, we
26f3ef
   // can make this use R8B8G8A8 and R8B8G8X8 for non-Windows platforms.
26f3ef
   OS_RGBA = A8R8G8B8_UINT32,
26f3ef
   OS_RGBX = X8R8G8B8_UINT32
26f3ef
 };
26f3ef
diff --git a/gfx/skia/skia/third_party/skcms/skcms.cc b/gfx/skia/skia/third_party/skcms/skcms.cc
26f3ef
--- a/gfx/skia/skia/third_party/skcms/skcms.cc
26f3ef
+++ b/gfx/skia/skia/third_party/skcms/skcms.cc
26f3ef
@@ -25,16 +25,18 @@
26f3ef
         // it'd be a lot slower.  But we want all those headers included so we
26f3ef
         // can use their features after runtime checks later.
26f3ef
         #include <smmintrin.h>
26f3ef
         #include <avxintrin.h>
26f3ef
         #include <avx2intrin.h>
83ba88
         #include <avx512fintrin.h>
83ba88
         #include <avx512dqintrin.h>
83ba88
     #endif
83ba88
+#else
83ba88
+    #define SKCMS_PORTABLE
83ba88
 #endif
83ba88
 
83ba88
 // sizeof(x) will return size_t, which is 32-bit on some machines and 64-bit on others.
26f3ef
 // We have better testing on 64-bit machines, so force 32-bit machines to behave like 64-bit.
26f3ef
 //
26f3ef
 // Please do not use sizeof() directly, and size_t only when required.
26f3ef
 // (We have no way of enforcing these requests...)
26f3ef
 #define SAFE_SIZEOF(x) ((uint64_t)sizeof(x))
26f3ef
@@ -275,30 +277,38 @@ enum {
26f3ef
     skcms_Signature_sf32 = 0x73663332,
26f3ef
     // XYZ is also a PCS signature, so it's defined in skcms.h
26f3ef
     // skcms_Signature_XYZ = 0x58595A20,
26f3ef
 };
26f3ef
 
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)
83ba88
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
83ba88
+    return be;
26f3ef
+#else
83ba88
+    #if defined(_MSC_VER)
26f3ef
     return _byteswap_ushort(be);
26f3ef
-#else
83ba88
+    #else
83ba88
     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)
83ba88
+#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__
83ba88
+    return be;
26f3ef
+#else
83ba88
+    #if defined(_MSC_VER)
26f3ef
     return _byteswap_ulong(be);
26f3ef
-#else
83ba88
+    #else
83ba88
     return __builtin_bswap32(be);
83ba88
+    #endif
83ba88
 #endif
83ba88
 }
83ba88
 
26f3ef
 static int32_t read_big_i32(const uint8_t* ptr) {
26f3ef
     return (int32_t)read_big_u32(ptr);
26f3ef
 }
26f3ef
 
26f3ef
 static float read_big_fixed(const uint8_t* ptr) {