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