73 lines
2.8 KiB
Diff
73 lines
2.8 KiB
Diff
Since this code is broken on BE at this point (OS_RGBA resolves to an
|
|
unhandled thing), temporarily revert to the code present in firefox-esr
|
|
|
|
Upstream issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1616030
|
|
|
|
--- image/decoders/nsGIFDecoder2.cpp
|
|
+++ image/decoders/nsGIFDecoder2.cpp
|
|
@@ -418,10 +418,65 @@ void nsGIFDecoder2::ConvertColormap(uint32_t* aColormap, uint32_t aColors) {
|
|
}
|
|
}
|
|
|
|
+ // since SwizzleRow is broken on BE right now for OS_RGBA, temporarily
|
|
+ // restore this code to whatever it was before the rework...
|
|
+#if MOZ_BIG_ENDIAN()
|
|
+
|
|
+#define BLOCK_RGB_TO_FRGB(from, to) \
|
|
+do { \
|
|
+ uint32_t m0 = ((uint32_t*)from)[0], m1 = ((uint32_t*)from)[1], \
|
|
+ m2 = ((uint32_t*)from)[2], \
|
|
+ p0, p1, p2, p3; \
|
|
+ p0 = 0xFF000000 | ((m0) >> 8); \
|
|
+ p1 = 0xFF000000 | ((m0) << 16) | ((m1) >> 16); \
|
|
+ p2 = 0xFF000000 | ((m1) << 8) | ((m2) >> 24); \
|
|
+ p3 = 0xFF000000 | (m2); \
|
|
+ to[0] = p0; \
|
|
+ to[1] = p1; \
|
|
+ to[2] = p2; \
|
|
+ to[3] = p3; \
|
|
+} while(0)
|
|
+
|
|
+ // Convert from the GIF's RGB format to the Cairo format.
|
|
+ // Work from end to begin, because of the in-place expansion
|
|
+ uint8_t* from = ((uint8_t*)aColormap) + 3 * aColors;
|
|
+ uint32_t* to = aColormap + aColors;
|
|
+
|
|
+ // Convert color entries to Cairo format
|
|
+
|
|
+ // set up for loops below
|
|
+ if (!aColors) {
|
|
+ return;
|
|
+ }
|
|
+ uint32_t c = aColors;
|
|
+
|
|
+ // copy as bytes until source pointer is 32-bit-aligned
|
|
+ // NB: can't use 32-bit reads, they might read off the end of the buffer
|
|
+ for (; (NS_PTR_TO_UINT32(from) & 0x3) && c; --c) {
|
|
+ from -= 3;
|
|
+ *--to = gfxPackedPixel(0xFF, from[0], from[1], from[2]);
|
|
+ }
|
|
+
|
|
+ // bulk copy of pixels.
|
|
+ while (c >= 4) {
|
|
+ from -= 12;
|
|
+ to -= 4;
|
|
+ c -= 4;
|
|
+ BLOCK_RGB_TO_FRGB(from, to);
|
|
+ }
|
|
+
|
|
+ // copy remaining pixel(s)
|
|
+ // NB: can't use 32-bit reads, they might read off the end of the buffer
|
|
+ while (c--) {
|
|
+ from -= 3;
|
|
+ *--to = gfxPackedPixel(0xFF, from[0], from[1], from[2]);
|
|
+ }
|
|
+#else
|
|
// Expand color table from RGB to BGRA.
|
|
MOZ_ASSERT(mSwizzleFn);
|
|
uint8_t* data = reinterpret_cast<uint8_t*>(aColormap);
|
|
mSwizzleFn(data, data, aColors);
|
|
+#endif
|
|
}
|
|
|
|
LexerResult nsGIFDecoder2::DoDecode(SourceBufferIterator& aIterator,
|