225ef2
# HG changeset patch
96931b
# Parent  d1d66f7e4d0e7fd45e91e4fcee07555e72046d48
225ef2
For FF68, AntiAliasing of XULTexts seem to be broken on big endian (s390x). Text and icons of the sandwich-menu to the
225ef2
right of the address bar, as well as plugin-windows appears transparant, which usually means unreadable (white on white).
225ef2
96931b
diff --git a/gfx/skia/skia/include/private/SkNx.h b/gfx/skia/skia/include/private/SkNx.h
96931b
--- a/gfx/skia/skia/include/private/SkNx.h
96931b
+++ b/gfx/skia/skia/include/private/SkNx.h
96931b
@@ -233,17 +233,28 @@ struct SkNx<1,T> {
96931b
     AI SkNx operator<<(int bits) const { return fVal << bits; }
96931b
     AI SkNx operator>>(int bits) const { return fVal >> bits; }
96931b
 
96931b
     AI SkNx operator+(const SkNx& y) const { return fVal + y.fVal; }
96931b
     AI SkNx operator-(const SkNx& y) const { return fVal - y.fVal; }
225ef2
     AI SkNx operator*(const SkNx& y) const { return fVal * y.fVal; }
225ef2
     AI SkNx operator/(const SkNx& y) const { return fVal / y.fVal; }
225ef2
 
225ef2
+    // On Big endian the commented out variant doesn't work,
225ef2
+    // and honestly, I have no idea why it exists in the first place.
225ef2
+    // The reason its broken is, I think, that it defaults to the double-variant of ToBits()
225ef2
+    // which gets a 64-bit integer, and FromBits returns 32-bit,
225ef2
+    // cutting off the wrong half again.
225ef2
+    // Overall, I see no reason to have ToBits and FromBits at all (even for floats/doubles).
225ef2
+    // Still we are only "fixing" this for big endian and leave little endian alone (never touch a running system)
225ef2
+#ifdef SK_CPU_BENDIAN
225ef2
+    AI SkNx operator&(const SkNx& y) const { return fVal & y.fVal; }
225ef2
+#else
225ef2
     AI SkNx operator&(const SkNx& y) const { return FromBits(ToBits(fVal) & ToBits(y.fVal)); }
225ef2
+#endif
225ef2
     AI SkNx operator|(const SkNx& y) const { return FromBits(ToBits(fVal) | ToBits(y.fVal)); }
225ef2
     AI SkNx operator^(const SkNx& y) const { return FromBits(ToBits(fVal) ^ ToBits(y.fVal)); }
225ef2
 
96931b
     AI SkNx operator==(const SkNx& y) const { return FromBits(fVal == y.fVal ? ~0 : 0); }
96931b
     AI SkNx operator!=(const SkNx& y) const { return FromBits(fVal != y.fVal ? ~0 : 0); }
96931b
     AI SkNx operator<=(const SkNx& y) const { return FromBits(fVal <= y.fVal ? ~0 : 0); }
96931b
     AI SkNx operator>=(const SkNx& y) const { return FromBits(fVal >= y.fVal ? ~0 : 0); }
96931b
     AI SkNx operator< (const SkNx& y) const { return FromBits(fVal <  y.fVal ? ~0 : 0); }
96931b
diff --git a/gfx/skia/skia/src/opts/SkBlitMask_opts.h b/gfx/skia/skia/src/opts/SkBlitMask_opts.h
96931b
--- a/gfx/skia/skia/src/opts/SkBlitMask_opts.h
96931b
+++ b/gfx/skia/skia/src/opts/SkBlitMask_opts.h
96931b
@@ -198,17 +198,23 @@ namespace SK_OPTS_NS {
96931b
                                        const SkAlpha* mask, size_t maskRB,
96931b
                                        int w, int h) {
96931b
         auto fn = [](const Sk4px& d, const Sk4px& aa) {
96931b
             //   = (s + d(1-sa))aa + d(1-aa)
96931b
             //   = s*aa + d(1-sa*aa)
225ef2
             //   ~~~>
225ef2
             // a = 1*aa + d(1-1*aa) = aa + d(1-aa)
225ef2
             // c = 0*aa + d(1-1*aa) =      d(1-aa)
225ef2
+
225ef2
+            // For big endian we have to swap the alpha-mask from 0,0,0,255 to 255,0,0,0
225ef2
+#ifdef SK_CPU_BENDIAN
225ef2
+            return Sk4px(Sk16b(aa) & Sk16b(255,0,0,0, 255,0,0,0, 255,0,0,0, 255,0,0,0))
225ef2
+#else
225ef2
             return Sk4px(Sk16b(aa) & Sk16b(0,0,0,255, 0,0,0,255, 0,0,0,255, 0,0,0,255))
225ef2
+#endif
225ef2
                  + d.approxMulDiv255(aa.inv());
225ef2
         };
225ef2
         while (h --> 0) {
96931b
             Sk4px::MapDstAlpha(w, dst, mask, fn);
96931b
             dst  +=  dstRB / sizeof(*dst);
96931b
             mask += maskRB / sizeof(*mask);
96931b
         }
96931b
     }