MFH: r525179

www/firefox: apply upstream powerpc64 fixes

Many of these are stalled on review for various reasons but the intent
of each seems clear enough to keep rebasing or ask upstream for help.
pkg-fallout@ would identify rebase mistakes while atomic changes would
identify when a particular patch is no longer useful.

Submitted by:	mikael (via D21765)
Approved by:	ports-secteam blanket
This commit is contained in:
Jan Beich 2020-02-10 17:04:44 +00:00
parent 3a80afeba6
commit 0005fb1bf3
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/branches/2020Q1/; revision=525722
5 changed files with 282 additions and 0 deletions

View File

@ -0,0 +1,43 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=1269654#c5
https://bug1269654.bmoattachments.org/attachment.cgi?id=8749234
handle big-endian formats in Cairo format conversions
# HG changeset patch
# User Lee Salzman <lsalzman@mozilla.com>
# Date 1462463631 14400
# Thu May 05 11:53:51 2016 -0400
# Node ID 8da374804a09977c8f89af5e6e0cb37cb074595d
# Parent 29662e28a9c93ac67ee0b8ddfb65a9f29bbf73f5
handle big-endian formats in Cairo format conversions
--- gfx/2d/HelpersCairo.h.orig 2019-12-02 17:51:16.633474000 +0100
+++ gfx/2d/HelpersCairo.h 2019-12-02 17:52:44.939998000 +0100
@@ -147,7 +147,14 @@ static inline cairo_format_t GfxFormatToCairoFormat(Su
case SurfaceFormat::R5G6B5_UINT16:
return CAIRO_FORMAT_RGB16_565;
default:
- gfxCriticalError() << "Unknown image format " << (int)format;
+ // _UINT32 formats don't match B8G8R8[AX]8 on big-endian platforms,
+ // and Moz2d uses B8G8R8[AX]8 as if it was _UINT32.
+ // See bug 1269654
+ if (format == SurfaceFormat::B8G8R8X8) {
+ return CAIRO_FORMAT_RGB24;
+ } else if (format != SurfaceFormat::B8G8R8A8) {
+ gfxCriticalError() << "Unknown image format " << (int)format;
+ }
return CAIRO_FORMAT_ARGB32;
}
}
@@ -177,7 +184,11 @@ static inline cairo_content_t GfxFormatToCairoContent(
case SurfaceFormat::A8:
return CAIRO_CONTENT_ALPHA;
default:
- gfxCriticalError() << "Unknown image content format " << (int)format;
+ if (format == SurfaceFormat::B8G8R8X8) {
+ return CAIRO_CONTENT_COLOR;
+ } else if (format != SurfaceFormat::B8G8R8A8) {
+ gfxCriticalError() << "Unknown image content format " << (int)format;
+ }
return CAIRO_CONTENT_COLOR_ALPHA;
}
}

View File

@ -0,0 +1,34 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c10
https://bug1504834.bmoattachments.org/attachment.cgi?id=9111147
mozilla-bmo1504834-part4.patch
# HG changeset patch
# Parent 46ea866ca3acb8bb5e1709ceb799b9c94f591dec
Problem description: Tab-titles that are too long to fit into a tab get faded out.
On big endian this is broken and instead of fading out, the
tab gets white and the font transparent, leading to an unreadable
tab-title
Solution: This is not a real solution, but a hack. The real solution would have been
to byte-swap the correct buffer, but I could not find it.
So the next best thing is to deactivate the fading-effect. Now all tab-titles
are readable, albeit not as pretty to look at as they could be.
Side-effects: I have not yet found an unwanted side-effect.
diff -r 46ea866ca3ac -r 6ef20eee3f8f gfx/2d/DrawTargetSkia.cpp
--- gfx/2d/DrawTargetSkia.cpp Tue Oct 22 12:27:22 2019 +0200
+++ gfx/2d/DrawTargetSkia.cpp Thu Oct 31 09:11:56 2019 +0100
@@ -1861,6 +1861,14 @@
SkCanvas::kPreserveLCDText_SaveLayerFlag |
(aCopyBackground ? SkCanvas::kInitWithPrevious_SaveLayerFlag : 0));
+#if MOZ_BIG_ENDIAN
+ // Pushing a layer where an aMask is defined produces wrong output.
+ // We _should_ endian swap the data, but I couldn't find a workable way to do so
+ // Therefore I deactivate those layers in the meantime.
+ // The result is: Tab-titles that are longer than the available space should be faded out.
+ // The fading doesn't work, so we deactivate the fading-effect here.
+ if (!aMask)
+#endif
mCanvas->saveLayer(saveRec);
SetPermitSubpixelAA(aOpaque);

