https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c9 https://bugs.chromium.org/p/skia/issues/detail?id=9781 --- a/gfx/skia/skia/include/private/SkNx.h +++ b/gfx/skia/skia/include/private/SkNx.h @@ -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)); } --- a/gfx/skia/skia/src/opts/SkBlitMask_opts.h +++ b/gfx/skia/skia/src/opts/SkBlitMask_opts.h @@ -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) {