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