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