Comment out lcd assert to make GLPrograms test happy
[platform/upstream/libSkiaSharp.git] / BUILD.gn
index a406ffa..19691ed 100644 (file)
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -6,12 +6,18 @@
 import("gn/android_framework_defines.gni")
 import("gn/shared_sources.gni")
 
+if (is_fuchsia) {
+  import("//build/vulkan/config.gni")
+}
+
 if (!defined(is_skia_standalone)) {
   is_skia_standalone = false
 }
+is_skia_dev_build = is_skia_standalone && !is_official_build
 
 declare_args() {
   skia_use_angle = false
+  skia_use_egl = false
   skia_use_expat = true
   skia_use_fontconfig = is_linux
   skia_use_freetype = is_android || is_fuchsia || is_linux
@@ -28,26 +34,40 @@ declare_args() {
   skia_android_serial = ""
   skia_enable_android_framework_defines = false
   skia_enable_discrete_gpu = true
+  skia_enable_effects = true
   skia_enable_gpu = true
   skia_enable_pdf = true
-  skia_enable_splicer =
-      is_skia_standalone &&
-      (is_linux || is_mac || (is_android && target_cpu == "arm64"))
-  skia_enable_tools = is_skia_standalone
-  skia_enable_vulkan_debug_layers = is_skia_standalone && is_debug
+  skia_enable_spirv_validation = is_skia_dev_build && is_debug
+  skia_enable_tools = is_skia_dev_build
+  skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
   skia_vulkan_sdk = getenv("VULKAN_SDK")
 }
 declare_args() {
-  skia_use_dng_sdk =
-      !is_fuchsia && !is_win && skia_use_libjpeg_turbo && skia_use_zlib
+  skia_use_dng_sdk = !is_fuchsia && skia_use_libjpeg_turbo && skia_use_zlib
   skia_use_sfntly = skia_use_icu
 
   if (is_android) {
     skia_use_vulkan = defined(ndk_api) && ndk_api >= 24
+  } else if (is_fuchsia) {
+    skia_use_vulkan = fuchsia_use_vulkan
   } else {
     skia_use_vulkan = skia_vulkan_sdk != ""
   }
 }
+declare_args() {
+  if (skia_use_vulkan) {
+    if (is_fuchsia) {
+      skia_vulkan_headers = "$fuchsia_vulkan_sdk/include"
+    } else if (is_linux || is_win) {
+      skia_vulkan_headers = "$skia_vulkan_sdk/include"
+    } else {
+      # When buliding on Android we get the header via the NDK
+      skia_vulkan_headers = ""
+    }
+  } else {
+    skia_vulkan_headers = "third_party/vulkan"
+  }
+}
 
 # Our tools require static linking (they use non-exported symbols).
 skia_enable_tools = skia_enable_tools && !is_component_build
@@ -61,20 +81,22 @@ skia_public_includes = [
   "include/config",
   "include/core",
   "include/effects",
+  "include/encode",
   "include/gpu",
   "include/gpu/gl",
-  "include/images",
   "include/pathops",
   "include/ports",
   "include/svg",
   "include/utils",
   "include/utils/mac",
-  "include/xml",
 ]
 
 # Skia public API, generally provided by :skia.
 config("skia_public") {
   include_dirs = skia_public_includes
+  if (skia_vulkan_headers != "") {
+    include_dirs += [ skia_vulkan_headers ]
+  }
   defines = []
   if (is_component_build) {
     defines += [ "SKIA_DLL" ]
@@ -102,7 +124,6 @@ config("skia_private") {
     "src/effects",
     "src/effects/gradients",
     "src/fonts",
-    "src/gpu",
     "src/image",
     "src/images",
     "src/lazy",
@@ -114,15 +135,12 @@ config("skia_private") {
     "src/sksl",
     "src/utils",
     "src/utils/win",
+    "src/xml",
     "third_party/etc1",
     "third_party/gif",
-    "third_party/ktx",
   ]
 
-  defines = [
-    "SK_GAMMA_APPLY_TO_A8",
-    "SK_INTERNAL",
-  ]
+  defines = [ "SK_GAMMA_APPLY_TO_A8" ]
   if (is_android) {
     defines += [
       "SK_GAMMA_EXPONENT=1.4",
@@ -136,20 +154,19 @@ config("skia_private") {
   libs = []
   lib_dirs = []
   if (skia_use_vulkan) {
-    if (skia_vulkan_sdk != "" && !is_android) {
+    if (skia_vulkan_sdk != "" && !is_android && !is_fuchsia) {
       if (is_win) {
-        include_dirs += [ "$skia_vulkan_sdk/Include/" ]
-        lib_dirs += [ "$skia_vulkan_sdk/Bin" ]
+        lib_dirs += [
+          "$skia_vulkan_sdk/Bin",
+          "$skia_vulkan_sdk/Lib",
+        ]
       } else {
-        include_dirs += [ "$skia_vulkan_sdk/include/" ]
         lib_dirs += [ "$skia_vulkan_sdk/lib/" ]
       }
     }
-    if (is_win) {
-      libs += [ "vulkan-1.lib" ]
-    } else {
-      libs += [ "vulkan" ]
-    }
+  }
+  if (skia_enable_gpu) {
+    include_dirs += [ "src/gpu" ]
   }
   if (skia_use_angle) {
     defines += [ "SK_ANGLE" ]
@@ -325,12 +342,19 @@ template("optional") {
   }
 }
 
+optional("effects") {
+  enabled = skia_enable_effects
+  sources =
+      skia_effects_sources + [ "src/ports/SkGlobalInitialization_default.cpp" ]
+  sources_when_disabled = [ "src/ports/SkGlobalInitialization_none.cpp" ]
+}
+
 optional("fontmgr_android") {
   enabled = fontmgr_android_enabled
 
   deps = [
+    ":typeface_freetype",
     "//third_party/expat",
-    "//third_party/freetype2",
   ]
   sources = [
     "src/ports/SkFontMgr_android.cpp",
@@ -343,11 +367,15 @@ optional("fontmgr_custom") {
   enabled = is_linux && skia_use_freetype && !skia_use_fontconfig
 
   deps = [
-    "//third_party/freetype2",
+    ":typeface_freetype",
   ]
   sources = [
     "src/ports/SkFontMgr_custom.cpp",
+    "src/ports/SkFontMgr_custom.h",
+    "src/ports/SkFontMgr_custom_directory.cpp",
     "src/ports/SkFontMgr_custom_directory_factory.cpp",
+    "src/ports/SkFontMgr_custom_embedded.cpp",
+    "src/ports/SkFontMgr_custom_empty.cpp",
   ]
 }
 
@@ -355,8 +383,8 @@ optional("fontmgr_fontconfig") {
   enabled = skia_use_freetype && skia_use_fontconfig
 
   deps = [
+    ":typeface_freetype",
     "//third_party:fontconfig",
-    "//third_party/freetype2",
   ]
   sources = [
     "src/ports/SkFontConfigInterface.cpp",
@@ -372,10 +400,11 @@ optional("fontmgr_fuchsia") {
   enabled = is_fuchsia && skia_use_freetype
 
   deps = [
-    "//third_party/freetype2",
+    ":typeface_freetype",
   ]
   sources = [
     "src/ports/SkFontMgr_custom.cpp",
+    "src/ports/SkFontMgr_custom_empty.cpp",
     "src/ports/SkFontMgr_custom_empty_factory.cpp",
   ]
 }
@@ -384,7 +413,8 @@ optional("gpu") {
   enabled = skia_enable_gpu
   public_defines = []
 
-  sources = skia_gpu_sources + [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
+  sources = skia_gpu_sources + skia_sksl_sources +
+            [ "src/gpu/gl/GrGLDefaultInterface_native.cpp" ]
 
   # These paths need to be absolute to match the ones produced by shared_sources.gni.
   sources -= get_path_info([
@@ -395,8 +425,15 @@ optional("gpu") {
   libs = []
   if (is_android) {
     sources += [ "src/gpu/gl/android/GrGLCreateNativeInterface_android.cpp" ]
+  } else if (skia_use_egl) {
+    sources += [ "src/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp" ]
+    libs += [ "EGL" ]
   } else if (is_linux) {
     sources += [ "src/gpu/gl/glx/GrGLCreateNativeInterface_glx.cpp" ]
+    libs += [
+      "GL",
+      "GLU",
+    ]
   } else if (is_mac) {
     sources += [ "src/gpu/gl/mac/GrGLCreateNativeInterface_mac.cpp" ]
   } else if (is_ios) {
@@ -415,6 +452,12 @@ optional("gpu") {
       public_defines += [ "SK_ENABLE_VK_LAYERS" ]
     }
   }
+  if (skia_enable_spirv_validation) {
+    deps = [
+      "//third_party/spirv-tools",
+    ]
+    public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ]
+  }
 }
 
 optional("jpeg") {
@@ -428,8 +471,8 @@ optional("jpeg") {
     "src/codec/SkJpegCodec.cpp",
     "src/codec/SkJpegDecoderMgr.cpp",
     "src/codec/SkJpegUtility.cpp",
-    "src/images/SkJPEGImageEncoder.cpp",
     "src/images/SkJPEGWriteUtility.cpp",
+    "src/images/SkJpegEncoder.cpp",
   ]
 }
 
@@ -459,7 +502,7 @@ optional("png") {
   sources = [
     "src/codec/SkIcoCodec.cpp",
     "src/codec/SkPngCodec.cpp",
-    "src/images/SkPNGImageEncoder.cpp",
+    "src/images/SkPngEncoder.cpp",
   ]
 }
 
@@ -483,15 +526,6 @@ optional("raw") {
   ]
 }
 
-optional("splicer") {
-  enabled = skia_enable_splicer
-  public_defines = [ "SK_RASTER_PIPELINE_HAS_JIT" ]
-
-  sources = [
-    "src/splicer/SkSplicer.cpp",
-  ]
-}
-
 optional("typeface_freetype") {
   enabled = skia_use_freetype
 
@@ -514,7 +548,7 @@ optional("webp") {
   sources = [
     "src/codec/SkWebpAdapterCodec.cpp",
     "src/codec/SkWebpCodec.cpp",
-    "src/images/SkWEBPImageEncoder.cpp",
+    "src/images/SkWebpEncoder.cpp",
   ]
 }
 
@@ -526,6 +560,8 @@ optional("xml") {
     "//third_party/expat",
   ]
   sources = [
+    "src/svg/SkSVGCanvas.cpp",
+    "src/svg/SkSVGDevice.cpp",
     "src/xml/SkDOM.cpp",
     "src/xml/SkXMLParser.cpp",
     "src/xml/SkXMLWriter.cpp",
@@ -541,6 +577,7 @@ component("skia") {
     ":armv7",
     ":avx",
     ":crc32",
+    ":effects",
     ":fontmgr_android",
     ":fontmgr_custom",
     ":fontmgr_fontconfig",
@@ -552,12 +589,10 @@ component("skia") {
     ":pdf",
     ":png",
     ":raw",
-    ":splicer",
     ":sse2",
     ":sse41",
     ":sse42",
     ":ssse3",
-    ":typeface_freetype",
     ":webp",
     ":xml",
   ]
@@ -569,8 +604,6 @@ component("skia") {
 
   sources = []
   sources += skia_core_sources
-  sources += skia_effects_sources
-  sources += skia_sksl_sources
   sources += skia_utils_sources
   sources += skia_xps_sources
   sources += [
@@ -593,18 +626,14 @@ component("skia") {
     "src/codec/SkWbmpCodec.cpp",
     "src/images/SkImageEncoder.cpp",
     "src/ports/SkDiscardableMemory_none.cpp",
-    "src/ports/SkGlobalInitialization_default.cpp",
     "src/ports/SkImageGenerator_skia.cpp",
     "src/ports/SkMemory_malloc.cpp",
     "src/ports/SkOSFile_stdio.cpp",
     "src/sfnt/SkOTTable_name.cpp",
     "src/sfnt/SkOTUtils.cpp",
-    "src/svg/SkSVGCanvas.cpp",
-    "src/svg/SkSVGDevice.cpp",
     "src/utils/mac/SkStream_mac.cpp",
     "third_party/etc1/etc1.cpp",
     "third_party/gif/SkGifImageReader.cpp",
-    "third_party/ktx/ktx.cpp",
   ]
 
   libs = []
@@ -650,6 +679,9 @@ component("skia") {
 
   if (is_android) {
     deps += [ "//third_party/expat" ]
+    if (defined(ndk) && ndk != "") {
+      deps += [ "//third_party/cpu-features" ]
+    }
     sources += [ "src/ports/SkDebug_android.cpp" ]
     libs += [
       "EGL",
@@ -659,11 +691,6 @@ component("skia") {
   }
 
   if (is_linux) {
-    libs += [
-      "GL",
-      "GLU",
-      "X11",
-    ]
     sources += [ "src/ports/SkDebug_stdio.cpp" ]
   }
 
@@ -675,6 +702,8 @@ component("skia") {
       "src/ports/SkImageGeneratorCG.cpp",
     ]
     libs += [
+      # AppKit symbols NSFontWeightXXX may be dlsym'ed.
+      "AppKit.framework",
       "ApplicationServices.framework",
       "OpenGL.framework",
     ]
@@ -693,6 +722,9 @@ component("skia") {
       "CoreText.framework",
       "ImageIO.framework",
       "MobileCoreServices.framework",
+
+      # UIKit symbols UIFontWeightXXX may be dlsym'ed.
+      "UIKit.framework",
     ]
   }
 
@@ -716,7 +748,8 @@ if (skia_enable_tools) {
     skia_h = "$target_gen_dir/skia.h"
     script = "gn/find_headers.py"
     args = [ rebase_path(skia_h, root_build_dir) ] +
-           rebase_path(skia_public_includes)
+           rebase_path(skia_public_includes) +
+           [ rebase_path("third_party/vulkan") ]
     depfile = "$skia_h.deps"
     outputs = [
       skia_h,
@@ -736,7 +769,9 @@ if (skia_enable_tools) {
         "tools/fiddle/draw.cpp",
         "tools/fiddle/fiddle_main.cpp",
       ]
+      testonly = true
       deps = [
+        ":flags",
         ":skia",
         ":skia.h",
       ]
@@ -835,13 +870,14 @@ if (skia_enable_tools) {
       ]
       libs = []
 
-      if (is_android) {
+      if (is_android || skia_use_egl) {
         sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
       } else if (is_ios) {
         sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
         libs += [ "OpenGLES.framework" ]
       } else if (is_linux) {
         sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
+        libs += [ "X11" ]
       } else if (is_mac) {
         sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
       } else if (is_win) {
@@ -863,6 +899,11 @@ if (skia_enable_tools) {
       }
       if (skia_use_vulkan) {
         sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
+        if (is_win) {
+          libs += [ "vulkan-1.lib" ]
+        } else {
+          libs += [ "vulkan" ]
+        }
       }
     }
   }
@@ -892,7 +933,6 @@ if (skia_enable_tools) {
       "tools/timer",
     ]
     sources = [
-      "src/utils/SkMultiPictureDocumentReader.cpp",  # TODO(halcanary): move to tools?
       "tools/AndroidSkDebugToStdOut.cpp",
       "tools/CrashHandler.cpp",
       "tools/LsanSuppressions.cpp",
@@ -910,6 +950,11 @@ if (skia_enable_tools) {
       "tools/sk_tool_utils_font.cpp",
       "tools/timer/Timer.cpp",
     ]
+    libs = []
+    if (is_ios) {
+      sources += [ "tools/ios_utils.m" ]
+      libs += [ "Foundation.framework" ]
+    }
     deps = [
       ":common_flags",
       ":flags",
@@ -942,12 +987,14 @@ if (skia_enable_tools) {
     deps = [
       ":experimental_svg_model",
       ":flags",
-      ":gpu_tool_utils",
       ":skia",
       ":tool_utils",
       "//third_party/libpng",
       "//third_party/zlib",
     ]
+    public_deps = [
+      ":gpu_tool_utils",  # Test.h #includes headers from this target.
+    ]
   }
 
   import("gn/bench.gni")
@@ -1013,6 +1060,10 @@ if (skia_enable_tools) {
         "src/views/unix/SkOSWindow_Unix.cpp",
         "src/views/unix/keysym2ucs.c",
       ]
+      libs += [
+        "GL",
+        "X11",
+      ]
     } else if (is_mac) {
       sources += [
         "src/views/mac/SkEventNotifier.mm",
@@ -1082,6 +1133,7 @@ if (skia_enable_tools) {
               ]
     deps = [
       ":experimental_svg_model",
+      ":flags",
       ":gm",
       ":tool_utils",
       ":views",
@@ -1118,6 +1170,22 @@ if (skia_enable_tools) {
     ]
   }
 
+  test_app("ok") {
+    sources = [
+      "tools/ok.cpp",
+      "tools/ok_dsts.cpp",
+      "tools/ok_srcs.cpp",
+      "tools/ok_test.cpp",
+      "tools/ok_vias.cpp",
+    ]
+    deps = [
+      ":gm",
+      ":skia",
+      ":tests",
+      ":tool_utils",
+    ]
+  }
+
   if (!is_debug) {  # I've benchmarked debug code once too many times...
     test_app("monobench") {
       sources = [
@@ -1147,6 +1215,16 @@ if (skia_enable_tools) {
     ]
   }
 
+  test_app("skpinfo") {
+    sources = [
+      "tools/skpinfo.cpp",
+    ]
+    deps = [
+      ":flags",
+      ":skia",
+    ]
+  }
+
   if (is_linux || is_win || is_mac) {
     test_app("SampleApp") {
       sources = [
@@ -1212,6 +1290,16 @@ if (skia_enable_tools) {
     ]
   }
 
+  test_app("create_flutter_test_images") {
+    sources = [
+      "tools/create_flutter_test_images.cpp",
+    ]
+    deps = [
+      ":skia",
+      ":tool_utils",
+    ]
+  }
+
   test_app("get_images_from_skps") {
     sources = [
       "tools/get_images_from_skps.cpp",
@@ -1271,6 +1359,7 @@ if (skia_enable_tools) {
   test_app("fuzz") {
     sources = [
       "fuzz/FilterFuzz.cpp",
+      "fuzz/FuzzCanvas.cpp",
       "fuzz/FuzzDrawFunctions.cpp",
       "fuzz/FuzzGradients.cpp",
       "fuzz/FuzzParsePath.cpp",
@@ -1280,6 +1369,7 @@ if (skia_enable_tools) {
     ]
     deps = [
       ":flags",
+      ":gpu_tool_utils",
       ":skia",
       ":tool_utils",
     ]
@@ -1345,7 +1435,6 @@ if (skia_enable_tools) {
         "tools/viewer/sk_app/CommandSet.cpp",
         "tools/viewer/sk_app/GLWindowContext.cpp",
         "tools/viewer/sk_app/Window.cpp",
-        "tools/viewer/sk_app/WindowContext.cpp",
       ]
       libs = []
 
@@ -1357,6 +1446,7 @@ if (skia_enable_tools) {
           "tools/viewer/sk_app/android/main_android.cpp",
           "tools/viewer/sk_app/android/surface_glue_android.cpp",
         ]
+        libs += [ "android" ]
       } else if (is_linux) {
         sources += [
           "tools/viewer/sk_app/unix/GLWindowContext_unix.cpp",
@@ -1385,7 +1475,6 @@ if (skia_enable_tools) {
         if (is_android) {
           sources +=
               [ "tools/viewer/sk_app/android/VulkanWindowContext_android.cpp" ]
-          libs += [ "android" ]
         } else if (is_linux) {
           sources += [ "tools/viewer/sk_app/unix/VulkanWindowContext_unix.cpp" ]
           libs += [ "X11-xcb" ]
@@ -1403,6 +1492,7 @@ if (skia_enable_tools) {
         ":skia",
         ":tool_utils",
         ":views",
+        "//third_party/imgui",
         "//third_party/jsoncpp",
       ]
       if (is_android) {
@@ -1413,7 +1503,7 @@ if (skia_enable_tools) {
     }
   }
 
-  if (is_android) {
+  if (is_android && defined(ndk) && ndk != "") {
     copy("gdbserver") {
       sources = [
         "$ndk/$ndk_gdbserver",
@@ -1422,28 +1512,16 @@ if (skia_enable_tools) {
         "$root_out_dir/gdbserver",
       ]
     }
-    if (ndk_simpleperf != "") {
-      copy("simpleperf") {
-        sources = [
-          "$ndk/$ndk_simpleperf",
-          "$ndk/simpleperf/simpleperf_report.py",
-        ]
-        outputs = [
-          "$root_out_dir/{{source_file_part}}",
-        ]
-      }
-    }
   }
 
   if (skia_enable_gpu) {
     test_app("skslc") {
+      defines = [ "SKSL_STANDALONE" ]
       sources = [
         "src/sksl/SkSLMain.cpp",
       ]
-      deps = [
-        ":flags",
-        ":skia",
-      ]
+      sources += skia_sksl_sources
+      include_dirs = [ "src/sksl" ]
     }
   }
 }