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