mozilla-bmo1504834-part2.patch
branchfirefox69
changeset 1109 972f68ac6b1a
parent 1101 a4709640638e
child 1119 4c5d44d40a03
equal deleted inserted replaced
1108:33b03cfb3747 1109:972f68ac6b1a
     1 # HG changeset patch
     1 # HG changeset patch
     2 # Parent  548d0a2f3a22bfac32ec0c3921c6c969c8bf32a9
     2 # Parent  6fa4b62427433e8f445d05c557e5db096667d880
     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 -r 548d0a2f3a22 gfx/2d/ConvolutionFilter.cpp
     8 diff --git a/gfx/2d/ConvolutionFilter.cpp b/gfx/2d/ConvolutionFilter.cpp
     9 --- a/gfx/2d/ConvolutionFilter.cpp	Mon Jul 22 16:57:54 2019 +0200
     9 --- a/gfx/2d/ConvolutionFilter.cpp
    10 +++ b/gfx/2d/ConvolutionFilter.cpp	Thu Jul 25 14:27:59 2019 +0200
    10 +++ b/gfx/2d/ConvolutionFilter.cpp
    11 @@ -35,9 +35,38 @@
    11 @@ -30,32 +30,79 @@ bool ConvolutionFilter::GetFilterOffsetA
       
    12                                                   int32_t* aResultLength) {
       
    13    if (aRowIndex >= mFilter->numValues()) {
       
    14      return false;
       
    15    }
       
    16    mFilter->FilterForValue(aRowIndex, aResultOffset, aResultLength);
    12    return true;
    17    return true;
    13  }
    18  }
    14  
    19  
    15 +static void ByteSwapArray(uint8_t *u8Array, int32_t size) {
    20 +static void ByteSwapArray(uint8_t *u8Array, int32_t size) {
    16 +    uint32_t *array = reinterpret_cast<uint32_t*>(u8Array);
    21 +    uint32_t *array = reinterpret_cast<uint32_t*>(u8Array);
    21 +    }
    26 +    }
    22 +}
    27 +}
    23 +
    28 +
    24  void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
    29  void ConvolutionFilter::ConvolveHorizontally(const uint8_t* aSrc, uint8_t* aDst,
    25                                               bool aHasAlpha) {
    30                                               bool aHasAlpha) {
    26 +#ifdef MOZ_BIG_ENDIAN
    31 +#if MOZ_BIG_ENDIAN
    27 +    int outputSize = mFilter->numValues();
    32 +    int outputSize = mFilter->numValues();
    28 +
    33 +
    29 +    // 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
    30 +    int inputSize = 0;
    35 +    int inputSize = 0;
    31 +    for (int xx = 0; xx < outputSize; ++xx) {
    36 +    for (int xx = 0; xx < outputSize; ++xx) {
    38 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    43 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    39 +#endif
    44 +#endif
    40 +
    45 +
    41    SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
    46    SkOpts::convolve_horizontally(aSrc, *mFilter, aDst, aHasAlpha);
    42 +
    47 +
    43 +#ifdef MOZ_BIG_ENDIAN
    48 +#if MOZ_BIG_ENDIAN
    44 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    49 +    ByteSwapArray((uint8_t*)aSrc, inputSize);
    45 +    ByteSwapArray(aDst, outputSize);
    50 +    ByteSwapArray(aDst, outputSize);
    46 +#endif
    51 +#endif
    47  }
    52  }
    48  
    53  
    49  void ConvolutionFilter::ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
    54  void ConvolutionFilter::ConvolveVertically(uint8_t* const* aSrc, uint8_t* aDst,
    50 @@ -49,8 +78,26 @@
    55                                             int32_t aRowIndex, int32_t aRowSize,
       
    56                                             bool aHasAlpha) {
       
    57    MOZ_ASSERT(aRowIndex < mFilter->numValues());
       
    58  
       
    59    int32_t filterOffset;
    51    int32_t filterLength;
    60    int32_t filterLength;
    52    auto filterValues =
    61    auto filterValues =
    53        mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
    62        mFilter->FilterForValue(aRowIndex, &filterOffset, &filterLength);
    54 +
    63 +
    55 +#ifdef MOZ_BIG_ENDIAN
    64 +#if MOZ_BIG_ENDIAN
    56 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    65 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    57 +      // Skia only knows LE, so we have to swizzle the input
    66 +      // Skia only knows LE, so we have to swizzle the input
    58 +    ByteSwapArray(aSrc[filterY], aRowSize);
    67 +    ByteSwapArray(aSrc[filterY], aRowSize);
    59 +  }
    68 +  }
    60 +#endif
    69 +#endif
    61 +
    70 +
    62    SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
    71    SkOpts::convolve_vertically(filterValues, filterLength, aSrc, aRowSize, aDst,
    63                                aHasAlpha);
    72                                aHasAlpha);
    64 +
    73 +
    65 +#ifdef MOZ_BIG_ENDIAN
    74 +#if MOZ_BIG_ENDIAN
    66 +  // After skia is finished, we swizzle back to BE, in case
    75 +  // After skia is finished, we swizzle back to BE, in case
    67 +  // the input is used again somewhere else
    76 +  // the input is used again somewhere else
    68 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    77 +  for (int filterY = 0; filterY < filterLength; filterY++) {
    69 +    ByteSwapArray(aSrc[filterY], aRowSize);
    78 +    ByteSwapArray(aSrc[filterY], aRowSize);
    70 +  }
    79 +  }
    72 +  ByteSwapArray(aDst, aRowSize);
    81 +  ByteSwapArray(aDst, aRowSize);
    73 +#endif
    82 +#endif
    74  }
    83  }
    75  
    84  
    76  /* ConvolutionFilter::ComputeResizeFactor is derived from Skia's
    85  /* ConvolutionFilter::ComputeResizeFactor is derived from Skia's
    77 diff -r 548d0a2f3a22 gfx/skia/skia/include/core/SkPreConfig.h
    86   * SkBitmapScaler/SkResizeFilter::computeFactors. It is governed by Skia's
    78 --- a/gfx/skia/skia/include/core/SkPreConfig.h	Mon Jul 22 16:57:54 2019 +0200
    87   * BSD-style license (see gfx/skia/LICENSE) and the following copyright:
    79 +++ b/gfx/skia/skia/include/core/SkPreConfig.h	Thu Jul 25 14:27:59 2019 +0200
    88   * Copyright (c) 2015 Google Inc.
    80 @@ -73,7 +73,7 @@
    89   */
       
    90  bool ConvolutionFilter::ComputeResizeFilter(ResizeMethod aResizeMethod,
       
    91 diff --git a/gfx/skia/skia/include/core/SkPreConfig.h b/gfx/skia/skia/include/core/SkPreConfig.h
       
    92 --- a/gfx/skia/skia/include/core/SkPreConfig.h
       
    93 +++ b/gfx/skia/skia/include/core/SkPreConfig.h
       
    94 @@ -68,17 +68,17 @@
       
    95          #define SK_CPU_BENDIAN
       
    96      #elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
       
    97          #define SK_CPU_LENDIAN
       
    98      #elif defined(__sparc) || defined(__sparc__) || \
       
    99        defined(_POWER) || defined(__powerpc__) || \
    81        defined(__ppc__) || defined(__hppa) || \
   100        defined(__ppc__) || defined(__hppa) || \
    82        defined(__PPC__) || defined(__PPC64__) || \
   101        defined(__PPC__) || defined(__PPC64__) || \
    83        defined(_MIPSEB) || defined(__ARMEB__) || \
   102        defined(_MIPSEB) || defined(__ARMEB__) || \
    84 -      defined(__s390__) || \
   103 -      defined(__s390__) || \
    85 +      defined(__s390__) || defined(__s390x__) || \
   104 +      defined(__s390__) || defined(__s390x__) || \
    86        (defined(__sh__) && defined(__BIG_ENDIAN__)) || \
   105        (defined(__sh__) && defined(__BIG_ENDIAN__)) || \
    87        (defined(__ia64) && defined(__BIG_ENDIAN__))
   106        (defined(__ia64) && defined(__BIG_ENDIAN__))
    88           #define SK_CPU_BENDIAN
   107           #define SK_CPU_BENDIAN
       
   108      #else
       
   109          #define SK_CPU_LENDIAN
       
   110      #endif
       
   111  #endif
       
   112