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