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