Dash:
[t2-trunk.git] / package / www / firefox / Skia-rendering.patch
blob2647d03c33ec44a6b8fe2202d8a6b979de120b98
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/firefox/Skia-rendering.patch
3 # Copyright (C) 2021 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 https://bugzilla.mozilla.org/show_bug.cgi?id=1626236
16 Plus SVG gradient-issues.
18 Fixes by Martin Sirringhaus.
20 --- a/gfx/2d/DrawTargetSkia.cpp
21 +++ b/gfx/2d/DrawTargetSkia.cpp
22 @@ -68,15 +68,28 @@
23 mColors.resize(mCount);
24 mPositions.resize(mCount);
25 if (aStops[0].offset != 0) {
26 +// reddit.com yellow graddient
27 +#if MOZ_BIG_ENDIAN()
28 + mColors[0] = mozilla::detail::Swapper<SkColor>::swap(ColorToSkColor(aStops[0].color, 1.0));
29 +#else
30 mColors[0] = ColorToSkColor(aStops[0].color, 1.0);
31 +#endif
32 mPositions[0] = 0;
34 for (uint32_t i = 0; i < aNumStops; i++) {
35 +#if MOZ_BIG_ENDIAN()
36 + mColors[i + shift] = mozilla::detail::Swapper<SkColor>::swap(ColorToSkColor(aStops[i].color, 1.0));
37 +#else
38 mColors[i + shift] = ColorToSkColor(aStops[i].color, 1.0);
39 +#endif
40 mPositions[i + shift] = SkFloatToScalar(aStops[i].offset);
42 if (aStops[aNumStops - 1].offset != 1) {
43 +#if MOZ_BIG_ENDIAN()
44 + mColors[mCount - 1] = mozilla::detail::Swapper<SkColor>::swap(ColorToSkColor(aStops[aNumStops - 1].color, 1.0));
45 +#else
46 mColors[mCount - 1] = ColorToSkColor(aStops[aNumStops - 1].color, 1.0);
47 +#endif
48 mPositions[mCount - 1] = SK_Scalar1;
51 @@ -155,7 +168,7 @@
52 for (int row = 0; row < height; ++row) {
53 for (int column = 0; column < width; column += 4) {
54 if (aData[column + kARGBAlphaOffset] != 0xFF) {
55 - gfxCriticalError() << "RGBX pixel at (" << column << "," << row
56 + gfxWarning() << "RGBX pixel at (" << column << "," << row
57 << ") in " << width << "x" << height
58 << " surface is not opaque: " << int(aData[column])
59 << "," << int(aData[column + 1]) << ","
60 @@ -205,7 +218,7 @@
61 if (aData[offset + kARGBAlphaOffset] != 0xFF) {
62 int row = offset / aStride;
63 int column = (offset % aStride) / pixelSize;
64 - gfxCriticalError() << "RGBX corner pixel at (" << column << "," << row
65 + gfxWarning() << "RGBX corner pixel at (" << column << "," << row
66 << ") in " << aSize.width << "x" << aSize.height
67 << " surface, bounded by "
68 << "(" << bounds.X() << "," << bounds.Y() << ","
69 diff -r 49ddb3c45fbc -r 13bdca7081de gfx/2d/FilterProcessing.h
70 --- a/gfx/2d/FilterProcessing.h Wed Jun 17 11:32:00 2020 +0200
71 +++ b/gfx/2d/FilterProcessing.h Fri Jun 19 15:20:16 2020 +0200
72 @@ -13,10 +13,17 @@
73 namespace mozilla {
74 namespace gfx {
76 +#if defined WORDS_BIGENDIAN || defined IS_BIG_ENDIAN || defined __BIG_ENDIAN__
77 +const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_B = 3;
78 +const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_G = 2;
79 +const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_R = 1;
80 +const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_A = 0;
81 +#else
82 const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_B = 0;
83 const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_G = 1;
84 const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_R = 2;
85 const ptrdiff_t B8G8R8A8_COMPONENT_BYTEOFFSET_A = 3;
86 +#endif
88 class FilterProcessing {
89 public:
90 diff -r 49ddb3c45fbc -r 13bdca7081de gfx/skia/skia/src/shaders/gradients/Sk4fLinearGradient.cpp
91 --- a/gfx/skia/skia/src/shaders/gradients/Sk4fLinearGradient.cpp Wed Jun 17 11:32:00 2020 +0200
92 +++ b/gfx/skia/skia/src/shaders/gradients/Sk4fLinearGradient.cpp Fri Jun 19 15:20:16 2020 +0200
93 @@ -7,7 +7,7 @@
95 #include "include/core/SkPaint.h"
96 #include "src/shaders/gradients/Sk4fLinearGradient.h"
98 +#include "src/core/SkEndian.h"
99 #include <cmath>
100 #include <utility>
102 @@ -28,6 +28,9 @@
104 while (n >= 4) {
105 DstTraits<premul>::store4x(c0, c1, c2, c3, dst, bias0, bias1);
106 +#ifdef SK_CPU_BENDIAN
107 + SkEndianSwap32s(dst, 4);
108 +#endif
109 dst += 4;
111 c0 = c0 + dc4;
112 @@ -37,12 +40,23 @@
113 n -= 4;
115 if (n & 2) {
116 - DstTraits<premul>::store(c0, dst++, bias0);
117 - DstTraits<premul>::store(c1, dst++, bias1);
118 + DstTraits<premul>::store(c0, dst, bias0);
119 +#ifdef SK_CPU_BENDIAN
120 + *dst = SkEndianSwap32(*dst);
121 +#endif
122 + ++dst;
123 + DstTraits<premul>::store(c1, dst, bias1);
124 +#ifdef SK_CPU_BENDIAN
125 + *dst = SkEndianSwap32(*dst);
126 +#endif
127 + ++dst;
128 c0 = c0 + dc2;
130 if (n & 1) {
131 DstTraits<premul>::store(c0, dst, bias0);
132 +#ifdef SK_CPU_BENDIAN
133 + *dst = SkEndianSwap32(*dst);
134 +#endif
138 diff -r 49ddb3c45fbc -r 13bdca7081de image/decoders/nsJPEGDecoder.cpp
139 --- a/image/decoders/nsJPEGDecoder.cpp Wed Jun 17 11:32:00 2020 +0200
140 +++ b/image/decoders/nsJPEGDecoder.cpp Fri Jun 19 15:20:16 2020 +0200
141 @@ -256,6 +256,9 @@
142 case JCS_YCbCr:
143 // By default, we will output directly to BGRA. If we need to apply
144 // special color transforms, this may change.
145 +#if MOZ_BIG_ENDIAN()
146 + mInfo.out_color_space = MOZ_JCS_EXT_NATIVE_ENDIAN_XRGB;
147 +#else
148 switch (SurfaceFormat::OS_RGBX) {
149 case SurfaceFormat::B8G8R8X8:
150 mInfo.out_color_space = JCS_EXT_BGRX;
151 @@ -270,6 +273,7 @@
152 mState = JPEG_ERROR;
153 return Transition::TerminateFailure();
155 +#endif
156 break;
157 case JCS_CMYK:
158 case JCS_YCCK:
159 diff -r 49ddb3c45fbc -r 13bdca7081de image/decoders/nsWebPDecoder.cpp
160 --- a/image/decoders/nsWebPDecoder.cpp Wed Jun 17 11:32:00 2020 +0200
161 +++ b/image/decoders/nsWebPDecoder.cpp Fri Jun 19 15:20:16 2020 +0200
162 @@ -245,7 +245,12 @@
163 // WebP doesn't guarantee that the alpha generated matches the hint in the
164 // header, so we always need to claim the input is BGRA. If the output is
165 // BGRX, swizzling will mask off the alpha channel.
166 +#if MOZ_BIG_ENDIAN()
167 + mBuffer.colorspace = MODE_ARGB;
168 + SurfaceFormat inFormat = mFormat;
169 +#else
170 SurfaceFormat inFormat = SurfaceFormat::OS_RGBA;
171 +#endif
173 SurfacePipeFlags pipeFlags = SurfacePipeFlags();
174 if (mFormat == SurfaceFormat::OS_RGBA &&