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