mozilla-bmo1504834-part2.patch
changeset 1129 146af4f081b9
parent 1123 7fa561e5d7c7
equal deleted inserted replaced
1116:52b1745787cf 1129:146af4f081b9
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent  6fa4b62427433e8f445d05c557e5db096667d880
     2 # Parent  9319844dca3133fa8bd7107079f1d1ddc5c0bf70
     3 Skia does not support big endian. The places to fix are too numerous and upstream (skia, not Mozilla)
     3 Skia does not support big endian. The places to fix are too numerous and upstream (skia, not Mozilla)
     4 has no interest in maintaining big endian.
     4 has no interest in maintaining big endian.
     5 So here we try to swizzle the input for skia, so that skia always works on LE, and when it comes
     5 So here we try to swizzle the input for skia, so that skia always works on LE, and when it comes
     6 out again, we transform back to BE.
     6 out again, we transform back to BE.
     7 
     7 
     8 diff --git a/gfx/2d/ConvolutionFilter.cpp b/gfx/2d/ConvolutionFilter.cpp
     8 diff --git a/gfx/2d/ConvolutionFilter.cpp b/gfx/2d/ConvolutionFilter.cpp
     9 --- a/gfx/2d/ConvolutionFilter.cpp
     9 --- a/gfx/2d/ConvolutionFilter.cpp
    10 +++ b/gfx/2d/ConvolutionFilter.cpp
    10 +++ b/gfx/2d/ConvolutionFilter.cpp
    11 @@ -30,32 +30,79 @@ bool ConvolutionFilter::GetFilterOffsetA
    11 @@ -29,32 +29,79 @@ bool ConvolutionFilter::GetFilterOffsetA
    12                                                   int32_t* aResultLength) {
    12                                                   int32_t* aResultLength) {
    13    if (aRowIndex >= mFilter->numValues()) {
    13    if (aRowIndex >= mFilter->numValues()) {
    14      return false;
    14      return false;
    15    }
    15    }
    16    mFilter->FilterForValue(aRowIndex, aResultOffset, aResultLength);
    16    mFilter->FilterForValue(aRowIndex, aResultOffset, aResultLength);
    26 +    }
    26 +    }
    27 +}
    27 +}
    28 +
    28 +
    29  void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
    29  void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
    30                                               bool aHasAlpha) {
    30                                               bool aHasAlpha) {
    31 +#if MOZ_BIG_ENDIAN
    31 +#if MOZ_BIG_ENDIAN()
    32 +    int outputSize = mFilter->numValues();
    32 +    int outputSize = mFilter->numValues();
    33 +
    33 +
    34 +    // Input size isn't handed in, so we have to calculate it quickly
    34 +    // Input size isn't handed in, so we have to calculate it quickly
    35 +    int inputSize = 0;
    35 +    int inputSize = 0;
    36 +    for (int xx = 0; xx < outputSize; ++xx) {
    36 +    for (int xx = 0; xx < outputSize; ++xx) {
    43 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    43 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    44 +#endif
    44 +#endif
    45 +
    45 +
    46    SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
    46    SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
    47 +
    47 +
    48 +#if MOZ_BIG_ENDIAN
    48 +#if MOZ_BIG_ENDIAN()
    49 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    49 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    50 +    ByteSwapArray(aDst, outputSize);
    50 +    ByteSwapArray(aDst, outputSize);
    51 +#endif
    51 +#endif
    52  }
    52  }
    53  
    53  
    59    int32_t filterOffset;
    59    int32_t filterOffset;
    60    int32_t filterLength;
    60    int32_t filterLength;
    61    auto filterValues =
    61    auto filterValues =
    62        mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
    62        mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
    63 +
    63 +
    64 +#if MOZ_BIG_ENDIAN
    64 +#if MOZ_BIG_ENDIAN()
    65 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    65 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    66 +      // Skia only knows LE, so we have to swizzle the input
    66 +      // Skia only knows LE, so we have to swizzle the input
    67 +    ByteSwapArray(aSrc[filterY], aRowSize);
    67 +    ByteSwapArray(aSrc[filterY], aRowSize);
    68 +  }
    68 +  }
    69 +#endif
    69 +#endif
    70 +
    70 +
    71    SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
    71    SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
    72                                aHasAlpha);
    72                                aHasAlpha);
    73 +
    73 +
    74 +#if MOZ_BIG_ENDIAN
    74 +#if MOZ_BIG_ENDIAN()
    75 +  // After skia is finished, we swizzle back to BE, in case
    75 +  // After skia is finished, we swizzle back to BE, in case
    76 +  // the input is used again somewhere else
    76 +  // the input is used again somewhere else
    77 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    77 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    78 +    ByteSwapArray(aSrc[filterY], aRowSize);
    78 +    ByteSwapArray(aSrc[filterY], aRowSize);
    79 +  }
    79 +  }