View File

@ -0,0 +1,80 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c5
https://bugzilla.mozilla.org/attachment.cgi?id=9028600
Rough progress patch
diff -r 53107afbc21e gfx/skia/skia/third_party/skcms/skcms.cc
--- gfx/skia/skia/third_party/skcms/skcms.cc Wed Nov 07 04:50:21 2018 +0000
+++ gfx/skia/skia/third_party/skcms/skcms.cc Thu Nov 29 12:49:35 2018 +0000
@@ -30,6 +30,8 @@
#include <avx512fintrin.h>
#include <avx512dqintrin.h>
#endif
+#else
+ #define SKCMS_PORTABLE
#endif
// sizeof(x) will return size_t, which is 32-bit on some machines and 64-bit on others.
@@ -280,20 +282,28 @@ enum {
static uint16_t read_big_u16(const uint8_t* ptr) {
uint16_t be;
memcpy(&be, ptr, sizeof(be));
-#if defined(_MSC_VER)
- return _byteswap_ushort(be);
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ return be;
#else
+ #if defined(_MSC_VER)
+ return _byteswap_ushort(be);
+ #else
return __builtin_bswap16(be);
+ #endif
#endif
}
static uint32_t read_big_u32(const uint8_t* ptr) {
uint32_t be;
memcpy(&be, ptr, sizeof(be));
-#if defined(_MSC_VER)
- return _byteswap_ulong(be);
+#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__
+ return be;
#else
+ #if defined(_MSC_VER)
+ return _byteswap_ulong(be);
+ #else
return __builtin_bswap32(be);
+ #endif
#endif
}
--- gfx/2d/DrawTargetSkia.cpp.orig 2019-09-21 15:51:04.129603000 +0200
+++ gfx/2d/DrawTargetSkia.cpp 2019-09-21 15:52:11.900316000 +0200
@@ -138,8 +138,7 @@ static IntRect CalculateSurfaceBounds(const IntSize& a
return surfaceBounds.Intersect(bounds);
}
-static const int kARGBAlphaOffset =
- SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0;
+static const int kARGBAlphaOffset = 0;
static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize,
const int32_t aStride, SurfaceFormat aFormat) {
--- gfx/2d/Types.h.orig 2019-09-21 15:52:47.044803000 +0200
+++ gfx/2d/Types.h 2019-09-21 15:53:40.113641000 +0200
@@ -87,15 +87,8 @@ enum class SurfaceFormat : int8_t {
// The following values are endian-independent synonyms. The _UINT32 suffix
// indicates that the name reflects the layout when viewed as a uint32_t
// value.
-#if MOZ_LITTLE_ENDIAN()
A8R8G8B8_UINT32 = B8G8R8A8, // 0xAARRGGBB
X8R8G8B8_UINT32 = B8G8R8X8, // 0x00RRGGBB
-#elif MOZ_BIG_ENDIAN()
- A8R8G8B8_UINT32 = A8R8G8B8, // 0xAARRGGBB
- X8R8G8B8_UINT32 = X8R8G8B8, // 0x00RRGGBB
-#else
-# error "bad endianness"
-#endif
// The following values are OS and endian-independent synonyms.
//

View File

@ -0,0 +1,76 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c7
https://bugzilla.mozilla.org/attachment.cgi?id=9080593
WIP-s390x-fixes.patch
# HG changeset patch
# Parent 548d0a2f3a22bfac32ec0c3921c6c969c8bf32a9
diff -r 548d0a2f3a22 gfx/2d/ConvolutionFilter.cpp
--- gfx/2d/ConvolutionFilter.cpp Mon Jul 22 16:57:54 2019 +0200
+++ gfx/2d/ConvolutionFilter.cpp Thu Jul 25 14:27:59 2019 +0200
@@ -35,9 +35,38 @@
return true;
}
+static void ByteSwapArray(uint8_t *u8Array, int32_t size) {
+ uint32_t *array = reinterpret_cast<uint32_t*>(u8Array);
+ for (int pxl = 0; pxl < size; ++pxl) {
+ // Use an endian swap to move the bytes, i.e. BGRA -> ARGB.
+ uint32_t rgba = array[pxl];
+ array[pxl] = NativeEndian::swapToLittleEndian(rgba);
+ }
+}
+
void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
bool aHasAlpha) {
+#ifdef MOZ_BIG_ENDIAN
+ int outputSize = mFilter->numValues();
+
+ // Input size isn't handed in, so we have to calculate it quickly
+ int inputSize = 0;
+ for (int xx = 0; xx < outputSize; ++xx) {
+ // Get the filter that determines the current output pixel.
+ int filterOffset, filterLength;
+ mFilter->FilterForValue(xx, &filterOffset, &filterLength);
+ inputSize = std::max(inputSize, filterOffset + filterLength);
+ }
+
+ ByteSwapArray((uint8_t*)aSrc, inputSize);
+#endif
+
SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
+
+#ifdef MOZ_BIG_ENDIAN
+ ByteSwapArray((uint8_t*)aSrc, inputSize);
+ ByteSwapArray(aDst, outputSize);
+#endif
}
void ConvolutionFilter::ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
@@ -49,8 +78,26 @@
int32_t filterLength;
auto filterValues =
mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
+
+#ifdef MOZ_BIG_ENDIAN
+ for (int filterY = 0; filterY < filterLength; filterY++) {
+ // Skia only knows LE, so we have to swizzle the input
+ ByteSwapArray(aSrc[filterY], aRowSize);
+ }
+#endif
+
SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
aHasAlpha);
+
+#ifdef MOZ_BIG_ENDIAN
+ // After skia is finished, we swizzle back to BE, in case
+ // the input is used again somewhere else
+ for (int filterY = 0; filterY < filterLength; filterY++) {
+ ByteSwapArray(aSrc[filterY], aRowSize);
+ }
+ // The destination array as well
+ ByteSwapArray(aDst, aRowSize);
+#endif
}
/* ConvolutionFilter::ComputeResizeFactor is derived from Skia's

View File

@ -0,0 +1,49 @@
https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c9
https://bugzilla.mozilla.org/attachment.cgi?id=9111146
mozilla-bmo1504834-part3.patch
# HG changeset patch
# Parent aecb4600e5da17443b224c79eee178c1d8e155e3
For FF68, AntiAliasing of XULTexts seem to be broken on big endian (s390x). Text and icons of the sandwich-menu to the
right of the address bar, as well as plugin-windows appears transparant, which usually means unreadable (white on white).
diff -r aecb4600e5da gfx/skia/skia/include/private/SkNx.h
--- gfx/skia/skia/include/private/SkNx.h Tue Aug 20 09:46:55 2019 +0200
+++ gfx/skia/skia/include/private/SkNx.h Mon Sep 09 10:04:06 2019 +0200
@@ -238,7 +238,18 @@
AI SkNx operator*(const SkNx& y) const { return fVal * y.fVal; }
AI SkNx operator/(const SkNx& y) const { return fVal / y.fVal; }
+ // On Big endian the commented out variant doesn't work,
+ // and honestly, I have no idea why it exists in the first place.
+ // The reason its broken is, I think, that it defaults to the double-variant of ToBits()
+ // which gets a 64-bit integer, and FromBits returns 32-bit,
+ // cutting off the wrong half again.
+ // Overall, I see no reason to have ToBits and FromBits at all (even for floats/doubles).
+ // Still we are only "fixing" this for big endian and leave little endian alone (never touch a running system)
+#ifdef SK_CPU_BENDIAN
+ AI SkNx operator&(const SkNx& y) const { return fVal & y.fVal; }
+#else
AI SkNx operator&(const SkNx& y) const { return FromBits(ToBits(fVal) & ToBits(y.fVal)); }
+#endif
AI SkNx operator|(const SkNx& y) const { return FromBits(ToBits(fVal) | ToBits(y.fVal)); }
AI SkNx operator^(const SkNx& y) const { return FromBits(ToBits(fVal) ^ ToBits(y.fVal)); }
diff -r aecb4600e5da gfx/skia/skia/src/opts/SkBlitMask_opts.h
--- gfx/skia/skia/src/opts/SkBlitMask_opts.h Tue Aug 20 09:46:55 2019 +0200
+++ gfx/skia/skia/src/opts/SkBlitMask_opts.h Mon Sep 09 10:04:06 2019 +0200
@@ -203,7 +203,13 @@
// ~~~>
// a = 1*aa + d(1-1*aa) = aa + d(1-aa)
// c = 0*aa + d(1-1*aa) = d(1-aa)
+
+ // For big endian we have to swap the alpha-mask from 0,0,0,255 to 255,0,0,0
+#ifdef SK_CPU_BENDIAN
+ return Sk4px(Sk16b(aa) & Sk16b(255,0,0,0, 255,0,0,0, 255,0,0,0, 255,0,0,0))
+#else
return Sk4px(Sk16b(aa) & Sk16b(0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255))
+#endif
+ d.approxMulDiv255(aa.inv());
};
while (h --> 0) {