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