GN/Win: suppport GDI, convert GDI bots to build with GN.

CQ_INCLUDE_TRYBOTS=master.client.skia.compile:Build-Win-MSVC-x86-Debug-GDI-Trybot,Build-Win-MSVC-x86-Release-GDI-Trybot;master.client.skia:Perf-Win-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI-Trybot,Test-Win-MSVC-GCE-CPU-AVX2-x86_64-Debug-GDI-Trybot,Test-Win-MSVC-GCE-CPU-AVX2-x86_64-Release-GDI-Trybot

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3324

Change-Id: I3ff2f5d16de9fff7ed77fa5127b96bef55bef957
Reviewed-on: https://skia-review.googlesource.com/3324
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 3f88df5..d402f59 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -14,6 +14,7 @@
   skia_use_expat = true
   skia_use_fontconfig = is_linux
   skia_use_freetype = is_android || is_fuchsia || is_linux
+  skia_use_gdi = false
   skia_use_giflib = !is_fuchsia
   skia_use_libjpeg_turbo = true
   skia_use_libpng = true
@@ -542,7 +543,6 @@
       "src/ports/SkDebug_win.cpp",
       "src/ports/SkFontHost_win.cpp",
       "src/ports/SkFontMgr_win_dw.cpp",
-      "src/ports/SkFontMgr_win_dw_factory.cpp",
       "src/ports/SkImageEncoder_WIC.cpp",
       "src/ports/SkImageGeneratorWIC.cpp",
       "src/ports/SkOSFile_win.cpp",
@@ -553,6 +553,15 @@
       "src/xps/SkDocument_XPS.cpp",
       "src/xps/SkXPSDevice.cpp",
     ]
+    if (skia_use_gdi) {
+      sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
+      libs += [
+        "Gdi32.lib",
+        "Usp10.lib",
+      ]
+    } else {
+      sources += [ "src/ports/SkFontMgr_win_dw_factory.cpp" ]
+    }
     sources -=
         [ get_path_info("src/utils/SkThreadUtils_pthread.cpp", "abspath") ]
     libs += [
diff --git a/infra/bots/recipe_modules/flavor/gn_flavor.py b/infra/bots/recipe_modules/flavor/gn_flavor.py
index a189536..d06d7c4 100644
--- a/infra/bots/recipe_modules/flavor/gn_flavor.py
+++ b/infra/bots/recipe_modules/flavor/gn_flavor.py
@@ -18,6 +18,7 @@
       extra_config == 'CommandBuffer',
       extra_config == 'Exceptions',
       extra_config == 'Fast',
+      extra_config == 'GDI',
       extra_config == 'GN',
       extra_config == 'Mesa',
       extra_config == 'NoGPU',
@@ -93,6 +94,8 @@
       args['skia_use_angle'] = 'true'
     if extra_config == 'CommandBuffer':
       self.m.run.run_once(self.build_command_buffer)
+    if extra_config == 'GDI':
+      args['skia_use_gdi'] = 'true'
     if extra_config == 'MSAN':
       args['skia_use_fontconfig'] = 'false'
     if extra_config == 'Mesa':
diff --git a/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GDI.json b/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GDI.json
index cd08ff7..38d8f64 100644
--- a/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GDI.json
+++ b/infra/bots/recipes/swarm_compile.expected/Build-Win-MSVC-x86-Release-GDI.json
@@ -123,30 +123,39 @@
     "cmd": [
       "python",
       "-u",
-      "[CUSTOM_C:\\_B_WORK]\\skia\\infra\\bots\\bootstrap_win_toolchain_json.py",
-      "--win_toolchain_json",
-      "[SLAVE_BUILD]\\src\\build\\win_toolchain.json",
-      "--depot_tools_parent_dir",
-      "[SLAVE_BUILD]"
-    ],
-    "name": "bootstrap win toolchain"
-  },
-  {
-    "cmd": [
-      "python",
-      "make.py",
-      "most"
+      "[CUSTOM_C:\\_B_WORK]\\skia\\bin\\fetch-gn"
     ],
     "cwd": "[CUSTOM_C:\\_B_WORK]\\skia",
     "env": {
-      "BUILDTYPE": "Release",
-      "CHROME_HEADLESS": "1",
-      "CHROME_PATH": "[SLAVE_BUILD]\\src",
-      "GYP_DEFINES": "qt_sdk=C:/Qt/4.8.5/ skia_arch_type=x86 skia_gdi=1 skia_warnings_as_errors=0 skia_win_debuggers_path=c:/DbgHelp skia_win_ltcg=0",
-      "PATH": "%(PATH)s;RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools]",
-      "SKIA_OUT": "[CUSTOM_C:\\_B_WORK]\\skia\\out\\Build-Win-MSVC-x86-Release-GDI"
+      "PATH": "%(PATH)s;RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools]"
     },
-    "name": "build most"
+    "name": "fetch-gn"
+  },
+  {
+    "cmd": [
+      "gn.bat",
+      "gen",
+      "[CUSTOM_C:\\_B_WORK]\\skia\\out\\Build-Win-MSVC-x86-Release-GDI\\Release",
+      "--args=is_debug=false skia_use_gdi=true target_cpu=\"x86\" windk=\"[SLAVE_BUILD]\\t\\depot_tools\\win_toolchain\\vs_files\\95ddda401ec5678f15eeed01d2bee08fcbc5ee97\""
+    ],
+    "cwd": "[CUSTOM_C:\\_B_WORK]\\skia",
+    "env": {
+      "PATH": "%(PATH)s;RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools]"
+    },
+    "name": "gn gen"
+  },
+  {
+    "cmd": [
+      "ninja.exe",
+      "-C",
+      "[CUSTOM_C:\\_B_WORK]\\skia\\out\\Build-Win-MSVC-x86-Release-GDI\\Release"
+    ],
+    "cwd": "[CUSTOM_C:\\_B_WORK]\\skia",
+    "env": {
+      "NINJA_STATUS": "%%e [%%f/%%t] ",
+      "PATH": "%(PATH)s;RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools];RECIPE_PACKAGE_REPO[depot_tools]"
+    },
+    "name": "ninja"
   },
   {
     "cmd": [