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