e98f2c
# HG changeset patch
e98f2c
# User msirringhaus@suse.de
e98f2c
# Date 1582805876 -3600
e98f2c
#      Thu Feb 27 13:17:56 2020 +0100
e98f2c
# Node ID cc3d09abea31068e57f1ab918782f9f86fc6a158
e98f2c
# Parent  9cd90914846f667f18babc491a74c164ae5d6e9f
e98f2c
imported patch decoder_workaround.patch
e98f2c
e98f2c
diff -r 9cd90914846f image/decoders/nsGIFDecoder2.cpp
e98f2c
--- a/image/decoders/nsGIFDecoder2.cpp	Thu Feb 27 12:57:14 2020 +0100
e98f2c
+++ b/image/decoders/nsGIFDecoder2.cpp	Fri Mar 27 13:06:18 2020 +0100
e98f2c
@@ -422,6 +422,9 @@
e98f2c
   MOZ_ASSERT(mSwizzleFn);
e98f2c
   uint8_t* data = reinterpret_cast<uint8_t*>(aColormap);
e98f2c
   mSwizzleFn(data, data, aColors);
e98f2c
+#if MOZ_BIG_ENDIAN()
e98f2c
+  SwizzleRow(SurfaceFormat::A8R8G8B8, SurfaceFormat::B8G8R8A8)(data, data, aColors);
e98f2c
+#endif
e98f2c
 }
e98f2c
 
e98f2c
 LexerResult nsGIFDecoder2::DoDecode(SourceBufferIterator& aIterator,
e98f2c
diff -r 9cd90914846f image/decoders/nsJPEGDecoder.cpp
e98f2c
--- a/image/decoders/nsJPEGDecoder.cpp	Thu Feb 27 12:57:14 2020 +0100
e98f2c
+++ b/image/decoders/nsJPEGDecoder.cpp	Fri Mar 27 13:06:18 2020 +0100
e98f2c
@@ -263,6 +263,9 @@
e98f2c
         case JCS_YCbCr:
e98f2c
           // By default, we will output directly to BGRA. If we need to apply
e98f2c
           // special color transforms, this may change.
e98f2c
+#if MOZ_BIG_ENDIAN()
e98f2c
+          mInfo.out_color_space = MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB;
e98f2c
+#else
e98f2c
           switch (SurfaceFormat::OS_RGBX) {
e98f2c
             case SurfaceFormat::B8G8R8X8:
e98f2c
               mInfo.out_color_space = JCS_EXT_BGRX;
e98f2c
@@ -277,6 +280,7 @@
e98f2c
               mState = JPEG_ERROR;
e98f2c
               return Transition::TerminateFailure();
e98f2c
           }
e98f2c
+#endif
e98f2c
           break;
e98f2c
         case JCS_CMYK:
e98f2c
         case JCS_YCCK:
e98f2c
diff -r 9cd90914846f image/decoders/nsPNGDecoder.cpp
e98f2c
--- a/image/decoders/nsPNGDecoder.cpp	Thu Feb 27 12:57:14 2020 +0100
e98f2c
+++ b/image/decoders/nsPNGDecoder.cpp	Fri Mar 27 13:06:18 2020 +0100
e98f2c
@@ -361,7 +361,7 @@
e98f2c
                                    IResumable* aOnResume) {
e98f2c
   MOZ_ASSERT(!HasError(), "Shouldn't call DoDecode after error!");
e98f2c
 
e98f2c
-  return mLexer.Lex(aIterator, aOnResume,
e98f2c
+  LexerResult res = mLexer.Lex(aIterator, aOnResume,
e98f2c
                     [=](State aState, const char* aData, size_t aLength) {
e98f2c
                       switch (aState) {
e98f2c
                         case State::PNG_DATA:
e98f2c
@@ -371,6 +371,14 @@
e98f2c
                       }
e98f2c
                       MOZ_CRASH("Unknown State");
e98f2c
                     });
e98f2c
+
e98f2c
+#if MOZ_BIG_ENDIAN()
e98f2c
+  if(res.is<TerminalState>() && res.as<TerminalState>() == TerminalState::SUCCESS) {
e98f2c
+      NativeEndian::swapToLittleEndianInPlace<uint32_t>((uint32_t*)(mImageData), mImageDataLength / 4);
e98f2c
+  }
e98f2c
+#endif
e98f2c
+
e98f2c
+  return res;
e98f2c
 }
e98f2c
 
e98f2c
 LexerTransition<nsPNGDecoder::State> nsPNGDecoder::ReadPNGData(
e98f2c
diff -r 9cd90914846f image/decoders/nsWebPDecoder.cpp
e98f2c
--- a/image/decoders/nsWebPDecoder.cpp	Thu Feb 27 12:57:14 2020 +0100
e98f2c
+++ b/image/decoders/nsWebPDecoder.cpp	Fri Mar 27 13:06:18 2020 +0100
e98f2c
@@ -237,7 +237,12 @@
e98f2c
   // WebP doesn't guarantee that the alpha generated matches the hint in the
e98f2c
   // header, so we always need to claim the input is BGRA. If the output is
e98f2c
   // BGRX, swizzling will mask off the alpha channel.
e98f2c
+#if MOZ_BIG_ENDIAN()
e98f2c
+  mBuffer.colorspace = MODE_ARGB;
e98f2c
+  SurfaceFormat inFormat = mFormat;
e98f2c
+#else
e98f2c
   SurfaceFormat inFormat = SurfaceFormat::OS_RGBA;
e98f2c
+#endif
e98f2c
 
e98f2c
   SurfacePipeFlags pipeFlags = SurfacePipeFlags();
e98f2c
   if (mFormat == SurfaceFormat::OS_RGBA &&
e98f2c