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