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