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