A few changes for UWP
authorMatthew Leibowitz <mattleibow@live.com>
Thu, 16 Mar 2017 12:56:48 +0000 (14:56 +0200)
committerMatthew Leibowitz <mattleibow@live.com>
Thu, 16 Mar 2017 12:56:48 +0000 (14:56 +0200)
BUILD.gn
gn/BUILD.gn
gn/BUILDCONFIG.gn
src/xps/SkXPSDevice.cpp
third_party/libjpeg-turbo/BUILD.gn

index 390f136..bf3e69b 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -198,7 +198,10 @@ opts("none") {
 
 opts("armv7") {
   enabled = current_cpu == "arm"
-  sources = skia_opts.armv7_sources + skia_opts.neon_sources
+  sources = skia_opts.armv7_sources
+  if (!is_win) {
+    sources += skia_opts.neon_sources
+  }
   cflags = []
 }
 
@@ -398,7 +401,7 @@ optional("gpu") {
     sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
   } else if (is_ios) {
     sources += [ "src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp" ]
-  } else if (is_win) {
+  } else if (is_win && !is_winrt) {
     sources += [ "src/gpu/gl/win/GrGLCreateNativeInterface_win.cpp" ]
     libs += [ "OpenGL32.lib" ]
   } else {
@@ -610,7 +613,6 @@ component("skia") {
     sources += [
       "src/fonts/SkFontMgr_indirect.cpp",
       "src/ports/SkDebug_win.cpp",
-      "src/ports/SkFontHost_win.cpp",
       "src/ports/SkFontMgr_win_dw.cpp",
       "src/ports/SkImageEncoder_WIC.cpp",
       "src/ports/SkImageGeneratorWIC.cpp",
@@ -620,6 +622,9 @@ component("skia") {
       "src/ports/SkTLS_win.cpp",
       "src/ports/SkTypeface_win_dw.cpp",
     ]
+    if (!is_winrt) {
+      sources += [ "src/ports/SkFontHost_win.cpp" ]
+    }
     if (skia_use_gdi) {
       sources += [ "src/ports/SkFontMgr_win_gdi_factory.cpp" ]
       libs += [
@@ -645,6 +650,13 @@ component("skia") {
     ]
   }
 
+  if (is_winrt) {
+    sources -= [
+      get_path_info("src/utils/win/SkWGL.h", "abspath"),
+      get_path_info("src/utils/win/SkWGL_win.cpp", "abspath"),
+    ]
+  }
+
   if (is_android) {
     deps += [ "//third_party/expat" ]
     if (is_skia_standalone && ndk != "") {
index a393928..9e8b05e 100644 (file)
@@ -87,32 +87,49 @@ config("default") {
       "WIN32_LEAN_AND_MEAN",
       "NOMINMAX",
     ]
-    include_dirs = [
-      "$windk/VC/include",
-
-      # For local builds.
-      "$windk/../Windows Kits/10/Include/10.0.10150.0/ucrt",
-      "$windk/../Windows Kits/8.1/Include/shared",
-      "$windk/../Windows Kits/8.1/Include/um",
-      "$windk/../Windows Kits/8.1/Include/winrt",
-
-      # For builds using win_toolchain asset.
-      "$windk/win_sdk/Include/10.0.14393.0/shared",
-      "$windk/win_sdk/Include/10.0.14393.0/ucrt",
-      "$windk/win_sdk/Include/10.0.14393.0/um",
-      "$windk/win_sdk/Include/10.0.14393.0/winrt",
-    ]
-    lib_dirs = [
-      # For local builds.
-      "$windk/../Windows Kits/10/Lib/10.0.10150.0/ucrt/$target_cpu",
-      "$windk/../Windows Kits/8.1/Lib/winv6.3/um/$target_cpu",
-
-      # For builds using win_toolchain asset.
-      "$windk/win_sdk/Lib/10.0.14393.0/ucrt/$target_cpu",
-      "$windk/win_sdk/Lib/10.0.14393.0/um/$target_cpu",
-    ]
+    if (is_winrt) {
+      include_dirs = [
+        "$windk/VC/include",
+
+        "$windk/../Windows Kits/10/Include/10.0.10240.0/ucrt",
+        "$windk/../Windows Kits/10/Include/10.0.10240.0/um",
+        "$windk/../Windows Kits/10/Include/10.0.10240.0/shared",
+        "$windk/../Windows Kits/10/Include/10.0.10240.0/winrt",
+      ]
+      lib_dirs = [
+        "$windk/../Windows Kits\10\lib\10.0.10240.0\ucrt\$target_cpu",
+        "$windk/../Windows Kits\10\lib\10.0.10240.0\um\$target_cpu",
+      ]
+    } else {
+      include_dirs = [
+        "$windk/VC/include",
+    
+        # For local builds.
+        "$windk/../Windows Kits/10/Include/10.0.10150.0/ucrt",
+        "$windk/../Windows Kits/8.1/Include/shared",
+        "$windk/../Windows Kits/8.1/Include/um",
+        "$windk/../Windows Kits/8.1/Include/winrt",
+    
+        # For builds using win_toolchain asset.
+        "$windk/win_sdk/Include/10.0.14393.0/shared",
+        "$windk/win_sdk/Include/10.0.14393.0/ucrt",
+        "$windk/win_sdk/Include/10.0.14393.0/um",
+        "$windk/win_sdk/Include/10.0.14393.0/winrt",
+      ]
+      lib_dirs = [
+        # For local builds.
+        "$windk/../Windows Kits/10/Lib/10.0.10150.0/ucrt/$target_cpu",
+        "$windk/../Windows Kits/8.1/Lib/winv6.3/um/$target_cpu",
+    
+        # For builds using win_toolchain asset.
+        "$windk/win_sdk/Lib/10.0.14393.0/ucrt/$target_cpu",
+        "$windk/win_sdk/Lib/10.0.14393.0/um/$target_cpu",
+      ]
+    }
     if (target_cpu == "x86") {
       lib_dirs += [ "$windk/VC/lib" ]
+    } else if (target_cpu == "arm") {
+      lib_dirs += [ "$windk/VC/lib/arm" ]
     } else {
       lib_dirs += [ "$windk/VC/lib/amd64" ]
     }
@@ -130,13 +147,13 @@ config("default") {
     ]
   }
 
-  if (current_cpu == "arm") {
+  if (current_cpu == "arm" && !is_win) {
     cflags += [
       "-march=armv7-a",
       "-mfpu=neon",
       "-mthumb",
     ]
-  } else if (current_cpu == "mipsel") {
+  } else if (current_cpu == "mipsel" && !is_win) {
     cflags += [
       "-march=mips32r2",
       "-mdspr2",
@@ -452,12 +469,19 @@ config("executable") {
 toolchain("msvc") {
   lib_dir_switch = "/LIBPATH:"
 
-  bin = "$windk/VC/bin/amd64"
+  _target = "amd64"
   env_setup = ""
-  if (target_cpu == "x86") {
-    bin += "_x86"
-    env_setup = "cmd /c $windk/win_sdk/bin/SetEnv.cmd /x86 && "
+  env_setup_end = ""
+  if (target_cpu != "x64") {
+    if (target_cpu == "x86") {
+      _target += "_x86"
+    } else if (target_cpu == "arm") {
+      _target += "_arm"
+    }
+    env_setup = "cmd /c \"\"$windk/VC/vcvarsall.bat\" $_target && "
+    env_setup_end = "\""
   }
+  bin = "$windk/VC/bin/$_target"
 
   tool("cc") {
     rspfile = "{{output}}.rsp"
@@ -465,7 +489,7 @@ toolchain("msvc") {
     pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
 
     # Label names may have spaces so pdbname must be quoted.
-    command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
+    command = "$env_setup\"$bin/cl.exe\" /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"$env_setup_end"
     depsformat = "msvc"
     outputs = [
       "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
@@ -480,7 +504,7 @@ toolchain("msvc") {
     pdbname = "{{target_out_dir}}/{{label_name}}_c.pdb"
 
     # Label names may have spaces so pdbname must be quoted.
-    command = "$env_setup$bin/cl.exe /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\""
+    command = "$env_setup\"$bin/cl.exe\" /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd\"$pdbname\"$env_setup_end"
     depsformat = "msvc"
     outputs = [
       "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
@@ -492,7 +516,7 @@ toolchain("msvc") {
   tool("alink") {
     rspfile = "{{output}}.rsp"
 
-    command = "$env_setup$bin/lib.exe /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile"
+    command = "$env_setup\"$bin/lib.exe\" /nologo /ignore:4221 {{arflags}} /OUT:{{output}} @$rspfile$env_setup_end"
     outputs = [
       # Ignore {{output_extension}} and always use .lib, there's no reason to
       # allow targets to override this extension on Windows.
@@ -512,7 +536,7 @@ toolchain("msvc") {
     pdbname = "${dllname}.pdb"
     rspfile = "${dllname}.rsp"
 
-    command = "$env_setup$bin/link.exe /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile"
+    command = "$env_setup\"$bin/link.exe\" /nologo /IMPLIB:$libname /DLL /OUT:$dllname /PDB:$pdbname @$rspfile$env_setup_end"
     outputs = [
       dllname,
       libname,
@@ -542,7 +566,7 @@ toolchain("msvc") {
     rspfile = "$exename.rsp"
 
     command =
-        "$env_setup$bin/link.exe /nologo /OUT:$exename /PDB:$pdbname @$rspfile"
+        "$env_setup\"$bin/link.exe\" /nologo /OUT:$exename /PDB:$pdbname @$rspfile$env_setup_end"
 
     default_output_extension = ".exe"
     default_output_dir = "{{root_out_dir}}"
index 4a99df3..cfebe2d 100644 (file)
@@ -41,7 +41,8 @@ is_ios = current_os == "ios" || current_os == "tvos"
 is_tvos = current_os == "tvos"
 is_linux = current_os == "linux"
 is_mac = current_os == "mac"
-is_win = current_os == "win"
+is_win = current_os == "win" || current_os == "winrt"
+is_winrt = current_os == "winrt"
 
 if (target_cpu == "") {
   target_cpu = host_cpu
index 3787433..94f039f 100644 (file)
@@ -200,6 +200,10 @@ template <typename T> static constexpr size_t sk_digits_in() {
 HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
                                         const unsigned int pageNum,
                                         IXpsOMImageResource** image) {
+#ifdef SK_BUILD_FOR_WINRT
+    *image = nullptr;
+    return S_OK;
+#else
     SkTScopedComPtr<IXpsOMThumbnailGenerator> thumbnailGenerator;
     HRM(CoCreateInstance(
             CLSID_XpsOMThumbnailGenerator,
@@ -231,6 +235,7 @@ HRESULT SkXPSDevice::createXpsThumbnail(IXpsOMPage* page,
         "Could not generate thumbnail.");
 
     return S_OK;
+#endif
 }
 
 HRESULT SkXPSDevice::createXpsPage(const XPS_SIZE& pageSize,
@@ -359,6 +364,9 @@ bool SkXPSDevice::endSheet() {
 }
 
 static HRESULT subset_typeface(SkXPSDevice::TypefaceUse* current) {
+#if SK_BUILD_FOR_WINRT
+    return E_UNEXPECTED;
+#else
     //CreateFontPackage wants unsigned short.
     //Microsoft, Y U NO stdint.h?
     SkTDArray<unsigned short> keepList;
@@ -449,6 +457,7 @@ static HRESULT subset_typeface(SkXPSDevice::TypefaceUse* current) {
         "Could not set new stream for subsetted font.");
 
     return S_OK;
+#endif
 }
 
 bool SkXPSDevice::endPortfolio() {
index 655c5f2..000068f 100644 (file)
@@ -64,12 +64,12 @@ if (skia_use_system_libjpeg_turbo) {
       "../externals/libjpeg-turbo/jutils.c",
     ]
 
-    if (current_cpu == "arm" && !is_ios) {
+    if (current_cpu == "arm" && !is_ios && !is_win) {
       sources += [
         "../externals/libjpeg-turbo/simd/jsimd_arm.c",
         "../externals/libjpeg-turbo/simd/jsimd_arm_neon.S",
       ]
-    } else if (current_cpu == "arm64" && !is_ios) {
+    } else if (current_cpu == "arm64" && !is_ios && !is_win) {
       sources += [
         "../externals/libjpeg-turbo/simd/jsimd_arm64.c",
         "../externals/libjpeg-turbo/simd/jsimd_arm64_neon.S",