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