Dash:
[t2.git] / package / www / firefox / Skia-ConvolutionFilter.patch
blobb9a03a2059d0ac938c513f5b803b8541b655c910
1 https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c7
3 Fixes blue tint on some pictures.
5 It's not final fix as there is still blue-tint on first page where is
6 the history. It could also be yet another almost-transparent overlay.
7 These cause the most problems (and one does see them, as they are
8 transparent ;).
10 And on some pages there is still yellow tint...
12 --- a/gfx/2d/ConvolutionFilter.cpp
13 +++ b/gfx/2d/ConvolutionFilter.cpp
14 @@ -35,9 +35,38 @@
15 return true;
18 +static void ByteSwapArray(uint8_t *u8Array, int32_t size) {
19 + uint32_t *array = reinterpret_cast<uint32_t*>(u8Array);
20 + for (int pxl = 0; pxl < size; ++pxl) {
21 + // Use an endian swap to move the bytes, i.e. BGRA -> ARGB.
22 + uint32_t rgba = array[pxl];
23 + array[pxl] = NativeEndian::swapToLittleEndian(rgba);
24 + }
27 void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
28 bool aHasAlpha) {
29 +#ifdef MOZ_BIG_ENDIAN
30 + int outputSize = mFilter->numValues();
32 + // Input size isn't handed in, so we have to calculate it quickly
33 + int inputSize = 0;
34 + for (int xx = 0; xx < outputSize; ++xx) {
35 + // Get the filter that determines the current output pixel.
36 + int filterOffset, filterLength;
37 + mFilter->FilterForValue(xx, &filterOffset, &filterLength);
38 + inputSize = std::max(inputSize, filterOffset + filterLength);
39 + }
41 + ByteSwapArray((uint8_t*)aSrc, inputSize);
42 +#endif
44 SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
46 +#ifdef MOZ_BIG_ENDIAN
47 + ByteSwapArray((uint8_t*)aSrc, inputSize);
48 + ByteSwapArray(aDst, outputSize);
49 +#endif
52 void ConvolutionFilter::ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
53 @@ -49,8 +78,26 @@
54 int32_t filterLength;
55 auto filterValues =
56 mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
58 +#ifdef MOZ_BIG_ENDIAN
59 + for (int filterY = 0; filterY < filterLength; filterY++) {
60 + // Skia only knows LE, so we have to swizzle the input
61 + ByteSwapArray(aSrc[filterY], aRowSize);
62 + }
63 +#endif
65 SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
66 aHasAlpha);
68 +#ifdef MOZ_BIG_ENDIAN
69 + // After skia is finished, we swizzle back to BE, in case
70 + // the input is used again somewhere else
71 + for (int filterY = 0; filterY < filterLength; filterY++) {
72 + ByteSwapArray(aSrc[filterY], aRowSize);
73 + }
74 + // The destination array as well
75 + ByteSwapArray(aDst, aRowSize);
76 +#endif
79 /* ConvolutionFilter::ComputeResizeFactor is derived from Skia's