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