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