diff --git a/common/graphics/BUILD.gn b/common/graphics/BUILD.gn index 426a8c38074c4..dc561db05a86e 100644 --- a/common/graphics/BUILD.gn +++ b/common/graphics/BUILD.gn @@ -26,9 +26,9 @@ source_set("graphics") { "//flutter/fml", "//flutter/shell/common:base64", "//flutter/shell/version:version", + "//flutter/skia", "//flutter/third_party/rapidjson", "//third_party/boringssl", - "//third_party/skia", ] public_configs = [ "//flutter:config" ] diff --git a/display_list/BUILD.gn b/display_list/BUILD.gn index 0f261510ed17b..6c55f2c835741 100644 --- a/display_list/BUILD.gn +++ b/display_list/BUILD.gn @@ -88,7 +88,7 @@ source_set("display_list") { "//flutter/fml", "//flutter/impeller/runtime_stage", "//flutter/impeller/typographer", - "//third_party/skia", + "//flutter/skia", ] if (!defined(defines)) { @@ -218,10 +218,10 @@ source_set("display_list_benchmarks_source") { "//flutter/display_list/testing:display_list_surface_provider", "//flutter/display_list/testing:display_list_testing", "//flutter/fml", + "//flutter/skia", "//flutter/testing:skia", "//flutter/testing:testing_lib", "//third_party/dart/runtime:libdart_jit", # for tracing - "//third_party/skia", ] } diff --git a/display_list/testing/BUILD.gn b/display_list/testing/BUILD.gn index 1839219b1e8e3..57b0794a8bac6 100644 --- a/display_list/testing/BUILD.gn +++ b/display_list/testing/BUILD.gn @@ -15,8 +15,8 @@ source_set("display_list_testing") { ] deps = [ + "//flutter/skia", "//flutter/testing:testing_lib", - "//third_party/skia", ] public_deps = [ "//flutter/display_list:display_list" ] diff --git a/flow/BUILD.gn b/flow/BUILD.gn index 0e37feb299461..e82db9624925a 100644 --- a/flow/BUILD.gn +++ b/flow/BUILD.gn @@ -96,7 +96,7 @@ source_set("flow") { "//flutter/fml", ] - deps = [ "//third_party/skia" ] + deps = [ "//flutter/skia" ] if (impeller_supports_rendering) { deps += [ @@ -190,11 +190,11 @@ if (enable_unittests) { "//flutter/display_list/testing:display_list_testing", "//flutter/fml", "//flutter/shell/common:base64", + "//flutter/skia", "//flutter/testing:skia", "//flutter/testing:testing_lib", "//third_party/dart/runtime:libdart_jit", # for tracing "//third_party/googletest:gtest", - "//third_party/skia", ] if (!defined(defines)) { diff --git a/flutter_vma/BUILD.gn b/flutter_vma/BUILD.gn index 05a3f5b55cc27..d1785ffc105be 100644 --- a/flutter_vma/BUILD.gn +++ b/flutter_vma/BUILD.gn @@ -32,7 +32,7 @@ source_set("flutter_skia_vma") { public_deps = [ ":flutter_vma", "//flutter/fml", + "//flutter/skia", "//flutter/vulkan/procs", - "//third_party/skia", ] } diff --git a/impeller/display_list/BUILD.gn b/impeller/display_list/BUILD.gn index 24a1980f59aac..daa2dc10168f4 100644 --- a/impeller/display_list/BUILD.gn +++ b/impeller/display_list/BUILD.gn @@ -15,8 +15,8 @@ impeller_component("skia_conversions") { "../geometry", "//flutter/display_list", "//flutter/fml", - "//third_party/skia", - "//third_party/skia/modules/skparagraph", + "//flutter/skia", + "//flutter/skia/modules/skparagraph", ] } @@ -38,7 +38,7 @@ impeller_component("display_list") { "//flutter/display_list", "//flutter/fml", "//flutter/impeller/typographer/backends/skia:typographer_skia_backend", - "//third_party/skia", + "//flutter/skia", ] if (!defined(defines)) { diff --git a/impeller/image/BUILD.gn b/impeller/image/BUILD.gn index 7c9953a983050..f3dc73c662710 100644 --- a/impeller/image/BUILD.gn +++ b/impeller/image/BUILD.gn @@ -36,7 +36,7 @@ impeller_component("image_skia_backend") { deps = [ "//flutter/fml", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/impeller/typographer/backends/skia/BUILD.gn b/impeller/typographer/backends/skia/BUILD.gn index f135edcc17458..778df39e99076 100644 --- a/impeller/typographer/backends/skia/BUILD.gn +++ b/impeller/typographer/backends/skia/BUILD.gn @@ -18,6 +18,6 @@ impeller_component("typographer_skia_backend") { public_deps = [ "//flutter/impeller/typographer", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn index 57f454e04fd51..4004b5ea1d372 100644 --- a/lib/ui/BUILD.gn +++ b/lib/ui/BUILD.gn @@ -163,8 +163,8 @@ source_set("ui") { "//flutter/flow", "//flutter/shell/common:display", "//flutter/shell/common:platform_message_handler", + "//flutter/skia/modules/skparagraph", "//flutter/third_party/txt", - "//third_party/skia/modules/skparagraph", ] deps = [ @@ -176,10 +176,10 @@ source_set("ui") { "//flutter/impeller/runtime_stage", "//flutter/runtime:dart_plugin_registrant", "//flutter/runtime:test_font", + "//flutter/skia", "//flutter/third_party/rapidjson", "//flutter/third_party/tonic", "//third_party/dart/runtime/bin:dart_io_api", - "//third_party/skia", "//third_party/zlib:zlib", ] diff --git a/lib/web_ui/skwasm/BUILD.gn b/lib/web_ui/skwasm/BUILD.gn index 73f93813a0982..b9d13cf406286 100644 --- a/lib/web_ui/skwasm/BUILD.gn +++ b/lib/web_ui/skwasm/BUILD.gn @@ -66,7 +66,7 @@ wasm_lib("skwasm") { } deps = [ - "//third_party/skia", - "//third_party/skia/modules/skparagraph", + "//flutter/skia", + "//flutter/skia/modules/skparagraph", ] } diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn index f3acb0aec81c9..a5d7874fb873e 100644 --- a/runtime/BUILD.gn +++ b/runtime/BUILD.gn @@ -10,7 +10,7 @@ source_set("test_font") { "test_font_data.cc", "test_font_data.h", ] - deps = [ "//third_party/skia" ] + deps = [ "//flutter/skia" ] public_configs = [ "//flutter:config" ] defines = [] if (flutter_runtime_mode == "debug" || current_toolchain == host_toolchain) { @@ -106,11 +106,11 @@ source_set("runtime") { "//flutter/fml", "//flutter/lib/io", "//flutter/shell/common:display", + "//flutter/skia", "//flutter/third_party/tonic", "//flutter/third_party/txt", "//third_party/dart/runtime:dart_api", "//third_party/dart/runtime/bin:dart_io_api", - "//third_party/skia", ] if (flutter_runtime_mode != "release" && !is_fuchsia) { @@ -147,12 +147,12 @@ if (enable_unittests) { "//flutter/common", "//flutter/fml", "//flutter/lib/snapshot", + "//flutter/skia", "//flutter/testing", "//flutter/testing:dart", "//flutter/testing:fixture_test", "//flutter/third_party/tonic", "//third_party/dart/runtime/bin:elf_loader", - "//third_party/skia", ] } diff --git a/shell/common/BUILD.gn b/shell/common/BUILD.gn index fc71a938a736d..ba83f117cbb51 100644 --- a/shell/common/BUILD.gn +++ b/shell/common/BUILD.gn @@ -145,8 +145,8 @@ source_set("common") { "//flutter/runtime", "//flutter/shell/common:base64", "//flutter/shell/profiling", + "//flutter/skia", "//third_party/dart/runtime:dart_api", - "//third_party/skia", ] if (impeller_supports_rendering) { @@ -256,10 +256,10 @@ if (enable_unittests) { "//flutter/assets", "//flutter/common", "//flutter/lib/ui", + "//flutter/skia", "//flutter/testing:dart", "//flutter/testing:fixture_test", "//flutter/third_party/rapidjson", - "//third_party/skia", ] public_configs = [ diff --git a/shell/gpu/BUILD.gn b/shell/gpu/BUILD.gn index 5e5c1cce53a6c..7440ff1fbbb37 100644 --- a/shell/gpu/BUILD.gn +++ b/shell/gpu/BUILD.gn @@ -12,7 +12,7 @@ gpu_common_deps = [ "//flutter/flow", "//flutter/fml", "//flutter/shell/common", - "//third_party/skia", + "//flutter/skia", ] source_set("gpu_surface_software") { diff --git a/shell/platform/android/BUILD.gn b/shell/platform/android/BUILD.gn index 35a1f31e4c4cc..5d8458973481f 100644 --- a/shell/platform/android/BUILD.gn +++ b/shell/platform/android/BUILD.gn @@ -29,7 +29,7 @@ source_set("image_generator") { deps = [ "//flutter/fml", "//flutter/lib/ui:ui", - "//third_party/skia", + "//flutter/skia", ] libs = [ @@ -153,8 +153,8 @@ source_set("flutter_shell_native_src") { "//flutter/shell/platform/android/platform_view_android_delegate", "//flutter/shell/platform/android/surface", "//flutter/shell/platform/android/surface:native_window", + "//flutter/skia", "//flutter/vulkan", - "//third_party/skia", ] public_configs = [ "//flutter:config" ] diff --git a/shell/platform/android/context/BUILD.gn b/shell/platform/android/context/BUILD.gn index a75549cab04d5..1de85c8144376 100644 --- a/shell/platform/android/context/BUILD.gn +++ b/shell/platform/android/context/BUILD.gn @@ -16,7 +16,7 @@ source_set("context") { deps = [ "//flutter/fml", "//flutter/impeller/renderer", - "//third_party/skia", + "//flutter/skia", ] if (shell_enable_vulkan) { diff --git a/shell/platform/android/external_view_embedder/BUILD.gn b/shell/platform/android/external_view_embedder/BUILD.gn index 44bcdaddae280..44ae1106df182 100644 --- a/shell/platform/android/external_view_embedder/BUILD.gn +++ b/shell/platform/android/external_view_embedder/BUILD.gn @@ -22,7 +22,7 @@ source_set("external_view_embedder") { "//flutter/shell/platform/android/context", "//flutter/shell/platform/android/jni", "//flutter/shell/platform/android/surface", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/shell/platform/android/jni/BUILD.gn b/shell/platform/android/jni/BUILD.gn index 7d95b56ad4399..7a05be011d2f7 100644 --- a/shell/platform/android/jni/BUILD.gn +++ b/shell/platform/android/jni/BUILD.gn @@ -18,7 +18,7 @@ source_set("jni") { "//flutter/fml", "//flutter/lib/ui", "//flutter/shell/platform/android/surface:native_window", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/shell/platform/android/platform_view_android_delegate/BUILD.gn b/shell/platform/android/platform_view_android_delegate/BUILD.gn index 89dc76f4f3ec9..f01f6f8da46c1 100644 --- a/shell/platform/android/platform_view_android_delegate/BUILD.gn +++ b/shell/platform/android/platform_view_android_delegate/BUILD.gn @@ -19,7 +19,7 @@ source_set("platform_view_android_delegate") { "//flutter/lib/ui", "//flutter/shell/common", "//flutter/shell/platform/android/jni", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/shell/platform/android/surface/BUILD.gn b/shell/platform/android/surface/BUILD.gn index eb1f832980d3b..82bb9a260c30a 100644 --- a/shell/platform/android/surface/BUILD.gn +++ b/shell/platform/android/surface/BUILD.gn @@ -21,7 +21,7 @@ source_set("surface") { "//flutter/shell/common", "//flutter/shell/platform/android/context", "//flutter/shell/platform/android/jni", - "//third_party/skia", + "//flutter/skia", ] } @@ -35,7 +35,7 @@ source_set("native_window") { deps = [ "//flutter/fml", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/shell/platform/darwin/graphics/BUILD.gn b/shell/platform/darwin/graphics/BUILD.gn index acb55214b3507..88ca95c51b593 100644 --- a/shell/platform/darwin/graphics/BUILD.gn +++ b/shell/platform/darwin/graphics/BUILD.gn @@ -36,7 +36,7 @@ source_set("graphics") { frameworks = [ "CoreVideo.framework" ] - public_deps = [ "//third_party/skia" ] + public_deps = [ "//flutter/skia" ] public_configs = [ "//flutter:config" ] } diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index cdb9e0d41e394..8e8521ef795c5 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -193,8 +193,8 @@ source_set("flutter_framework_source") { "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/profiling:profiling", + "//flutter/skia", "//flutter/third_party/spring_animation", - "//third_party/skia", ] public_configs = [ @@ -255,11 +255,11 @@ source_set("ios_test_flutter_mrc") { "//flutter/shell/common:common", "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", + "//flutter/skia", "//flutter/third_party/rapidjson", "//flutter/third_party/tonic", "//flutter/third_party/txt", "//third_party/ocmock:ocmock_shared", - "//third_party/skia", ] if (shell_enable_vulkan) { @@ -327,12 +327,12 @@ shared_library("ios_test_flutter") { "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/platform/embedder:embedder_test_utils", + "//flutter/skia", "//flutter/third_party/rapidjson", "//flutter/third_party/spring_animation", "//flutter/third_party/tonic", "//flutter/third_party/txt", "//third_party/ocmock:ocmock_shared", - "//third_party/skia", ] public_configs = [ ":ios_gpu_configuration_config", diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index ea29942f406f8..4cdbf646c7551 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -125,7 +125,7 @@ source_set("flutter_framework_source") { "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/darwin/graphics:graphics", "//flutter/shell/platform/embedder:embedder_as_internal_library", - "//third_party/skia", + "//flutter/skia", ] public_configs = [ "//flutter:config" ] diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index 829beb8d925bf..cf2616564049f 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -108,10 +108,10 @@ template("embedder_source_set") { "//flutter/lib/ui", "//flutter/runtime:libdart", "//flutter/shell/common", + "//flutter/skia", "//flutter/third_party/tonic", "//third_party/dart/runtime/bin:dart_io_api", "//third_party/dart/runtime/bin:elf_loader", - "//third_party/skia", ] if (embedder_enable_gl) { @@ -288,12 +288,12 @@ if (enable_unittests) { "//flutter/lib/snapshot", "//flutter/lib/ui", "//flutter/runtime", + "//flutter/skia", "//flutter/testing", "//flutter/testing:dart", "//flutter/testing:skia", "//flutter/third_party/tonic", "//third_party/dart/runtime/bin:elf_loader", - "//third_party/skia", ] if (test_enable_gl) { @@ -410,7 +410,7 @@ if (enable_unittests) { #"//flutter/testing:skia", #"//flutter/third_party/tonic", #"//third_party/dart/runtime/bin:elf_loader", - #"//third_party/skia", + #"//flutter/skia", ] } } diff --git a/shell/testing/BUILD.gn b/shell/testing/BUILD.gn index 8f4572310c519..dd51d0a077604 100644 --- a/shell/testing/BUILD.gn +++ b/shell/testing/BUILD.gn @@ -40,10 +40,10 @@ executable("testing") { "//flutter/lib/snapshot", "//flutter/shell/common", "//flutter/shell/gpu:gpu_surface_software", + "//flutter/skia", "//flutter/third_party/tonic", "//third_party/dart/runtime:libdart_jit", "//third_party/dart/runtime/bin:dart_io_api", - "//third_party/skia", ] if (impeller_supports_rendering) { diff --git a/skia/BUILD.gn b/skia/BUILD.gn new file mode 100644 index 0000000000000..d0f8f1703ca9f --- /dev/null +++ b/skia/BUILD.gn @@ -0,0 +1,825 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +_skia_root = "//third_party/skia" + +import("$_skia_root/gn/shared_sources.gni") +import("$_skia_root/gn/skia.gni") +import("$_skia_root/gn/toolchain/wasm.gni") +import("flutter_defines.gni") + +if (is_fuchsia) { + import("//build/fuchsia/sdk.gni") +} + +# Skia public API, generally provided by :skia. +config("skia_public") { + include_dirs = [ "$_skia_root" ] + + defines = [] + cflags_objcc = [] + if (is_fuchsia || is_linux) { + defines += [ "SK_R32_SHIFT=16" ] + } + if (skia_enable_flutter_defines) { + defines += flutter_defines + } + + # TODO(zra): Try using this. + if (skia_enable_optimize_size) { + defines += [ + "SK_ENABLE_OPTIMIZE_SIZE", + "SK_FORCE_AAA", + ] + } + if (skia_enable_precompile) { + defines += [ "SK_ENABLE_PRECOMPILE" ] + } + if (is_wasm) { + defines += wasm_defines + } + if (skia_gl_standard == "gles") { + defines += [ "SK_ASSUME_GL_ES=1" ] + } else if (skia_gl_standard == "gl") { + defines += [ "SK_ASSUME_GL=1" ] + } else if (skia_gl_standard == "webgl") { + defines += [ + "SK_ASSUME_WEBGL=1", + "SK_USE_WEBGL", + ] + } + if (skia_enable_ganesh) { + defines += [ "SK_GANESH" ] + } + + # TODO(zra): Try turning this off. + if (skia_use_perfetto) { + defines += [ "SK_USE_PERFETTO" ] + } + + # Some older versions of the Clang toolchain change the visibility of + # symbols decorated with API_AVAILABLE macro to be visible. Users of such + # toolchains suppress the use of this macro till toolchain updates are made. + if (is_mac || is_ios) { + cflags_objcc += [ "-Wno-unguarded-availability" ] + } +} + +# Skia internal APIs, used by Skia itself and a few test tools. +config("skia_private") { + visibility = [ "./*" ] + + defines = [ "SK_GAMMA_APPLY_TO_A8" ] + if (skia_use_fixed_gamma_text) { + defines += [ + "SK_GAMMA_EXPONENT=1.4", + "SK_GAMMA_CONTRAST=0.0", + ] + } + libs = [] + lib_dirs = [] + if (skia_use_vma) { + defines += [ "SK_USE_VMA" ] + } +} + +# Any code that's linked into Skia-the-library should use this config +# via += skia_library_configs. +config("skia_library") { + visibility = [ "./*" ] + defines = [ "SKIA_IMPLEMENTATION=1" ] +} + +skia_library_configs = [ + ":skia_public", + ":skia_private", + ":skia_library", +] + +# Use for CPU-specific Skia code that needs particular compiler flags. +template("opts") { + if (invoker.enabled) { + skia_source_set(target_name) { + visibility = [ ":*" ] + check_includes = false + configs = skia_library_configs + forward_variables_from(invoker, "*") + if (defined(invoker.configs)) { + configs += invoker.configs + } + } + } else { + # If not enabled, a phony empty target that swallows all otherwise unused + # variables. + skia_source_set(target_name) { + visibility = [ ":*" ] + check_includes = false + forward_variables_from(invoker, + "*", + [ + "sources", + "cflags", + ]) + } + } +} + +is_x86 = current_cpu == "x64" || current_cpu == "x86" + +opts("hsw") { + enabled = is_x86 + sources = skia_opts.hsw_sources + if (is_win) { + cflags = [ "/arch:AVX2" ] + } else { + cflags = [ "-march=haswell" ] + } +} + +# Any feature of Skia that requires third-party code should be optional and use +# this template. +template("optional") { + if (invoker.enabled) { + config(target_name + "_public") { + if (defined(invoker.public_defines)) { + defines = invoker.public_defines + } + if (defined(invoker.public_configs)) { + configs = invoker.public_configs + } + if (defined(invoker.public_include_dirs)) { + include_dirs = invoker.public_include_dirs + } + } + skia_source_set(target_name) { + visibility = [ ":*" ] + + # Opted out of check_includes, due to (logically) being part of skia. + check_includes = false + configs = skia_library_configs + + # "*" clobbers the current scope; append to existing configs + forward_variables_from(invoker, + "*", + [ + "configs", + "public_defines", + "sources_for_tests", + "sources_when_disabled", + ]) + if (defined(invoker.configs)) { + configs += invoker.configs + } + all_dependent_configs = [ ":" + target_name + "_public" ] + } + } else { + skia_source_set(target_name) { + visibility = [ ":*" ] + configs = skia_library_configs + + # "*" clobbers the current scope; append to existing configs + forward_variables_from(invoker, + "*", + [ + "configs", + "public", + "public_defines", + "public_deps", + "deps", + "libs", + "frameworks", + "sources", + "sources_for_tests", + "sources_when_disabled", + ]) + if (defined(invoker.configs)) { + configs += invoker.configs + } + if (defined(invoker.sources_when_disabled)) { + sources = invoker.sources_when_disabled + } + } + if (defined(invoker.sources_for_tests)) { + skia_source_set(target_name + "_tests") { + visibility = [ ":*" ] + } + } + } +} + +group("fontmgr_factory") { + public_deps = [ skia_fontmgr_factory ] +} + +optional("fontmgr_empty_factory") { + enabled = true + sources = [ "$_skia_root/src/ports/SkFontMgr_empty_factory.cpp" ] +} + +optional("fontmgr_android") { + enabled = skia_enable_fontmgr_android + + deps = [ + ":typeface_freetype", + "//third_party/expat", + ] + public = [ "$_skia_root/include/ports/SkFontMgr_android.h" ] + sources = [ + "$_skia_root/src/ports/SkFontMgr_android.cpp", + "$_skia_root/src/ports/SkFontMgr_android_parser.cpp", + "$_skia_root/src/ports/SkFontMgr_android_parser.h", + ] +} +optional("fontmgr_android_factory") { + enabled = skia_enable_fontmgr_android + deps = [ ":fontmgr_android" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_android_factory.cpp" ] +} + +optional("fontmgr_custom") { + enabled = + skia_enable_fontmgr_custom_directory || + skia_enable_fontmgr_custom_embedded || skia_enable_fontmgr_custom_empty + + deps = [ ":typeface_freetype" ] + public = [ "$_skia_root/src/ports/SkFontMgr_custom.h" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom.cpp" ] +} + +optional("fontmgr_custom_directory") { + enabled = skia_enable_fontmgr_custom_directory + + deps = [ + ":fontmgr_custom", + ":typeface_freetype", + ] + public = [ "$_skia_root/include/ports/SkFontMgr_directory.h" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom_directory.cpp" ] +} +optional("fontmgr_custom_directory_factory") { + enabled = skia_enable_fontmgr_custom_directory + deps = [ ":fontmgr_custom_directory" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom_directory_factory.cpp" ] +} + +optional("fontmgr_custom_embedded") { + enabled = skia_enable_fontmgr_custom_embedded + + deps = [ + ":fontmgr_custom", + ":typeface_freetype", + ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom_embedded.cpp" ] +} +optional("fontmgr_custom_embedded_factory") { + enabled = skia_enable_fontmgr_custom_embedded + deps = [ ":fontmgr_custom_embedded" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom_embedded_factory.cpp" ] +} + +optional("fontmgr_custom_empty") { + enabled = skia_enable_fontmgr_custom_empty + + deps = [ + ":fontmgr_custom", + ":typeface_freetype", + ] + public = [ "$_skia_root/include/ports/SkFontMgr_empty.h" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom_empty.cpp" ] +} +optional("fontmgr_custom_empty_factory") { + enabled = skia_enable_fontmgr_custom_empty + deps = [ ":fontmgr_custom_empty" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_custom_empty_factory.cpp" ] +} + +optional("fontmgr_fontconfig") { + enabled = skia_enable_fontmgr_fontconfig + + # The public header includes fontconfig.h and uses FcConfig* + public_deps = [ "//third_party:fontconfig" ] + public = [ "$_skia_root/include/ports/SkFontMgr_fontconfig.h" ] + deps = [ ":typeface_freetype" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_fontconfig.cpp" ] +} +optional("fontmgr_fontconfig_factory") { + enabled = skia_enable_fontmgr_fontconfig + deps = [ ":fontmgr_fontconfig" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_fontconfig_factory.cpp" ] +} + +optional("fontmgr_FontConfigInterface") { + enabled = skia_enable_fontmgr_FontConfigInterface + + deps = [ + ":typeface_freetype", + "//third_party:fontconfig", + ] + public = [ + "$_skia_root/include/ports/SkFontConfigInterface.h", + "$_skia_root/include/ports/SkFontMgr_FontConfigInterface.h", + ] + sources = [ + "$_skia_root/src/ports/SkFontConfigInterface.cpp", + "$_skia_root/src/ports/SkFontConfigInterface_direct.cpp", + "$_skia_root/src/ports/SkFontConfigInterface_direct_factory.cpp", + "$_skia_root/src/ports/SkFontConfigTypeface.h", + "$_skia_root/src/ports/SkFontMgr_FontConfigInterface.cpp", + ] +} +optional("fontmgr_FontConfigInterface_factory") { + enabled = skia_enable_fontmgr_FontConfigInterface + deps = [ ":fontmgr_FontConfigInterface" ] + sources = + [ "$_skia_root/src/ports/SkFontMgr_FontConfigInterface_factory.cpp" ] +} + +optional("fontmgr_fuchsia") { + enabled = skia_enable_fontmgr_fuchsia + + deps = [] + + if (is_fuchsia && using_fuchsia_sdk) { + deps += [ "//build/fuchsia/fidl:fuchsia.fonts" ] + } else { + deps = [ "//sdk/fidl/fuchsia.fonts" ] + } + public = [ "$_skia_root/src/ports/SkFontMgr_fuchsia.h" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_fuchsia.cpp" ] +} + +optional("fontmgr_mac_ct") { + enabled = skia_use_fonthost_mac + + public_defines = [ "SK_TYPEFACE_FACTORY_CORETEXT" ] + public = [ + "$_skia_root/include/ports/SkFontMgr_mac_ct.h", + "$_skia_root/include/ports/SkTypeface_mac.h", + ] + sources = [ + "$_skia_root/src/ports/SkFontMgr_mac_ct.cpp", + "$_skia_root/src/ports/SkScalerContext_mac_ct.cpp", + "$_skia_root/src/ports/SkScalerContext_mac_ct.h", + "$_skia_root/src/ports/SkTypeface_mac_ct.cpp", + "$_skia_root/src/ports/SkTypeface_mac_ct.h", + ] + + if (is_mac) { + frameworks = [ + # AppKit symbols NSFontWeightXXX may be dlsym'ed. + "AppKit.framework", + "ApplicationServices.framework", + ] + } + + if (is_ios) { + frameworks = [ + "CoreFoundation.framework", + "CoreGraphics.framework", + "CoreText.framework", + + # UIKit symbols UIFontWeightXXX may be dlsym'ed. + "UIKit.framework", + ] + } +} +optional("fontmgr_mac_ct_factory") { + enabled = skia_use_fonthost_mac + deps = [ ":fontmgr_mac_ct" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_mac_ct_factory.cpp" ] +} + +optional("fontmgr_win") { + enabled = skia_enable_fontmgr_win + + public_defines = [ "SK_TYPEFACE_FACTORY_DIRECTWRITE" ] + public = [ "$_skia_root/include/ports/SkTypeface_win.h" ] + sources = [ + "$_skia_root/include/ports/SkFontMgr_indirect.h", + "$_skia_root/include/ports/SkRemotableFontMgr.h", + "$_skia_root/src/fonts/SkFontMgr_indirect.cpp", + "$_skia_root/src/ports/SkFontMgr_win_dw.cpp", + "$_skia_root/src/ports/SkScalerContext_win_dw.cpp", + "$_skia_root/src/ports/SkScalerContext_win_dw.h", + "$_skia_root/src/ports/SkTypeface_win_dw.cpp", + "$_skia_root/src/ports/SkTypeface_win_dw.h", + ] + if (skia_dwritecore_sdk != "") { + defines = [ "DWRITE_CORE" ] + if (is_win && is_clang) { + # Clang complains about these headers, so mark them as system. These + # headers are hiding SDK headers of the same name, which are also + # included as system headers, so these need to go first in the cflags + # "includes" before the SDK. gn appends configs in the order listed, + # so these flags will be first. + cflags = [ + "-imsvc", + "${skia_dwritecore_sdk}/include", + ] + } else { + include_dirs = [ "${skia_dwritecore_sdk}/include" ] + } + } +} +optional("fontmgr_win_factory") { + enabled = skia_enable_fontmgr_win + deps = [ ":fontmgr_win" ] + sources = [ "$_skia_root/src/ports/SkFontMgr_win_dw_factory.cpp" ] +} + +optional("fontmgr_win_gdi") { + enabled = skia_enable_fontmgr_win_gdi + + public = [ "$_skia_root/include/ports/SkTypeface_win.h" ] + sources = [ "$_skia_root/src/ports/SkFontHost_win.cpp" ] + libs = [ "Gdi32.lib" ] +} + +optional("gpu_shared") { + enabled = skia_enable_ganesh + + deps = [] + libs = [] + public_defines = [] + public_deps = [] + frameworks = [] + + sources = skia_shared_gpu_sources + skia_sksl_gpu_sources + + if (skia_use_vulkan) { + public_defines += [ "SK_VULKAN" ] + sources += skia_shared_vk_sources + if (skia_enable_vulkan_debug_layers) { + public_defines += [ "SK_ENABLE_VK_LAYERS" ] + } + if (skia_use_vma) { + public_deps += [ "$_skia_root/src/gpu/vk/vulkanmemoryallocator" ] + } + } + + if (skia_use_metal) { + public_defines += [ "SK_METAL" ] + sources += skia_shared_mtl_sources + } +} + +optional("gpu") { + enabled = skia_enable_ganesh + deps = [ ":gpu_shared" ] + public_defines = [] + public_configs = [] + public_deps = [] + + public = skia_gpu_public + sources = skia_ganesh_private + + libs = [] + frameworks = [] + + if (is_android) { + sources += skia_gpu_android_private + } + + if (skia_use_gl) { + public_defines += [ "SK_GL" ] + if (is_android) { + sources += [ + "$_skia_root/src/gpu/ganesh/gl/egl/GrGLMakeEGLInterface.cpp", + "$_skia_root/src/gpu/ganesh/gl/egl/GrGLMakeNativeInterface_egl.cpp", + ] + sources += skia_android_gl_sources + + # this lib is required to link against AHardwareBuffer + if (defined(ndk_api) && ndk_api >= 26) { + libs += [ "android" ] + } + } else if (skia_use_webgl) { + sources += [ + "$_skia_root/src/gpu/ganesh/gl/webgl/GrGLMakeNativeInterface_webgl.cpp", + ] + } else if (is_linux && skia_use_x11) { + sources += [ + "$_skia_root/src/gpu/ganesh/gl/glx/GrGLMakeGLXInterface.cpp", + "$_skia_root/src/gpu/ganesh/gl/glx/GrGLMakeNativeInterface_glx.cpp", + ] + libs += [ "GL" ] + } else if (is_win) { + sources += [ + "$_skia_root/src/gpu/ganesh/gl/win/GrGLMakeNativeInterface_win.cpp", + ] + if (target_cpu != "arm64") { + libs += [ "OpenGL32.lib" ] + } + } else { + sources += + [ "$_skia_root/src/gpu/ganesh/gl/GrGLMakeNativeInterface_none.cpp" ] + } + public += skia_gpu_gl_public + sources += skia_gpu_gl_private + } + + if (skia_use_vulkan) { + public += skia_gpu_vk_public + sources += skia_gpu_vk_private + if (is_fuchsia) { + if (using_fuchsia_sdk) { + public_deps += [ "$fuchsia_sdk_root/pkg:vulkan" ] + } else { + public_deps += [ "$_skia_root/src/graphics/lib/vulkan" ] + } + } + if (is_android) { + sources += skia_gpu_vk_android_private + } + } + + if (is_android && (skia_use_gl || skia_use_vulkan)) { + # this lib is required to link against AHardwareBuffer + if (defined(ndk_api) && ndk_api >= 26) { + libs += [ "android" ] + } + } + + cflags_objcc = [] + if (skia_use_metal) { + public_defines += [ "SK_METAL" ] + public += skia_gpu_metal_public + sources += skia_gpu_metal_private + sources += skia_gpu_metal_cpp + frameworks += [ "Metal.framework" ] + frameworks += [ "Foundation.framework" ] + if (is_ios) { + frameworks += [ "UIKit.framework" ] + } + cflags_objcc += [ "-fobjc-arc" ] + } + + if (is_debug) { + public_defines += [ "SK_ENABLE_DUMP_GPU" ] + } +} + +optional("jpeg_decode") { + enabled = skia_use_libjpeg_turbo_decode + public_defines = [ "SK_CODEC_DECODES_JPEG" ] + + deps = [ "//third_party/libjpeg-turbo:libjpeg" ] + sources = [ + "$_skia_root/src/codec/SkJpegCodec.cpp", + "$_skia_root/src/codec/SkJpegDecoderMgr.cpp", + "$_skia_root/src/codec/SkJpegSourceMgr.cpp", + "$_skia_root/src/codec/SkJpegUtility.cpp", + ] +} + +optional("jpeg_encode") { + enabled = skia_use_libjpeg_turbo_encode && !skia_use_ndk_images + + deps = [ "//third_party/libjpeg-turbo:libjpeg" ] + public = skia_encode_jpeg_public + sources = skia_encode_jpeg_srcs +} + +optional("ndk_images") { + enabled = skia_use_ndk_images + public_defines = [ "SK_ENABLE_NDK_IMAGES" ] + sources = [ + "$_skia_root/src/ports/SkImageEncoder_NDK.cpp", + "$_skia_root/src/ports/SkImageGeneratorNDK.cpp", + "$_skia_root/src/ports/SkNDKConversions.cpp", + ] + libs = [ "jnigraphics" ] +} + +optional("xps") { + enabled = skia_use_xps && is_win + public_defines = [ "SK_SUPPORT_XPS" ] + public = skia_xps_public + sources = skia_xps_sources +} + +optional("png_decode") { + enabled = skia_use_libpng_decode + public_defines = [ "SK_CODEC_DECODES_PNG" ] + + deps = [ "//third_party/libpng" ] + sources = [ + "$_skia_root/src/codec/SkIcoCodec.cpp", + "$_skia_root/src/codec/SkPngCodec.cpp", + ] +} + +optional("png_encode") { + enabled = skia_use_libpng_encode && !skia_use_ndk_images + public = skia_encode_png_public + + deps = [ "//third_party/libpng" ] + sources = skia_encode_png_srcs +} + +optional("typeface_freetype") { + enabled = skia_use_freetype + + public_defines = [ "SK_TYPEFACE_FACTORY_FREETYPE" ] + deps = [ "//third_party/freetype2" ] + sources = [ + "$_skia_root/src/ports/SkFontHost_FreeType.cpp", + "$_skia_root/src/ports/SkFontHost_FreeType_common.cpp", + "$_skia_root/src/ports/SkFontHost_FreeType_common.h", + ] +} + +optional("webp_decode") { + enabled = skia_use_libwebp_decode + public_defines = [ "SK_CODEC_DECODES_WEBP" ] + + deps = [ "//third_party/libwebp" ] + sources = [ "$_skia_root/src/codec/SkWebpCodec.cpp" ] +} + +optional("webp_encode") { + enabled = skia_use_libwebp_encode && !skia_use_ndk_images + public = skia_encode_webp_public + + deps = [ "//third_party/libwebp" ] + sources = skia_encode_webp_srcs +} + +optional("wuffs") { + enabled = skia_use_wuffs + public_defines = [ "SK_HAS_WUFFS_LIBRARY" ] + + deps = [ "//third_party/wuffs" ] + sources = [ "$_skia_root/src/codec/SkWuffsCodec.cpp" ] +} + +optional("xml") { + enabled = skia_use_expat || skia_use_jpeg_gainmaps + public_defines = [ "SK_XML" ] + + deps = [ "//third_party/expat" ] + sources = skia_xml_sources + skia_codec_xmp + [ + "$_skia_root/src/svg/SkSVGCanvas.cpp", + "$_skia_root/src/svg/SkSVGDevice.cpp", + ] +} + +import("$_skia_root/gn/codec.gni") + +skia_component("skia") { + public_configs = [ ":skia_public" ] + configs = skia_library_configs + + # Opted out of check_includes, due to (logically) being part of skia. + check_includes = false + + public_deps = [ + ":fontmgr_FontConfigInterface", + ":fontmgr_android", + ":fontmgr_custom_directory", + ":fontmgr_custom_embedded", + ":fontmgr_custom_empty", + ":fontmgr_fontconfig", + ":fontmgr_fuchsia", + ":fontmgr_mac_ct", + ":fontmgr_win", + ":fontmgr_win_gdi", + ":gpu", + ":jpeg_encode", + ":png_encode", + ":webp_encode", + ":xps", + ] + + deps = [ + ":fontmgr_factory", + ":hsw", + ":jpeg_decode", + ":ndk_images", + ":png_decode", + ":webp_decode", + ":wuffs", + ":xml", + "modules/skcms", + ] + + public = skia_core_public + public += skia_codec_public + public += skia_utils_public + public += skia_effects_public + public += skia_effects_imagefilter_public + + sources = [] + sources += skia_core_sources + sources += skia_utils_private + sources += skia_utils_chromium + sources += skia_effects_sources + sources += skia_colorfilters_sources + sources += skia_effects_imagefilter_sources + sources += skia_codec_core + sources += skia_codec_decode_bmp + sources += skia_encode_srcs + sources += skia_sksl_sources + sources += [ + "$_skia_root/src/android/SkAndroidFrameworkUtils.cpp", + "$_skia_root/src/android/SkAnimatedImage.cpp", + "$_skia_root/src/codec/SkAndroidCodec.cpp", + "$_skia_root/src/codec/SkAndroidCodecAdapter.cpp", + "$_skia_root/src/codec/SkEncodedInfo.cpp", + "$_skia_root/src/codec/SkParseEncodedOrigin.cpp", + "$_skia_root/src/codec/SkSampledCodec.cpp", + "$_skia_root/src/ports/SkDiscardableMemory_none.cpp", + "$_skia_root/src/ports/SkGlobalInitialization_default.cpp", + "$_skia_root/src/ports/SkMemory_malloc.cpp", + "$_skia_root/src/ports/SkOSFile_stdio.cpp", + "$_skia_root/src/sfnt/SkOTTable_name.cpp", + "$_skia_root/src/sfnt/SkOTUtils.cpp", + ] + + defines = [] + libs = [] + + if (skia_use_no_jpeg_encode) { + sources += skia_no_encode_jpeg_srcs + } + if (skia_use_no_png_encode) { + sources += skia_no_encode_png_srcs + } + if (skia_use_no_webp_encode) { + sources += skia_no_encode_webp_srcs + } + + if (is_win) { + sources += [ + "$_skia_root/src/ports/SkDebug_win.cpp", + "$_skia_root/src/ports/SkImageGeneratorWIC.cpp", + "$_skia_root/src/ports/SkOSFile_win.cpp", + "$_skia_root/src/ports/SkOSLibrary_win.cpp", + ] + libs += [ + "Ole32.lib", + "OleAut32.lib", + ] + + if (!skia_enable_winuwp) { + libs += [ + "FontSub.lib", + "User32.lib", + "Usp10.lib", + ] + } + } else { + sources += [ + "$_skia_root/src/ports/SkOSFile_posix.cpp", + "$_skia_root/src/ports/SkOSLibrary_posix.cpp", + ] + libs += [ "dl" ] + } + + if (is_android) { + deps += [ "//third_party/expat" ] + sources += [ "$_skia_root/src/ports/SkDebug_android.cpp" ] + libs += [ + "EGL", + "GLESv2", + "log", + ] + } + + if (is_linux || is_wasm) { + sources += [ "$_skia_root/src/ports/SkDebug_stdio.cpp" ] + if (skia_use_egl) { + libs += [ "GLESv2" ] + } + } + + if (is_mac) { + public += [ "$_skia_root/include/ports/SkCFObject.h" ] + sources += [ + "$_skia_root/src/ports/SkDebug_stdio.cpp", + "$_skia_root/src/ports/SkImageGeneratorCG.cpp", + ] + frameworks = [ + "ApplicationServices.framework", + "OpenGL.framework", + ] + } + + if (is_ios) { + public += [ "$_skia_root/include/ports/SkCFObject.h" ] + sources += [ + "$_skia_root/src/ports/SkDebug_stdio.cpp", + "$_skia_root/src/ports/SkImageGeneratorCG.cpp", + ] + frameworks = [ + "CoreFoundation.framework", + "ImageIO.framework", + "MobileCoreServices.framework", + ] + } + + if (is_fuchsia) { + sources += [ "$_skia_root/src/ports/SkDebug_stdio.cpp" ] + } +} diff --git a/skia/flutter_defines.gni b/skia/flutter_defines.gni new file mode 100644 index 0000000000000..877a8503c5475 --- /dev/null +++ b/skia/flutter_defines.gni @@ -0,0 +1,30 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +flutter_defines = [ + # Flutter always wants this https://github.com/flutter/flutter/issues/11402 + "SK_ENABLE_DUMP_GPU", + + # Remove software rasterizers to save some code size. + "SK_FORCE_AAA", + + # Staging + "SK_LEGACY_IGNORE_DRAW_VERTICES_BLEND_WITH_NO_SHADER", + "SK_DISABLE_LEGACY_GRDIRECTCONTEXT_BOOLS", + "SK_DISABLE_LEGACY_GRDIRECTCONTEXT_FLUSH", + "SK_RESOLVE_FILTERS_BEFORE_RESTORE", + + # Fast low-precision software rendering isn't a priority for Flutter. + "SK_DISABLE_LEGACY_SHADERCONTEXT", + "SK_DISABLE_LOWP_RASTER_PIPELINE", + "SK_FORCE_RASTER_PIPELINE_BLITTER", + + # When running Metal, ensure that command buffers are scheduled before + # returning from submit. + "SK_METAL_WAIT_UNTIL_SCHEDULED", +] + +if (!is_fuchsia) { + flutter_defines += [ "SK_DISABLE_EFFECT_DESERIALIZATION" ] +} diff --git a/skia/modules/canvaskit/BUILD.gn b/skia/modules/canvaskit/BUILD.gn new file mode 100644 index 0000000000000..4632c7bb5021d --- /dev/null +++ b/skia/modules/canvaskit/BUILD.gn @@ -0,0 +1,222 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +_skia_root = "//third_party/skia" + +import("$_skia_root/gn/skia.gni") +import("$_skia_root/gn/toolchain/wasm.gni") +import("$_skia_root/modules/canvaskit/canvaskit.gni") + +# Defines a WASM library target. +template("canvaskit_wasm_lib") { + _vars_to_forward = [ + "cflags", + "check_includes", + "ldflags", + "defines", + "deps", + "includes", + "sources", + "include_dirs", + "public_configs", + "testonly", + "visibility", + ] + + _lib_name = target_name + + executable("${_lib_name}_js") { + forward_variables_from(invoker, _vars_to_forward) + output_extension = "js" + output_name = "${_lib_name}" + } + + group("$_lib_name") { + public_deps = [ ":${_lib_name}_js" ] + } +} + +canvaskit_wasm_lib("canvaskit") { + # Opted out of check_includes, due to (logically) being part of skia. + check_includes = false + deps = [ "../..:skia" ] + if (skia_canvaskit_enable_paragraph) { + deps += [ + "../../modules/skparagraph:skparagraph", + "../../modules/skunicode:skunicode", + ] + } + + sources = [ + "$_skia_root/modules/canvaskit/WasmCommon.h", + "$_skia_root/modules/canvaskit/canvaskit_bindings.cpp", + ] + if (skia_canvaskit_enable_paragraph) { + sources += [ + "$_skia_root/modules/canvaskit/paragraph_bindings.cpp", + "$_skia_root/modules/canvaskit/paragraph_bindings_gen.cpp", + ] + } + + ldflags = [] + if (is_debug) { + ldflags += [ + "-O0", + "-sDEMANGLE_SUPPORT=1", + "-sASSERTIONS=1", + "-sGL_ASSERTIONS=1", + "-g3", + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/debug.js"), + ] + } else { + externs_path = rebase_path("$_skia_root/modules/canvaskit/externs.js") + ldflags += [ + "-Oz", + "--closure=1", + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/release.js"), + "--closure-args=--externs=$externs_path", + ] + } + if (skia_canvaskit_profile_build) { + ldflags += [ + "--profiling-funcs", + "--closure=0", + ] + } + ldflags += [ "-fno-rtti" ] + + if (skia_canvaskit_enable_webgl) { + ldflags += [ + "-lGL", + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/cpu.js"), + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/webgl.js"), + "-sUSE_WEBGL2=1", + "-sMAX_WEBGL_VERSION=2", + ] + } else { + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/cpu.js"), + "-sUSE_WEBGL2=0", + ] + } + + ldflags += [ + "-std=c++17", + "--bind", + "--no-entry", + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/preamble.js"), + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/color.js"), + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/memory.js"), + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/util.js"), + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/interface.js"), + ] + + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/paragraph.js"), + ] + + if (skia_canvaskit_enable_pathops) { + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/pathops.js"), + ] + } + + if (skia_canvaskit_enable_font) { + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/font.js"), + ] + } + + if (skia_canvaskit_enable_skp_serialization) { + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/skp.js"), + ] + } + + if (skia_canvaskit_enable_rt_shader) { + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/rt_shader.js"), + ] + } + + ldflags += [ + "--pre-js", + rebase_path("$_skia_root/modules/canvaskit/postamble.js"), + "-sALLOW_MEMORY_GROWTH", + "-sDISABLE_EXCEPTION_CATCHING", + "-sNODEJS_CATCH_EXIT=0", + "-sDYNAMIC_EXECUTION=0", + "-sEXPORT_NAME=CanvasKitInit", + "-sEXPORTED_FUNCTIONS=[_malloc,_free]", + "-sFORCE_FILESYSTEM=0", + "-sFILESYSTEM=0", + "-sMODULARIZE", + "-sNO_EXIT_RUNTIME=1", + "-sINITIAL_MEMORY=128MB", + "-sWASM", + "-sSTRICT=1", + ] + + defines = [] + if (is_debug) { + defines += [ "SK_DEBUG" ] + } else { + defines += [ "SK_RELEASE" ] + } + if (!is_debug && !skia_canvaskit_force_tracing) { + defines += [ "SK_DISABLE_TRACING" ] + } + defines += [ + "SK_FORCE_AAA", + "SK_FORCE_8_BYTE_ALIGNMENT", + "EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0", + "SK_SHAPER_HARFBUZZ_AVAILABLE", + ] + if (skia_canvaskit_enable_paragraph) { + defines += [ "CK_INCLUDE_PARAGRAPH" ] + } + if (skia_canvaskit_enable_skp_serialization) { + defines += [ "CK_SERIALIZE_SKP" ] + } + if (skia_enable_ganesh) { + defines += [ + "SK_GANESH", + "SK_DISABLE_LEGACY_SHADERCONTEXT", + ] + if (skia_canvaskit_enable_webgl) { + defines += [ + "SK_GL", + "CK_ENABLE_WEBGL", + ] + } + } + + if (skia_canvaskit_enable_pathops) { + defines += [ "CK_INCLUDE_PATHOPS" ] + } + if (skia_canvaskit_enable_rt_shader) { + defines += [ "CK_INCLUDE_RUNTIME_EFFECT" ] + } + if (!skia_canvaskit_enable_alias_font) { + defines += [ "CK_NO_ALIAS_FONT" ] + } + if (!skia_canvaskit_enable_font) { + defines += [ "CK_NO_FONTS" ] + } +} diff --git a/skia/modules/skcms/BUILD.gn b/skia/modules/skcms/BUILD.gn new file mode 100644 index 0000000000000..1b72952a288bc --- /dev/null +++ b/skia/modules/skcms/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +_skia_root = "//third_party/skia" + +import("$_skia_root/modules/skcms/skcms.gni") + +static_library("skcms") { + cflags = [] + if (!is_win || is_clang) { + cflags += [ "-std=c11" ] + } + + public = skcms_public_headers + sources = skcms_sources +} diff --git a/skia/modules/skparagraph/BUILD.gn b/skia/modules/skparagraph/BUILD.gn new file mode 100644 index 0000000000000..3acf580c5e847 --- /dev/null +++ b/skia/modules/skparagraph/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +_skia_root = "//third_party/skia" + +import("$_skia_root/gn/skia.gni") +import("$_skia_root/modules/skparagraph/skparagraph.gni") +import("$_skia_root/modules/skshaper/skshaper.gni") +import("$_skia_root/modules/skunicode/skunicode.gni") + +declare_args() { + skia_enable_skparagraph = true + paragraph_gms_enabled = true + paragraph_tests_enabled = true + paragraph_bench_enabled = false +} + +config("public_config") { + defines = [ "SK_ENABLE_PARAGRAPH" ] + include_dirs = [ + "$_skia_root/modules/skparagraph/include", + "$_skia_root/modules/skparagraph/utils", + ] +} + +skia_component("skparagraph") { + import("$_skia_root/modules/skparagraph/skparagraph.gni") + + # Opted out of check_includes, due to (logically) being part of skia. + check_includes = false + public_configs = [ ":public_config" ] + public = skparagraph_public + sources = skparagraph_sources + public_deps = [ + "../..:skia", + "../skunicode", + ] + deps = [ "../skshaper" ] +} diff --git a/skia/modules/skshaper/BUILD.gn b/skia/modules/skshaper/BUILD.gn new file mode 100644 index 0000000000000..de378fafc2799 --- /dev/null +++ b/skia/modules/skshaper/BUILD.gn @@ -0,0 +1,62 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +_skia_root = "//third_party/skia" + +import("$_skia_root/gn/skia.gni") +import("$_skia_root/modules/skshaper/skshaper.gni") + +if (skia_enable_skshaper) { + config("public_config") { + include_dirs = [ "$_skia_root/modules/skshaper/include" ] + defines = [] + if (skia_use_fonthost_mac) { + defines += [ "SK_SHAPER_CORETEXT_AVAILABLE" ] + } + if (skia_use_harfbuzz) { + defines += [ "SK_SHAPER_HARFBUZZ_AVAILABLE" ] + } + if (skia_enable_skunicode) { + defines += [ "SK_SHAPER_UNICODE_AVAILABLE" ] + } + } + + component("skshaper") { + # Opted out of check_includes, due to (logically) being part of skia. + check_includes = false + public_configs = [ ":public_config" ] + public = skia_shaper_public + deps = [ "../..:skia" ] + defines = [ "SKSHAPER_IMPLEMENTATION=1" ] + sources = skia_shaper_primitive_sources + if (skia_use_fonthost_mac) { + sources += skia_shaper_coretext_sources + if (is_mac) { + frameworks = [ "ApplicationServices.framework" ] + } + + if (is_ios) { + frameworks = [ + "CoreFoundation.framework", + "CoreText.framework", + ] + } + } + if (skia_enable_skunicode) { + sources += skia_shaper_skunicode_sources + deps += [ "../skunicode" ] + } + if (skia_use_harfbuzz && skia_enable_skunicode) { + sources += skia_shaper_harfbuzz_sources + deps += [ + "../skunicode", + "//third_party/harfbuzz", + ] + } + configs += [ "../../:skia_private" ] + } +} else { + group("skshaper") { + } +} diff --git a/skia/modules/skunicode/BUILD.gn b/skia/modules/skunicode/BUILD.gn new file mode 100644 index 0000000000000..e90997e5c72ab --- /dev/null +++ b/skia/modules/skunicode/BUILD.gn @@ -0,0 +1,76 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +_skia_root = "//third_party/skia" + +import("$_skia_root/gn/skia.gni") +import("$_skia_root/modules/skunicode/skunicode.gni") + +declare_args() { + skia_use_runtime_icu = false + skunicode_tests_enabled = true +} + +if (skia_use_icu || skia_use_client_icu || skia_use_libgrapheme) { + config("public_config") { + include_dirs = [ "$_skia_root/modules/skunicode/include" ] + defines = [ "SK_UNICODE_AVAILABLE" ] + if (skia_use_icu) { + defines += [ "SK_UNICODE_ICU_IMPLEMENTATION" ] + } + if (skia_use_client_icu) { + defines += [ "SK_UNICODE_CLIENT_IMPLEMENTATION" ] + } + if (skia_use_libgrapheme) { + defines += [ "SK_UNICODE_LIBGRAPHEME_IMPLEMENTATION" ] + } + } + + component("skunicode") { + # Opted out of check_includes, due to (logically) being part of skia. + check_includes = false + public_configs = [ ":public_config" ] + public = skia_unicode_public + deps = [ "../..:skia" ] + defines = [ "SKUNICODE_IMPLEMENTATION=1" ] + sources = skia_unicode_sources + skia_unicode_icu_bidi_sources + defines += [ "SK_UNICODE_AVAILABLE" ] + configs += [ "../../:skia_private" ] + + if (skia_use_icu) { + sources += skia_unicode_icu_sources + defines += [ "SK_UNICODE_ICU_IMPLEMENTATION" ] + + # only available for Android at the moment + if (skia_use_runtime_icu && (is_android || is_linux)) { + sources += skia_unicode_runtime_icu_sources + deps += [ "//third_party/icu:headers" ] + } else { + sources += skia_unicode_builtin_icu_sources + deps += [ "//third_party/icu" ] + } + configs += [ "$_skia_root/third_party/icu/config:no_cxx" ] + } + if (skia_use_client_icu) { + sources += skia_unicode_client_icu_sources + defines += [ "SK_UNICODE_CLIENT_IMPLEMENTATION" ] + if (!skia_use_icu) { + deps += [ skia_icu_bidi_third_party_dir ] + } + } + if (skia_use_libgrapheme) { + sources += skia_unicode_libgrapheme_sources + defines += [ "SK_UNICODE_LIBGRAPHEME_IMPLEMENTATION" ] + deps += [ skia_libgrapheme_third_party_dir ] + if (!skia_use_icu) { + deps += [ skia_icu_bidi_third_party_dir ] + } + } + } +} else { + group("skunicode") { + } + group("tests") { + } +} diff --git a/testing/BUILD.gn b/testing/BUILD.gn index cd7dd825295dd..5a56313330d6a 100644 --- a/testing/BUILD.gn +++ b/testing/BUILD.gn @@ -70,9 +70,9 @@ source_set("dart") { "//flutter/common", "//flutter/runtime", "//flutter/runtime:libdart", + "//flutter/skia", "//flutter/third_party/tonic", "//third_party/dart/runtime/bin:elf_loader", - "//third_party/skia", ] } @@ -87,7 +87,7 @@ source_set("skia") { public_deps = [ ":testing_lib", - "//third_party/skia", + "//flutter/skia", ] } diff --git a/third_party/canvaskit/BUILD.gn b/third_party/canvaskit/BUILD.gn index 125daf0998e80..782ee659f5528 100644 --- a/third_party/canvaskit/BUILD.gn +++ b/third_party/canvaskit/BUILD.gn @@ -23,7 +23,7 @@ wasm_toolchain("canvaskit") { copy("canvaskit_group") { visibility = [ "//flutter/web_sdk:*" ] - public_deps = [ "//third_party/skia/modules/canvaskit(:canvaskit)" ] + public_deps = [ "//flutter/skia/modules/canvaskit(:canvaskit)" ] sources = [ "$root_out_dir/canvaskit/canvaskit.js", @@ -58,7 +58,7 @@ wasm_toolchain("canvaskit_chromium") { copy("canvaskit_chromium_group") { visibility = [ "//flutter/web_sdk:*" ] - public_deps = [ "//third_party/skia/modules/canvaskit(:canvaskit_chromium)" ] + public_deps = [ "//flutter/skia/modules/canvaskit(:canvaskit_chromium)" ] sources = [ "$root_out_dir/canvaskit_chromium/canvaskit.js", diff --git a/third_party/txt/BUILD.gn b/third_party/txt/BUILD.gn index d917870109bf7..e5d97d024b249 100644 --- a/third_party/txt/BUILD.gn +++ b/third_party/txt/BUILD.gn @@ -82,14 +82,14 @@ source_set("txt") { "//flutter/display_list", "//flutter/fml", "//flutter/impeller/typographer/backends/skia:typographer_skia_backend", + "//flutter/skia", "//third_party/harfbuzz", "//third_party/icu", - "//third_party/skia", ] deps = [ - "//third_party/skia", - "//third_party/skia/modules/skparagraph", + "//flutter/skia", + "//flutter/skia/modules/skparagraph", ] libs = [] @@ -136,9 +136,9 @@ if (enable_unittests) { ":txt", ":txt_fixtures", "//flutter/fml", + "//flutter/skia/modules/skparagraph", "//flutter/testing:testing_lib", "//flutter/third_party/benchmark", - "//third_party/skia/modules/skparagraph", ] } @@ -164,9 +164,9 @@ if (enable_unittests) { ":txt_fixtures", "//flutter/fml", "//flutter/runtime:test_font", + "//flutter/skia/modules/skparagraph:skparagraph", "//flutter/testing:skia", "//flutter/testing:testing_lib", - "//third_party/skia/modules/skparagraph:skparagraph", ] # This is needed for //third_party/googletest for linking zircon symbols. diff --git a/tools/gn b/tools/gn index 4eed7044d185f..6ceda846269fe 100755 --- a/tools/gn +++ b/tools/gn @@ -541,10 +541,6 @@ def to_gn_args(args): gn_args['skia_use_gl'] = False gn_args['shell_enable_metal'] = True gn_args['skia_use_metal'] = True - # Bitcode enabled builds using the current version of the toolchain leak - # C++ symbols decorated with the availability attribute. Disable these - # attributes in release modes till the toolchain is updated. - gn_args['skia_enable_api_available_macro'] = args.runtime_mode != 'release' else: gn_args['skia_use_gl'] = args.target_os != 'fuchsia' @@ -772,7 +768,7 @@ def to_gn_wasm_args(args, gn_args): gn_args['skia_enable_fontmgr_custom_embedded'] = True gn_args['skia_enable_fontmgr_custom_empty'] = True gn_args['skia_fontmgr_factory' - ] = '//third_party/skia:fontmgr_custom_empty_factory' + ] = '//flutter/skia:fontmgr_custom_empty_factory' gn_args['skia_enable_skshaper'] = True gn_args['skia_enable_skparagraph'] = True gn_args['skia_canvaskit_force_tracing'] = False diff --git a/tools/path_ops/BUILD.gn b/tools/path_ops/BUILD.gn index cb711533dfbe4..6f928bbec70fe 100644 --- a/tools/path_ops/BUILD.gn +++ b/tools/path_ops/BUILD.gn @@ -9,7 +9,7 @@ shared_library("path_ops") { "path_ops.cc", "path_ops.h", ] - deps = [ "//third_party/skia" ] + deps = [ "//flutter/skia" ] metadata = { entitlement_file_path = [ "libpath_ops.dylib" ] diff --git a/vulkan/BUILD.gn b/vulkan/BUILD.gn index 173809ad2ce13..b213c73090f57 100644 --- a/vulkan/BUILD.gn +++ b/vulkan/BUILD.gn @@ -45,7 +45,7 @@ source_set("vulkan") { "procs", "//flutter/flutter_vma:flutter_skia_vma", "//flutter/fml", - "//third_party/skia", + "//flutter/skia", ] public_configs = [ "//flutter:config" ]