Blame qtwebengine-opensource-src-5.9.0-skia-neon.patch

Kevin Kofler e4e544
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/skia/BUILD.gn qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/skia/BUILD.gn
Kevin Kofler e4e544
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/skia/BUILD.gn	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler a9a9bd
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/skia/BUILD.gn	2017-06-12 12:59:26.707922417 +0200
Kevin Kofler e4e544
@@ -486,6 +486,24 @@
Kevin Kofler e4e544
 
Kevin Kofler e4e544
 # Separated out so it can be compiled with different flags for SSE.
Kevin Kofler e4e544
 if (!skia_build_no_opts) {
Kevin Kofler e4e544
+  if (current_cpu == "arm" && (arm_use_neon || arm_optionally_use_neon)) {
Kevin Kofler e4e544
+    source_set("skia_opts_neon") {
Kevin Kofler e4e544
+      sources = skia_opts.neon_sources
Kevin Kofler e4e544
+      # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
Kevin Kofler e4e544
+      # when running this.
Kevin Kofler e4e544
+      if (!arm_use_neon) {
Kevin Kofler e4e544
+        configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
Kevin Kofler a9a9bd
+        cflags = [ "-mfpu=neon" ]
Kevin Kofler e4e544
+      }
Kevin Kofler e4e544
+      visibility = [ ":skia_opts" ]
Kevin Kofler e4e544
+      configs -= [ "//build/config/compiler:chromium_code" ]
Kevin Kofler e4e544
+      configs += [
Kevin Kofler e4e544
+        ":skia_config",
Kevin Kofler e4e544
+        ":skia_library_config",
Kevin Kofler e4e544
+        "//build/config/compiler:no_chromium_code",
Kevin Kofler e4e544
+      ]
Kevin Kofler e4e544
+    }
Kevin Kofler e4e544
+  }
Kevin Kofler e4e544
   if (current_cpu == "arm64") {
Kevin Kofler e4e544
     source_set("skia_opts_crc32") {
Kevin Kofler e4e544
       sources = skia_opts.crc32_sources
Kevin Kofler e4e544
@@ -624,14 +642,7 @@
Kevin Kofler e4e544
     if (arm_version >= 7) {
Kevin Kofler e4e544
       sources = skia_opts.armv7_sources
Kevin Kofler e4e544
       if (arm_use_neon || arm_optionally_use_neon) {
Kevin Kofler e4e544
-        sources += skia_opts.neon_sources
Kevin Kofler e4e544
-
Kevin Kofler e4e544
-        # Root build config sets -mfpu=$arm_fpu, which we expect to be neon
Kevin Kofler e4e544
-        # when running this.
Kevin Kofler e4e544
-        if (!arm_use_neon) {
Kevin Kofler e4e544
-          configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
Kevin Kofler e4e544
-          cflags += [ "-mfpu=neon" ]
Kevin Kofler e4e544
-        }
Kevin Kofler e4e544
+        deps += [ ":skia_opts_neon" ]
Kevin Kofler e4e544
       }
Kevin Kofler e4e544
     } else {
Kevin Kofler e4e544
       sources = skia_opts.none_sources
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/gn/opts.gni qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/gn/opts.gni
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/gn/opts.gni	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/gn/opts.gni	2017-06-12 12:20:30.277109309 +0200
Kevin Kofler c87d48
@@ -23,6 +23,7 @@
Kevin Kofler c87d48
   "$_src/opts/SkBitmapProcState_matrixProcs_neon.cpp",
Kevin Kofler c87d48
   "$_src/opts/SkBlitMask_opts_arm_neon.cpp",
Kevin Kofler c87d48
   "$_src/opts/SkBlitRow_opts_arm_neon.cpp",
Kevin Kofler c87d48
+  "$_src/opts/SkOpts_neon.cpp",
Kevin Kofler c87d48
 ]
Kevin Kofler c87d48
 
Kevin Kofler c87d48
 arm64 = [
Kevin Kofler c87d48
@@ -33,6 +34,7 @@
Kevin Kofler c87d48
   "$_src/opts/SkBlitMask_opts_arm_neon.cpp",
Kevin Kofler c87d48
   "$_src/opts/SkBlitRow_opts_arm.cpp",
Kevin Kofler c87d48
   "$_src/opts/SkBlitRow_opts_arm_neon.cpp",
Kevin Kofler c87d48
+  "$_src/opts/SkOpts_neon.cpp",
Kevin Kofler c87d48
 ]
Kevin Kofler c87d48
 
Kevin Kofler c87d48
 crc32 = [ "$_src/opts/SkOpts_crc32.cpp" ]
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState.cpp qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState.cpp
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState.cpp	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState.cpp	2017-06-12 12:20:30.382107811 +0200
Kevin Kofler c87d48
@@ -19,7 +19,7 @@
Kevin Kofler c87d48
 #include "SkImageEncoder.h"
Kevin Kofler c87d48
 #include "SkResourceCache.h"
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
+#if !SK_ARM_NEON_IS_NONE
Kevin Kofler c87d48
 // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp
Kevin Kofler c87d48
 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[];
Kevin Kofler c87d48
 extern void  S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, int, uint16_t*);
Kevin Kofler c87d48
@@ -280,7 +280,7 @@
Kevin Kofler c87d48
                 return false;
Kevin Kofler c87d48
         }
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#if !defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
+#if !SK_ARM_NEON_IS_ALWAYS
Kevin Kofler c87d48
         static const SampleProc32 gSkBitmapProcStateSample32[] = {
Kevin Kofler c87d48
             S32_opaque_D32_nofilter_DXDY,
Kevin Kofler c87d48
             S32_alpha_D32_nofilter_DXDY,
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState_matrixProcs.cpp qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState_matrixProcs.cpp
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState_matrixProcs.cpp	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkBitmapProcState_matrixProcs.cpp	2017-06-12 12:20:30.448106869 +0200
Kevin Kofler c87d48
@@ -47,16 +47,16 @@
Kevin Kofler c87d48
 ///////////////////////////////////////////////////////////////////////////////
Kevin Kofler c87d48
 
Kevin Kofler c87d48
 // Compile neon code paths if needed
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
+#if !SK_ARM_NEON_IS_NONE
Kevin Kofler c87d48
 
Kevin Kofler c87d48
 // These are defined in src/opts/SkBitmapProcState_matrixProcs_neon.cpp
Kevin Kofler c87d48
 extern const SkBitmapProcState::MatrixProc ClampX_ClampY_Procs_neon[];
Kevin Kofler c87d48
 extern const SkBitmapProcState::MatrixProc RepeatX_RepeatY_Procs_neon[];
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#endif // defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
+#endif // !SK_ARM_NEON_IS_NONE
Kevin Kofler c87d48
 
Kevin Kofler c87d48
 // Compile non-neon code path if needed
Kevin Kofler c87d48
-#if !defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
+#if !SK_ARM_NEON_IS_ALWAYS
Kevin Kofler c87d48
 #define MAKENAME(suffix)        ClampX_ClampY ## suffix
Kevin Kofler c87d48
 #define TILEX_PROCF(fx, max)    SkClampMax((fx) >> 16, max)
Kevin Kofler c87d48
 #define TILEY_PROCF(fy, max)    SkClampMax((fy) >> 16, max)
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkBlitter_RGB16.cpp qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkBlitter_RGB16.cpp
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkBlitter_RGB16.cpp	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkBlitter_RGB16.cpp	2017-06-12 12:20:30.449106855 +0200
Kevin Kofler c87d48
@@ -20,7 +20,7 @@
Kevin Kofler c87d48
                                       uint32_t expanded32, unsigned maskRB);
Kevin Kofler c87d48
 #endif
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
+#if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
     #include <arm_neon.h>
Kevin Kofler c87d48
 extern void SkRGB16BlitterBlitV_neon(uint16_t* device,
Kevin Kofler c87d48
                                      int height,
Kevin Kofler c87d48
@@ -381,7 +381,7 @@
Kevin Kofler c87d48
     unsigned    maskRB = mask.fRowBytes - width;
Kevin Kofler c87d48
     uint32_t    expanded32 = fExpandedRaw16;
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
+#if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
 #define    UNROLL    8
Kevin Kofler c87d48
     do {
Kevin Kofler c87d48
         int w = width;
Kevin Kofler c87d48
@@ -475,7 +475,7 @@
Kevin Kofler c87d48
     unsigned scale5 = SkAlpha255To256(alpha) >> 3;
Kevin Kofler c87d48
     uint32_t src32 =  fExpandedRaw16 * scale5;
Kevin Kofler c87d48
     scale5 = 32 - scale5;
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
+#if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
     SkRGB16BlitterBlitV_neon(device, height, deviceRB, scale5, src32);
Kevin Kofler c87d48
 #else
Kevin Kofler c87d48
     do {
Kevin Kofler c87d48
@@ -654,7 +654,7 @@
Kevin Kofler c87d48
     unsigned scale5 = SkAlpha255To256(alpha) * fScale >> (8 + 3);
Kevin Kofler c87d48
     uint32_t src32 =  fExpandedRaw16 * scale5;
Kevin Kofler c87d48
     scale5 = 32 - scale5;
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON) && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
+#if SK_ARM_NEON_IS_ALWAYS && defined(SK_CPU_LENDIAN)
Kevin Kofler c87d48
     SkRGB16BlitterBlitV_neon(device, height, deviceRB, scale5, src32);
Kevin Kofler c87d48
 #else
Kevin Kofler c87d48
     do {
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkCpu.cpp qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkCpu.cpp
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkCpu.cpp	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkCpu.cpp	2017-06-12 12:20:30.449106855 +0200
Kevin Kofler c87d48
@@ -73,6 +73,124 @@
Kevin Kofler c87d48
         return features;
Kevin Kofler c87d48
     }
Kevin Kofler c87d48
 
Kevin Kofler c87d48
+#elif defined(SK_CPU_ARM32)         && \
Kevin Kofler c87d48
+      !defined(SK_BUILD_FOR_ANDROID)
Kevin Kofler c87d48
+#include <unistd.h>
Kevin Kofler c87d48
+#include <fcntl.h>
Kevin Kofler c87d48
+#include <errno.h>
Kevin Kofler c87d48
+#include <string.h>
Kevin Kofler c87d48
+#include <pthread.h>
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+    static uint32_t read_cpu_features() {
Kevin Kofler c87d48
+        uint32_t features = 0;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        // If we fail any of the following, assume we don't have NEON/VFPv4 instructions
Kevin Kofler c87d48
+        // This allows us to return immediately in case of error.
Kevin Kofler c87d48
+        bool have_neon = false;
Kevin Kofler c87d48
+        bool have_vfpv4 = false;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        // There is no user-accessible CPUID instruction on ARM that we can use.
Kevin Kofler c87d48
+        // Instead, we must parse /proc/cpuinfo and look for the 'neon' feature.
Kevin Kofler c87d48
+        // For example, here's a typical output (Nexus S running ICS 4.0.3):
Kevin Kofler c87d48
+        /*
Kevin Kofler c87d48
+        Processor       : ARMv7 Processor rev 2 (v7l)
Kevin Kofler c87d48
+        BogoMIPS        : 994.65
Kevin Kofler c87d48
+        Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3
Kevin Kofler c87d48
+        CPU implementer : 0x41
Kevin Kofler c87d48
+        CPU architecture: 7
Kevin Kofler c87d48
+        CPU variant     : 0x2
Kevin Kofler c87d48
+        CPU part        : 0xc08
Kevin Kofler c87d48
+        CPU revision    : 2
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        Hardware        : herring
Kevin Kofler c87d48
+        Revision        : 000b
Kevin Kofler c87d48
+        Serial          : 3833c77d6dc000ec
Kevin Kofler c87d48
+        */
Kevin Kofler c87d48
+        char   buffer[4096];
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        do {
Kevin Kofler c87d48
+            // open /proc/cpuinfo
Kevin Kofler c87d48
+            int fd = TEMP_FAILURE_RETRY(open("/proc/cpuinfo", O_RDONLY));
Kevin Kofler c87d48
+            if (fd < 0) {
Kevin Kofler c87d48
+                SkDebugf("Could not open /proc/cpuinfo: %s\n", strerror(errno));
Kevin Kofler c87d48
+                break;
Kevin Kofler c87d48
+            }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            // Read the file. To simplify our search, we're going to place two
Kevin Kofler c87d48
+            // sentinel '\n' characters: one at the start of the buffer, and one at
Kevin Kofler c87d48
+            // the end. This means we reserve the first and last buffer bytes.
Kevin Kofler c87d48
+            buffer[0] = '\n';
Kevin Kofler c87d48
+            int size = TEMP_FAILURE_RETRY(read(fd, buffer+1, sizeof(buffer)-2));
Kevin Kofler c87d48
+            close(fd);
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            if (size < 0) {  // should not happen
Kevin Kofler c87d48
+                SkDebugf("Could not read /proc/cpuinfo: %s\n", strerror(errno));
Kevin Kofler c87d48
+                break;
Kevin Kofler c87d48
+            }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            SkDebugf("START /proc/cpuinfo:\n%.*s\nEND /proc/cpuinfo\n",
Kevin Kofler c87d48
+                    size, buffer+1);
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            // Compute buffer limit, and place final sentinel
Kevin Kofler c87d48
+            char* buffer_end = buffer + 1 + size;
Kevin Kofler c87d48
+            buffer_end[0] = '\n';
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            // Now, find a line that starts with "Features", i.e. look for
Kevin Kofler c87d48
+            // '\nFeatures ' in our buffer.
Kevin Kofler c87d48
+            const char features[] = "\nFeatures\t";
Kevin Kofler c87d48
+            const size_t features_len = sizeof(features)-1;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            char*  line = (char*) memmem(buffer, buffer_end - buffer,
Kevin Kofler c87d48
+                                        features, features_len);
Kevin Kofler c87d48
+            if (line == nullptr) {  // Weird, no Features line, bad kernel?
Kevin Kofler c87d48
+                SkDebugf("Could not find a line starting with 'Features'"
Kevin Kofler c87d48
+                "in /proc/cpuinfo ?\n");
Kevin Kofler c87d48
+                break;
Kevin Kofler c87d48
+            }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            line += features_len;  // Skip the "\nFeatures\t" prefix
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            // Find the end of the current line
Kevin Kofler c87d48
+            char* line_end = (char*) memchr(line, '\n', buffer_end - line);
Kevin Kofler c87d48
+            if (line_end == nullptr)
Kevin Kofler c87d48
+                line_end = buffer_end;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            // Now find an instance of 'neon' in the flags list. We want to
Kevin Kofler c87d48
+            // ensure it's only 'neon' and not something fancy like 'noneon'
Kevin Kofler c87d48
+            // so check that it follows a space.
Kevin Kofler c87d48
+            const char neon[] = " neon";
Kevin Kofler c87d48
+            const size_t neon_len = sizeof(neon)-1;
Kevin Kofler c87d48
+            const char* flag = (const char*) memmem(line, line_end - line,
Kevin Kofler c87d48
+                                                    neon, neon_len);
Kevin Kofler c87d48
+            // Ensure it is followed by a space or a newline.
Kevin Kofler c87d48
+            if (flag != nullptr
Kevin Kofler c87d48
+                && (flag[neon_len] == ' ' || flag[neon_len] == '\n')) {
Kevin Kofler c87d48
+                // Fine, we support Arm NEON !
Kevin Kofler c87d48
+                have_neon = true;
Kevin Kofler c87d48
+            }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+            // Now find an instance of 'vfpv4' in the flags list. We want to
Kevin Kofler c87d48
+            // ensure it's only 'vfpv4' and not something fancy like 'novfpv4'
Kevin Kofler c87d48
+            // so check that it follows a space.
Kevin Kofler c87d48
+            const char vfpv4[] = " vfpv4";
Kevin Kofler c87d48
+            const size_t vfpv4_len = sizeof(vfpv4)-1;
Kevin Kofler c87d48
+            const char* vflag = (const char*) memmem(line, line_end - line,
Kevin Kofler c87d48
+                                                     vfpv4, vfpv4_len);
Kevin Kofler c87d48
+            // Ensure it is followed by a space or a newline.
Kevin Kofler c87d48
+            if (vflag != nullptr
Kevin Kofler c87d48
+                && (vflag[vfpv4_len] == ' ' || vflag[vfpv4_len] == '\n')) {
Kevin Kofler c87d48
+                // Fine, we support Arm VFPv4 !
Kevin Kofler c87d48
+                have_vfpv4 = true;
Kevin Kofler c87d48
+            }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        } while (0);
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        if (have_neon)               { features |= SkCpu::NEON    ; }
Kevin Kofler c87d48
+        if (have_neon && have_vfpv4) { features |= SkCpu::NEON_FMA; }
Kevin Kofler c87d48
+        if (have_vfpv4)              { features |= SkCpu::VFP_FP16; }
Kevin Kofler c87d48
+        return features;
Kevin Kofler c87d48
+    }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
 #elif defined(SK_CPU_ARM64)         && \
Kevin Kofler c87d48
       defined(SK_BUILD_FOR_ANDROID) && \
Kevin Kofler c87d48
      !defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkOpts.cpp qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkOpts.cpp
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkOpts.cpp	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkOpts.cpp	2017-06-12 12:20:30.449106855 +0200
Kevin Kofler c87d48
@@ -99,6 +99,7 @@
Kevin Kofler c87d48
     void Init_avx();
Kevin Kofler c87d48
     void Init_hsw();
Kevin Kofler c87d48
     void Init_crc32();
Kevin Kofler c87d48
+    void Init_neon();
Kevin Kofler c87d48
 
Kevin Kofler c87d48
     static void init() {
Kevin Kofler c87d48
 #if !defined(SK_BUILD_NO_OPTS)
Kevin Kofler c87d48
@@ -109,6 +110,9 @@
Kevin Kofler c87d48
         if (SkCpu::Supports(SkCpu::AVX  )) { Init_avx();   }
Kevin Kofler c87d48
         if (SkCpu::Supports(SkCpu::HSW  )) { Init_hsw();   }
Kevin Kofler c87d48
 
Kevin Kofler c87d48
+    #elif defined(SK_CPU_ARM32)
Kevin Kofler c87d48
+        if (SkCpu::Supports(SkCpu::NEON))  { Init_neon(); }
Kevin Kofler c87d48
+
Kevin Kofler c87d48
     #elif defined(SK_CPU_ARM64)
Kevin Kofler c87d48
         if (SkCpu::Supports(SkCpu::CRC32)) { Init_crc32(); }
Kevin Kofler c87d48
 
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkUtilsArm.h qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkUtilsArm.h
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/core/SkUtilsArm.h	2017-05-18 16:51:44.000000000 +0200
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/core/SkUtilsArm.h	2017-06-12 12:20:30.450106841 +0200
Kevin Kofler c87d48
@@ -8,12 +8,75 @@
Kevin Kofler c87d48
 #ifndef SkUtilsArm_DEFINED
Kevin Kofler c87d48
 #define SkUtilsArm_DEFINED
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#include "SkTypes.h"
Kevin Kofler c87d48
+#include "SkCpu.h"
Kevin Kofler c87d48
+#include "SkUtils.h"
Kevin Kofler c87d48
 
Kevin Kofler c87d48
-#if defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
-    #define SK_ARM_NEON_WRAP(x) (x ## _neon)
Kevin Kofler c87d48
+// Define SK_ARM_NEON_MODE to one of the following values
Kevin Kofler c87d48
+// corresponding respectively to:
Kevin Kofler c87d48
+// - No ARM Neon support at all  (not targetting ARMv7-A, or don't have NEON)
Kevin Kofler c87d48
+// - Full ARM Neon support (i.e. assume the CPU always supports it)
Kevin Kofler c87d48
+// - Optional ARM Neon support (i.e. probe CPU at runtime)
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+#define SK_ARM_NEON_MODE_NONE     0
Kevin Kofler c87d48
+#define SK_ARM_NEON_MODE_ALWAYS   1
Kevin Kofler c87d48
+#define SK_ARM_NEON_MODE_DYNAMIC  2
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+#if defined(SK_ARM_HAS_OPTIONAL_NEON)
Kevin Kofler c87d48
+#  define SK_ARM_NEON_MODE  SK_ARM_NEON_MODE_DYNAMIC
Kevin Kofler c87d48
+#elif defined(SK_ARM_HAS_NEON)
Kevin Kofler c87d48
+#  define SK_ARM_NEON_MODE  SK_ARM_NEON_MODE_ALWAYS
Kevin Kofler c87d48
+#else
Kevin Kofler c87d48
+#  define SK_ARM_NEON_MODE  SK_ARM_NEON_MODE_NONE
Kevin Kofler c87d48
+#endif
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+// Convenience test macros, always defined as 0 or 1
Kevin Kofler c87d48
+#define SK_ARM_NEON_IS_NONE    (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_NONE)
Kevin Kofler c87d48
+#define SK_ARM_NEON_IS_ALWAYS  (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_ALWAYS)
Kevin Kofler c87d48
+#define SK_ARM_NEON_IS_DYNAMIC (SK_ARM_NEON_MODE == SK_ARM_NEON_MODE_DYNAMIC)
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+// The sk_cpu_arm_has_neon() function returns true iff the target device
Kevin Kofler c87d48
+// is ARMv7-A and supports Neon instructions. In DYNAMIC mode, this actually
Kevin Kofler c87d48
+// probes the CPU at runtime (and caches the result).
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+static inline bool sk_cpu_arm_has_neon(void) {
Kevin Kofler c87d48
+#if SK_ARM_NEON_IS_NONE
Kevin Kofler c87d48
+    return false;
Kevin Kofler c87d48
 #else
Kevin Kofler c87d48
-    #define SK_ARM_NEON_WRAP(x) (x)
Kevin Kofler c87d48
+    return SkCpu::Supports(SkCpu::NEON);
Kevin Kofler c87d48
+#endif
Kevin Kofler c87d48
+}
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+// Use SK_ARM_NEON_WRAP(symbol) to map 'symbol' to a NEON-specific symbol
Kevin Kofler c87d48
+// when applicable. This will transform 'symbol' differently depending on
Kevin Kofler c87d48
+// the current NEON configuration, i.e.:
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+//    NONE           -> 'symbol'
Kevin Kofler c87d48
+//    ALWAYS         -> 'symbol_neon'
Kevin Kofler c87d48
+//    DYNAMIC        -> 'symbol' or 'symbol_neon' depending on runtime check.
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+// The goal is to simplify user code, for example:
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+//      return SK_ARM_NEON_WRAP(do_something)(params);
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+// Replaces the equivalent:
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+//     #if SK_ARM_NEON_IS_NONE
Kevin Kofler c87d48
+//       return do_something(params);
Kevin Kofler c87d48
+//     #elif SK_ARM_NEON_IS_ALWAYS
Kevin Kofler c87d48
+//       return do_something_neon(params);
Kevin Kofler c87d48
+//     #elif SK_ARM_NEON_IS_DYNAMIC
Kevin Kofler c87d48
+//       if (sk_cpu_arm_has_neon())
Kevin Kofler c87d48
+//         return do_something_neon(params);
Kevin Kofler c87d48
+//       else
Kevin Kofler c87d48
+//         return do_something(params);
Kevin Kofler c87d48
+//     #endif
Kevin Kofler c87d48
+//
Kevin Kofler c87d48
+#if SK_ARM_NEON_IS_NONE
Kevin Kofler c87d48
+#  define SK_ARM_NEON_WRAP(x)   (x)
Kevin Kofler c87d48
+#elif SK_ARM_NEON_IS_ALWAYS
Kevin Kofler c87d48
+#  define SK_ARM_NEON_WRAP(x)   (x ## _neon)
Kevin Kofler c87d48
+#elif SK_ARM_NEON_IS_DYNAMIC
Kevin Kofler c87d48
+#  define SK_ARM_NEON_WRAP(x)   (sk_cpu_arm_has_neon() ? x ## _neon : x)
Kevin Kofler c87d48
 #endif
Kevin Kofler c87d48
 
Kevin Kofler c87d48
 #endif // SkUtilsArm_DEFINED
Kevin Kofler c87d48
diff -Nur qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/opts/SkOpts_neon.cpp qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/opts/SkOpts_neon.cpp
Kevin Kofler c87d48
--- qtwebengine-opensource-src-5.9.0/src/3rdparty/chromium/third_party/skia/src/opts/SkOpts_neon.cpp	1970-01-01 01:00:00.000000000 +0100
Kevin Kofler e4e544
+++ qtwebengine-opensource-src-5.9.0-skia-neon/src/3rdparty/chromium/third_party/skia/src/opts/SkOpts_neon.cpp	2017-06-12 12:20:30.450106841 +0200
Kevin Kofler c87d48
@@ -0,0 +1,54 @@
Kevin Kofler c87d48
+/*
Kevin Kofler c87d48
+ * Copyright 2015 Google Inc.
Kevin Kofler c87d48
+ *
Kevin Kofler c87d48
+ * Use of this source code is governed by a BSD-style license that can be
Kevin Kofler c87d48
+ * found in the LICENSE file.
Kevin Kofler c87d48
+ */
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+#include "SkOpts.h"
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+#define SK_OPTS_NS sk_neon
Kevin Kofler c87d48
+#include "SkBlitMask_opts.h"
Kevin Kofler c87d48
+#include "SkBlitRow_opts.h"
Kevin Kofler c87d48
+#include "SkBlurImageFilter_opts.h"
Kevin Kofler c87d48
+#include "SkColorCubeFilter_opts.h"
Kevin Kofler c87d48
+#include "SkMorphologyImageFilter_opts.h"
Kevin Kofler c87d48
+#include "SkSwizzler_opts.h"
Kevin Kofler c87d48
+#include "SkTextureCompressor_opts.h"
Kevin Kofler c87d48
+#include "SkXfermode_opts.h"
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+namespace SkOpts {
Kevin Kofler c87d48
+    void Init_neon() {
Kevin Kofler c87d48
+        create_xfermode = sk_neon::create_xfermode;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        box_blur_xx = sk_neon::box_blur_xx;
Kevin Kofler c87d48
+        box_blur_xy = sk_neon::box_blur_xy;
Kevin Kofler c87d48
+        box_blur_yx = sk_neon::box_blur_yx;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        dilate_x = sk_neon::dilate_x;
Kevin Kofler c87d48
+        dilate_y = sk_neon::dilate_y;
Kevin Kofler c87d48
+         erode_x = sk_neon::erode_x;
Kevin Kofler c87d48
+         erode_y = sk_neon::erode_y;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        texture_compressor    = sk_neon::texture_compressor;
Kevin Kofler c87d48
+        fill_block_dimensions = sk_neon::fill_block_dimensions;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        blit_mask_d32_a8 = sk_neon::blit_mask_d32_a8;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        blit_row_color32     = sk_neon::blit_row_color32;
Kevin Kofler c87d48
+        blit_row_s32a_opaque = sk_neon::blit_row_s32a_opaque;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        color_cube_filter_span = sk_neon::color_cube_filter_span;
Kevin Kofler c87d48
+
Kevin Kofler c87d48
+        RGBA_to_BGRA          = sk_neon::RGBA_to_BGRA;
Kevin Kofler c87d48
+        RGBA_to_rgbA          = sk_neon::RGBA_to_rgbA;
Kevin Kofler c87d48
+        RGBA_to_bgrA          = sk_neon::RGBA_to_bgrA;
Kevin Kofler c87d48
+        RGB_to_RGB1           = sk_neon::RGB_to_RGB1;
Kevin Kofler c87d48
+        RGB_to_BGR1           = sk_neon::RGB_to_BGR1;
Kevin Kofler c87d48
+        gray_to_RGB1          = sk_neon::gray_to_RGB1;
Kevin Kofler c87d48
+        grayA_to_RGBA         = sk_neon::grayA_to_RGBA;
Kevin Kofler c87d48
+        grayA_to_rgbA         = sk_neon::grayA_to_rgbA;
Kevin Kofler c87d48
+        inverted_CMYK_to_RGB1 = sk_neon::inverted_CMYK_to_RGB1;
Kevin Kofler c87d48
+        inverted_CMYK_to_BGR1 = sk_neon::inverted_CMYK_to_BGR1;
Kevin Kofler c87d48
+    }
Kevin Kofler c87d48
+}