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
10 And on some pages there is still yellow tint...
12 --- a/gfx/2d/ConvolutionFilter.cpp
13 +++ b/gfx/2d/ConvolutionFilter.cpp
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);
27 void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
29 +#ifdef MOZ_BIG_ENDIAN
30 + int outputSize = mFilter->numValues();
32 + // Input size isn't handed in, so we have to calculate it quickly
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);
41 + ByteSwapArray((uint8_t*)aSrc, inputSize);
44 SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
46 +#ifdef MOZ_BIG_ENDIAN
47 + ByteSwapArray((uint8_t*)aSrc, inputSize);
48 + ByteSwapArray(aDst, outputSize);
52 void ConvolutionFilter::ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
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);
65 SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
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);
74 + // The destination array as well
75 + ByteSwapArray(aDst, aRowSize);
79 /* ConvolutionFilter::ComputeResizeFactor is derived from Skia's