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