526 lines
15 KiB
Plaintext
526 lines
15 KiB
Plaintext
# Copyright 2013 The PDFium Authors
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
import("//build/config/features.gni")
|
|
import("//build/config/ui.gni")
|
|
import("//testing/test.gni")
|
|
import("//third_party/skia/gn/codec.gni")
|
|
import("//third_party/skia/gn/shared_sources.gni")
|
|
import("//third_party/skia/modules/skcms/skcms.gni")
|
|
import("features.gni")
|
|
|
|
if (current_cpu == "arm") {
|
|
import("//build/config/arm.gni")
|
|
}
|
|
if (current_cpu == "mipsel" || current_cpu == "mips64el") {
|
|
import("//build/config/mips.gni")
|
|
}
|
|
|
|
skia_use_ganesh_backend = !is_ios
|
|
skia_support_pdf = false
|
|
|
|
# External-facing config for dependent code.
|
|
config("skia_config") {
|
|
include_dirs = [ "//third_party/skia" ]
|
|
|
|
defines = [
|
|
"SK_ENCODE_PNG",
|
|
"SK_USER_CONFIG_HEADER=\"../../skia/config/SkPdfiumUserConfig.h\"",
|
|
]
|
|
|
|
if (is_win) {
|
|
defines += [ "SK_FREETYPE_MINIMUM_RUNTIME_VERSION=(((FREETYPE_MAJOR) * 0x01000000) | ((FREETYPE_MINOR) * 0x00010000) | ((FREETYPE_PATCH) * 0x00000100))" ]
|
|
}
|
|
|
|
if (is_component_build) {
|
|
defines += [
|
|
"SKIA_DLL",
|
|
"GR_GL_IGNORE_ES3_MSAA=0",
|
|
]
|
|
}
|
|
|
|
if (skia_use_ganesh_backend) {
|
|
defines += [ "SK_GANESH" ]
|
|
}
|
|
|
|
if (skia_use_gl) {
|
|
defines += [ "SK_GL" ]
|
|
}
|
|
|
|
if (is_android) {
|
|
defines += [
|
|
"SK_BUILD_FOR_ANDROID",
|
|
"USE_CHROMIUM_SKIA",
|
|
]
|
|
}
|
|
|
|
if (is_mac) {
|
|
defines += [ "SK_BUILD_FOR_MAC" ]
|
|
}
|
|
|
|
if (is_win) {
|
|
defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ]
|
|
}
|
|
}
|
|
|
|
# Internal-facing config for Skia library code.
|
|
config("skia_library_config") {
|
|
# Turn on SK_API to export Skia's public API
|
|
defines = [
|
|
"IS_SKIA_IMPL=1",
|
|
"SKIA_IMPLEMENTATION=1",
|
|
]
|
|
|
|
if (current_cpu == "arm") {
|
|
if (arm_use_neon) {
|
|
defines += [ "SK_ARM_HAS_NEON" ]
|
|
} else if (arm_optionally_use_neon) {
|
|
defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ]
|
|
}
|
|
}
|
|
|
|
# Settings for text blitting, chosen to approximate the system browser.
|
|
if (is_linux || is_chromeos) {
|
|
defines += [
|
|
"SK_GAMMA_EXPONENT=1.2",
|
|
"SK_GAMMA_CONTRAST=0.2",
|
|
]
|
|
} else if (is_android) {
|
|
defines += [
|
|
"SK_GAMMA_APPLY_TO_A8",
|
|
"SK_GAMMA_EXPONENT=1.4",
|
|
"SK_GAMMA_CONTRAST=0.0",
|
|
]
|
|
} else if (is_win) {
|
|
defines += [
|
|
"SK_GAMMA_SRGB",
|
|
"SK_GAMMA_CONTRAST=0.5",
|
|
]
|
|
} else if (is_mac) {
|
|
defines += [
|
|
"SK_GAMMA_SRGB",
|
|
"SK_GAMMA_CONTRAST=0.0",
|
|
]
|
|
}
|
|
|
|
if (is_android) {
|
|
defines += [
|
|
# Android devices are typically more memory constrained, so default to a
|
|
# smaller glyph cache (it may be overriden at runtime when the renderer
|
|
# starts up, depending on the actual device memory).
|
|
"SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024
|
|
]
|
|
} else {
|
|
defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024
|
|
}
|
|
|
|
if (is_win) {
|
|
defines += [
|
|
# On windows, GDI handles are a scarse system-wide resource so we have to
|
|
# keep the glyph cache, which holds up to 4 GDI handles per entry, to a
|
|
# fairly small size. http://crbug.com/314387
|
|
"SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256",
|
|
]
|
|
|
|
cflags = [
|
|
"/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)'
|
|
"/wd4341", # signed value is out of range for enum constant.
|
|
"/wd4345", # Object is default-initialized if initialization is omitted.
|
|
"/wd4390", # ';'empty statement found in looping;is it what was intended?
|
|
"/wd4554", # 'operator' : check operator precedence for possible error
|
|
"/wd4748", # compiler will disable optimizations if a function has inline
|
|
# assembly code contains flow control(jmp or jcc) statements.
|
|
|
|
"/wd4800", # forcing value to bool 'true/false'(assigning int to bool).
|
|
"/wd5041", # out-of-line definition for constexpr static data member is
|
|
# not needed and is deprecated in C++17
|
|
]
|
|
}
|
|
}
|
|
|
|
source_set("skcms") {
|
|
cflags = []
|
|
if (!is_win || is_clang) {
|
|
cflags += [
|
|
"-w",
|
|
"-std=c11",
|
|
]
|
|
}
|
|
|
|
# LLVM automatically sets the equivalent of GCC's -mfp16-format=ieee on ARM
|
|
# builds by default, while GCC itself does not. We need it to enable support
|
|
# for half-precision floating point data types used by SKCMS on ARM.
|
|
if ((is_linux || is_chromeos) && !is_clang && current_cpu == "arm") {
|
|
cflags += [ "-mfp16-format=ieee" ]
|
|
}
|
|
|
|
public =
|
|
rebase_path(skcms_public_headers, ".", "//third_party/skia/modules/skcms")
|
|
sources = rebase_path(skcms_sources, ".", "//third_party/skia/modules/skcms")
|
|
}
|
|
|
|
component("skia") {
|
|
deps = []
|
|
|
|
sources = [
|
|
# PDFium sources.
|
|
"config/SkPdfiumUserConfig.h",
|
|
"ext/google_logging.cc",
|
|
]
|
|
|
|
# The skia sources values are relative to the skia_dir, so we need to rebase.
|
|
sources += skia_core_public
|
|
sources += skia_sksl_gpu_sources
|
|
sources += skia_sksl_sources
|
|
sources += skia_utils_sources
|
|
sources += skia_codec_core
|
|
sources += skia_codec_decode_bmp
|
|
sources += skia_encode_srcs
|
|
sources += skia_encode_png_srcs
|
|
sources += [
|
|
"//third_party/skia/src/fonts/SkFontMgr_indirect.cpp",
|
|
"//third_party/skia/src/fonts/SkRemotableFontMgr.cpp",
|
|
"//third_party/skia/src/ports/SkGlobalInitialization_default.cpp",
|
|
"//third_party/skia/src/ports/SkImageGenerator_none.cpp",
|
|
"//third_party/skia/src/ports/SkOSFile_stdio.cpp",
|
|
"//third_party/skia/src/sfnt/SkOTTable_name.cpp",
|
|
"//third_party/skia/src/sfnt/SkOTUtils.cpp",
|
|
|
|
#pdfium
|
|
"//third_party/skia/src/ports/SkDiscardableMemory_none.cpp",
|
|
"//third_party/skia/src/ports/SkMemory_malloc.cpp",
|
|
]
|
|
|
|
# This and skia_opts are really the same conceptual target so share headers.
|
|
allow_circular_includes_from = [ ":skia_opts" ]
|
|
|
|
# GPU
|
|
if (skia_use_ganesh_backend) {
|
|
sources += skia_gpu_public
|
|
sources += skia_ganesh_private
|
|
sources += skia_null_gpu_sources
|
|
sources += skia_shared_gpu_sources
|
|
if (skia_use_gl) {
|
|
sources += skia_gpu_gl_public
|
|
sources += skia_gpu_gl_private
|
|
}
|
|
}
|
|
|
|
# Remove unused util files include in utils.gni
|
|
sources -= [
|
|
"//third_party/skia/src/utils/SkCamera.cpp",
|
|
"//third_party/skia/src/utils/SkParsePath.cpp",
|
|
]
|
|
|
|
# need separate win section to handle chromes auto gn filter
|
|
# (build/config/BUILDCONFIG.gn)
|
|
if (is_win) {
|
|
sources -= [
|
|
#windows
|
|
"//third_party/skia/src/utils/win/SkAutoCoInitialize.cpp",
|
|
"//third_party/skia/src/utils/win/SkIStream.cpp",
|
|
"//third_party/skia/src/utils/win/SkWGL_win.cpp",
|
|
]
|
|
}
|
|
|
|
# Select Skia ports.
|
|
|
|
# FreeType is needed everywhere (except on iOS), on Linux and Android as main
|
|
# font backend, on Windows and Mac as fallback backend for Variations.
|
|
if (!is_ios) {
|
|
sources += [
|
|
"//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
|
|
"//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
|
|
]
|
|
}
|
|
|
|
if (is_win) {
|
|
sources += [
|
|
"//third_party/skia/src/ports/SkFontHost_win.cpp",
|
|
|
|
# TODO(crbug.com/pdfium/1830) Consider using SkFontMgr_win_dw_factory
|
|
# instead of SkFontMgr_custom_empty (which is what the embedder test
|
|
# hashes are based upon).
|
|
"//third_party/skia/src/ports/SkFontMgr_custom.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_win_dw.cpp",
|
|
"//third_party/skia/src/ports/SkOSFile_win.cpp",
|
|
"//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp",
|
|
"//third_party/skia/src/ports/SkScalerContext_win_dw.cpp",
|
|
"//third_party/skia/src/ports/SkTypeface_win_dw.cpp",
|
|
]
|
|
} else {
|
|
sources += [ "//third_party/skia/src/ports/SkOSFile_posix.cpp" ]
|
|
}
|
|
|
|
frameworks = []
|
|
if (is_apple) {
|
|
sources += [
|
|
# TODO(crbug.com/pdfium/1830) Consider using SkFontMgr_mac_ct instead of
|
|
# SkFontMgr_custom_empty (which is what the embedder test hashes are
|
|
# based upon).
|
|
"//third_party/skia/src/ports/SkFontMgr_custom.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp",
|
|
"//third_party/skia/src/ports/SkScalerContext_mac_ct.cpp",
|
|
"//third_party/skia/src/ports/SkScalerContext_mac_ct.h",
|
|
"//third_party/skia/src/ports/SkTypeface_mac_ct.cpp",
|
|
"//third_party/skia/src/ports/SkTypeface_mac_ct.h",
|
|
]
|
|
frameworks += [
|
|
"CoreFoundation.framework",
|
|
"CoreGraphics.framework",
|
|
"CoreText.framework",
|
|
]
|
|
}
|
|
|
|
if (is_linux || is_chromeos) {
|
|
sources += [
|
|
"//third_party/skia/src/ports/SkFontConfigInterface.cpp",
|
|
"//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
|
|
"//third_party/skia/src/ports/SkFontConfigInterface_direct_factory.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_FontConfigInterface.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp",
|
|
]
|
|
}
|
|
|
|
if (is_android) {
|
|
sources += [
|
|
# Unlike Chromium, standalone PDFium on Linux and Chrome OS does not
|
|
# require these files, since PDFium does not perform Android emulation.
|
|
# Note that this requires expat.
|
|
"//third_party/skia/src/ports/SkFontMgr_android.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_android_factory.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_android_parser.cpp",
|
|
]
|
|
}
|
|
|
|
if (is_fuchsia) {
|
|
sources += [
|
|
# TODO(crbug.com/pdfium/2019): Consider using SkFontMgr_fuchsia.cpp
|
|
# instead of SkFontMgr_custom_empty.cpp.
|
|
"//third_party/skia/src/ports/SkFontMgr_custom.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp",
|
|
"//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp",
|
|
]
|
|
deps += [
|
|
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.fonts:fuchsia.fonts_hlcpp",
|
|
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_hlcpp",
|
|
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sys:fuchsia.sys_hlcpp",
|
|
"//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
|
|
"//third_party/fuchsia-sdk/sdk/pkg/zx",
|
|
"//third_party/icu:icuuc",
|
|
]
|
|
}
|
|
|
|
if (is_clang && !is_nacl) {
|
|
# Skia won't compile with some of the more strict clang warnings.
|
|
# e.g. it does:
|
|
# SkASSERT(!"sk_out_of_memory");
|
|
configs -= [ "//build/config/clang:extra_warnings" ]
|
|
}
|
|
|
|
configs -= [ "//build/config/compiler:chromium_code" ]
|
|
configs += [
|
|
":skia_config",
|
|
":skia_library_config",
|
|
"//build/config/compiler:no_chromium_code",
|
|
]
|
|
public_configs = [ ":skia_config" ]
|
|
|
|
deps += [
|
|
":skcms",
|
|
":skia_opts",
|
|
"../third_party:png",
|
|
"../third_party:zlib",
|
|
"//:freetype_common",
|
|
]
|
|
public_deps = [ ":skia_core_and_effects" ]
|
|
|
|
if (is_linux || is_chromeos) {
|
|
deps += [
|
|
"//third_party:fontconfig",
|
|
"//third_party/icu:icuuc",
|
|
]
|
|
}
|
|
|
|
if (is_android) {
|
|
deps += [
|
|
"//third_party/android_ndk:cpu_features",
|
|
"//third_party/expat",
|
|
]
|
|
}
|
|
|
|
if (is_android && !is_debug) {
|
|
configs -= [ "//build/config/compiler:default_optimization" ]
|
|
configs += [ "//build/config/compiler:optimize_max" ]
|
|
}
|
|
|
|
if (is_ios) {
|
|
frameworks += [ "ImageIO.framework" ]
|
|
}
|
|
|
|
if (skia_support_pdf) {
|
|
deps += [ "//third_party/sfntly" ]
|
|
sources += skia_pdf_sources
|
|
} else {
|
|
sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ]
|
|
}
|
|
}
|
|
|
|
# Template for things that are logically part of :skia, but need to be split out
|
|
# so custom compile flags can be applied.
|
|
#
|
|
# These are all opted out of check_includes, due to (logically) being part of
|
|
# skia.
|
|
template("skia_source_set") {
|
|
source_set(target_name) {
|
|
forward_variables_from(invoker, "*")
|
|
|
|
check_includes = false
|
|
|
|
if (!is_debug) {
|
|
configs -= [ "//build/config/compiler:default_optimization" ]
|
|
configs += [ "//build/config/compiler:optimize_max" ]
|
|
}
|
|
|
|
configs -= [ "//build/config/compiler:chromium_code" ]
|
|
configs += [
|
|
":skia_config",
|
|
":skia_library_config",
|
|
"//build/config/compiler:no_chromium_code",
|
|
]
|
|
public_configs = [ ":skia_config" ]
|
|
|
|
if (is_win) {
|
|
cflags_cc = [
|
|
"/wd5041", # out-of-line definition for constexpr static data member is
|
|
# not needed and is deprecated in C++17
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
skia_source_set("skia_core_and_effects") {
|
|
defines = []
|
|
sources = skia_core_sources
|
|
sources += skia_effects_sources
|
|
sources += skia_effects_imagefilter_sources
|
|
|
|
visibility = [ ":skia" ]
|
|
}
|
|
|
|
# Bits that involve special vector-y hardware.
|
|
if (current_cpu == "arm64") {
|
|
skia_source_set("skia_opts_crc32") {
|
|
sources = skia_opts.crc32_sources
|
|
cflags = [ "-march=armv8-a+crc" ]
|
|
visibility = [ ":skia_opts" ]
|
|
}
|
|
}
|
|
if (current_cpu == "x86" || current_cpu == "x64") {
|
|
skia_source_set("skia_opts_sse3") {
|
|
sources = skia_opts.ssse3_sources
|
|
if (!is_win || is_clang) {
|
|
cflags = [ "-mssse3" ]
|
|
}
|
|
if (is_win) {
|
|
defines = [ "SK_CPU_SSE_LEVEL=31" ]
|
|
}
|
|
visibility = [ ":skia_opts" ]
|
|
}
|
|
skia_source_set("skia_opts_sse42") {
|
|
sources = skia_opts.sse42_sources
|
|
if (!is_win || is_clang) {
|
|
cflags = [ "-msse4.2" ]
|
|
}
|
|
if (is_win) {
|
|
defines = [ "SK_CPU_SSE_LEVEL=42" ]
|
|
}
|
|
visibility = [ ":skia_opts" ]
|
|
}
|
|
skia_source_set("skia_opts_avx") {
|
|
sources = skia_opts.avx_sources
|
|
if (!is_win) {
|
|
cflags = [ "-mavx" ]
|
|
}
|
|
if (is_win) {
|
|
cflags = [ "/arch:AVX" ]
|
|
}
|
|
visibility = [ ":skia_opts" ]
|
|
}
|
|
skia_source_set("skia_opts_hsw") {
|
|
sources = skia_opts.hsw_sources
|
|
if (!is_win) {
|
|
cflags = [
|
|
"-mavx2",
|
|
"-mbmi",
|
|
"-mbmi2",
|
|
"-mf16c",
|
|
"-mfma",
|
|
]
|
|
}
|
|
if (is_win) {
|
|
cflags = [ "/arch:AVX2" ]
|
|
}
|
|
visibility = [ ":skia_opts" ]
|
|
}
|
|
skia_source_set("skia_opts_skx") {
|
|
sources = skia_opts.skx_sources
|
|
if (!is_win) {
|
|
cflags = [ "-march=skylake-avx512" ]
|
|
}
|
|
if (is_win) {
|
|
cflags = [ "/arch:AVX512" ]
|
|
}
|
|
visibility = [ ":skia_opts" ]
|
|
}
|
|
}
|
|
|
|
skia_source_set("skia_opts") {
|
|
cflags = []
|
|
defines = []
|
|
|
|
if (current_cpu == "x86" || current_cpu == "x64") {
|
|
deps = [
|
|
":skia_opts_avx",
|
|
":skia_opts_hsw",
|
|
":skia_opts_skx",
|
|
":skia_opts_sse3",
|
|
":skia_opts_sse42",
|
|
]
|
|
} else if (current_cpu == "arm") {
|
|
# The assembly uses the frame pointer register (r7 in Thumb/r11 in
|
|
# ARM), the compiler doesn't like that.
|
|
cflags += [ "-fomit-frame-pointer" ]
|
|
|
|
if (arm_version >= 7) {
|
|
if (arm_use_neon || arm_optionally_use_neon) {
|
|
# Root build config sets -mfpu=$arm_fpu, which we expect to be neon
|
|
# when running this.
|
|
if (!arm_use_neon) {
|
|
configs -= [ "//build/config/compiler:compiler_arm_fpu" ]
|
|
cflags += [ "-mfpu=neon" ]
|
|
}
|
|
}
|
|
}
|
|
} else if (current_cpu == "arm64") {
|
|
deps = [ ":skia_opts_crc32" ]
|
|
} else if (current_cpu == "mipsel" || current_cpu == "mips64el") {
|
|
cflags += [ "-fomit-frame-pointer" ]
|
|
} else {
|
|
assert(false, "Unsupported target CPU " + current_cpu)
|
|
}
|
|
|
|
if (is_android && !is_debug) {
|
|
configs -= [ "//build/config/compiler:default_optimization" ]
|
|
configs += [ "//build/config/compiler:optimize_max" ]
|
|
}
|
|
|
|
visibility = [ ":skia" ]
|
|
}
|