K. Moon | 8636cff | 2022-11-02 18:45:43 +0000 | [diff] [blame] | 1 | # Copyright 2013 The PDFium Authors |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import("//build/config/features.gni") |
| 6 | import("//build/config/ui.gni") |
| 7 | import("//testing/test.gni") |
Kevin Lubick | fe247d3 | 2023-01-11 18:48:21 +0000 | [diff] [blame] | 8 | import("//third_party/skia/gn/codec.gni") |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 9 | import("//third_party/skia/gn/shared_sources.gni") |
Lei Zhang | 26dc4e6 | 2022-06-30 20:57:32 +0000 | [diff] [blame] | 10 | import("//third_party/skia/modules/skcms/skcms.gni") |
Lei Zhang | a7070ff | 2019-12-05 21:43:44 +0000 | [diff] [blame] | 11 | import("features.gni") |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 12 | |
| 13 | if (current_cpu == "arm") { |
| 14 | import("//build/config/arm.gni") |
| 15 | } |
| 16 | if (current_cpu == "mipsel" || current_cpu == "mips64el") { |
| 17 | import("//build/config/mips.gni") |
| 18 | } |
| 19 | |
Kevin Lubick | 7f2d281 | 2023-03-13 18:07:28 +0000 | [diff] [blame] | 20 | skia_use_ganesh_backend = !is_ios |
Lei Zhang | a7070ff | 2019-12-05 21:43:44 +0000 | [diff] [blame] | 21 | skia_support_pdf = false |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 22 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 23 | # External-facing config for dependent code. |
| 24 | config("skia_config") { |
Lei Zhang | 9835050 | 2019-07-12 17:12:34 +0000 | [diff] [blame] | 25 | include_dirs = [ "//third_party/skia" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 26 | |
K. Moon | f446aae | 2022-11-16 18:15:11 +0000 | [diff] [blame] | 27 | defines = [ |
| 28 | "SK_ENCODE_PNG", |
| 29 | "SK_USER_CONFIG_HEADER=\"../../skia/config/SkPdfiumUserConfig.h\"", |
| 30 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 31 | |
dan sinclair | ecc3c83 | 2017-04-10 10:47:18 -0400 | [diff] [blame] | 32 | if (is_win) { |
| 33 | defines += [ "SK_FREETYPE_MINIMUM_RUNTIME_VERSION=(((FREETYPE_MAJOR) * 0x01000000) | ((FREETYPE_MINOR) * 0x00010000) | ((FREETYPE_PATCH) * 0x00000100))" ] |
| 34 | } |
| 35 | |
| 36 | if (is_component_build) { |
| 37 | defines += [ |
| 38 | "SKIA_DLL", |
| 39 | "GR_GL_IGNORE_ES3_MSAA=0", |
| 40 | ] |
| 41 | } |
| 42 | |
Kevin Lubick | 7f2d281 | 2023-03-13 18:07:28 +0000 | [diff] [blame] | 43 | if (skia_use_ganesh_backend) { |
| 44 | defines += [ "SK_GANESH" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Lei Zhang | a7070ff | 2019-12-05 21:43:44 +0000 | [diff] [blame] | 47 | if (skia_use_gl) { |
| 48 | defines += [ "SK_GL" ] |
| 49 | } |
| 50 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 51 | if (is_android) { |
| 52 | defines += [ |
| 53 | "SK_BUILD_FOR_ANDROID", |
| 54 | "USE_CHROMIUM_SKIA", |
| 55 | ] |
| 56 | } |
| 57 | |
| 58 | if (is_mac) { |
| 59 | defines += [ "SK_BUILD_FOR_MAC" ] |
| 60 | } |
| 61 | |
| 62 | if (is_win) { |
| 63 | defines += [ "GR_GL_FUNCTION_TYPE=__stdcall" ] |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | # Internal-facing config for Skia library code. |
| 68 | config("skia_library_config") { |
K. Moon | 9fc138c | 2023-02-07 00:58:01 +0000 | [diff] [blame] | 69 | # Turn on SK_API to export Skia's public API |
| 70 | defines = [ |
| 71 | "IS_SKIA_IMPL=1", |
| 72 | "SKIA_IMPLEMENTATION=1", |
| 73 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 74 | |
| 75 | if (current_cpu == "arm") { |
| 76 | if (arm_use_neon) { |
| 77 | defines += [ "SK_ARM_HAS_NEON" ] |
| 78 | } else if (arm_optionally_use_neon) { |
| 79 | defines += [ "SK_ARM_HAS_OPTIONAL_NEON" ] |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | # Settings for text blitting, chosen to approximate the system browser. |
Lei Zhang | 2f5f955 | 2020-08-05 18:51:25 +0000 | [diff] [blame] | 84 | if (is_linux || is_chromeos) { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 85 | defines += [ |
| 86 | "SK_GAMMA_EXPONENT=1.2", |
| 87 | "SK_GAMMA_CONTRAST=0.2", |
| 88 | ] |
| 89 | } else if (is_android) { |
| 90 | defines += [ |
| 91 | "SK_GAMMA_APPLY_TO_A8", |
| 92 | "SK_GAMMA_EXPONENT=1.4", |
| 93 | "SK_GAMMA_CONTRAST=0.0", |
| 94 | ] |
| 95 | } else if (is_win) { |
| 96 | defines += [ |
| 97 | "SK_GAMMA_SRGB", |
| 98 | "SK_GAMMA_CONTRAST=0.5", |
| 99 | ] |
| 100 | } else if (is_mac) { |
| 101 | defines += [ |
| 102 | "SK_GAMMA_SRGB", |
| 103 | "SK_GAMMA_CONTRAST=0.0", |
| 104 | ] |
| 105 | } |
| 106 | |
| 107 | if (is_android) { |
| 108 | defines += [ |
| 109 | # Android devices are typically more memory constrained, so default to a |
| 110 | # smaller glyph cache (it may be overriden at runtime when the renderer |
| 111 | # starts up, depending on the actual device memory). |
| 112 | "SK_DEFAULT_FONT_CACHE_LIMIT=1048576", # 1024 * 1024 |
| 113 | ] |
| 114 | } else { |
| 115 | defines += [ "SK_DEFAULT_FONT_CACHE_LIMIT=20971520" ] # 20 * 1024 * 1024 |
| 116 | } |
| 117 | |
| 118 | if (is_win) { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 119 | defines += [ |
| 120 | # On windows, GDI handles are a scarse system-wide resource so we have to |
| 121 | # keep the glyph cache, which holds up to 4 GDI handles per entry, to a |
| 122 | # fairly small size. http://crbug.com/314387 |
| 123 | "SK_DEFAULT_FONT_CACHE_COUNT_LIMIT=256", |
| 124 | ] |
| 125 | |
| 126 | cflags = [ |
| 127 | "/wd4244", # conversion from 'type1( __int64)' to 'type2 (unsigned int)' |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 128 | "/wd4341", # signed value is out of range for enum constant. |
| 129 | "/wd4345", # Object is default-initialized if initialization is omitted. |
| 130 | "/wd4390", # ';'empty statement found in looping;is it what was intended? |
| 131 | "/wd4554", # 'operator' : check operator precedence for possible error |
| 132 | "/wd4748", # compiler will disable optimizations if a function has inline |
| 133 | # assembly code contains flow control(jmp or jcc) statements. |
Lei Zhang | f02c8c9 | 2019-12-05 19:14:23 +0000 | [diff] [blame] | 134 | |
| 135 | "/wd4800", # forcing value to bool 'true/false'(assigning int to bool). |
Lei Zhang | 95cf31b | 2020-04-23 16:42:38 +0000 | [diff] [blame] | 136 | "/wd5041", # out-of-line definition for constexpr static data member is |
| 137 | # not needed and is deprecated in C++17 |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 138 | ] |
| 139 | } |
| 140 | } |
| 141 | |
Lei Zhang | 742f5b2 | 2018-10-31 16:41:24 +0000 | [diff] [blame] | 142 | source_set("skcms") { |
| 143 | cflags = [] |
| 144 | if (!is_win || is_clang) { |
| 145 | cflags += [ |
| 146 | "-w", |
| 147 | "-std=c11", |
| 148 | ] |
| 149 | } |
| 150 | |
| 151 | # LLVM automatically sets the equivalent of GCC's -mfp16-format=ieee on ARM |
| 152 | # builds by default, while GCC itself does not. We need it to enable support |
| 153 | # for half-precision floating point data types used by SKCMS on ARM. |
Lei Zhang | 2f5f955 | 2020-08-05 18:51:25 +0000 | [diff] [blame] | 154 | if ((is_linux || is_chromeos) && !is_clang && current_cpu == "arm") { |
Lei Zhang | 742f5b2 | 2018-10-31 16:41:24 +0000 | [diff] [blame] | 155 | cflags += [ "-mfp16-format=ieee" ] |
| 156 | } |
| 157 | |
Lei Zhang | 26dc4e6 | 2022-06-30 20:57:32 +0000 | [diff] [blame] | 158 | public = |
| 159 | rebase_path(skcms_public_headers, ".", "//third_party/skia/modules/skcms") |
| 160 | sources = rebase_path(skcms_sources, ".", "//third_party/skia/modules/skcms") |
Lei Zhang | 742f5b2 | 2018-10-31 16:41:24 +0000 | [diff] [blame] | 161 | } |
| 162 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 163 | component("skia") { |
Lei Zhang | 31bc914 | 2023-04-05 18:42:27 +0000 | [diff] [blame] | 164 | deps = [] |
| 165 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 166 | sources = [ |
thestig | 19ea309 | 2016-05-13 11:24:26 -0700 | [diff] [blame] | 167 | # PDFium sources. |
Lei Zhang | 0cd7672 | 2022-11-14 22:13:27 +0000 | [diff] [blame] | 168 | "config/SkPdfiumUserConfig.h", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 169 | "ext/google_logging.cc", |
| 170 | ] |
| 171 | |
Lei Zhang | 65a2192 | 2017-04-15 21:30:32 -0700 | [diff] [blame] | 172 | # The skia sources values are relative to the skia_dir, so we need to rebase. |
K. Moon | 1852aa0 | 2022-11-10 18:56:52 +0000 | [diff] [blame] | 173 | sources += skia_core_public |
Lei Zhang | db9bec6 | 2019-07-16 19:14:45 +0000 | [diff] [blame] | 174 | sources += skia_sksl_gpu_sources |
ethannicholas | 52ef14e | 2016-10-12 13:08:18 -0700 | [diff] [blame] | 175 | sources += skia_sksl_sources |
Kevin Lubick | 53dcf78 | 2023-05-31 20:37:36 +0000 | [diff] [blame] | 176 | sources += skia_utils_private |
K. Moon | 505438b | 2023-06-30 22:20:28 +0000 | [diff] [blame] | 177 | sources += skia_xps_sources |
Kevin Lubick | fe247d3 | 2023-01-11 18:48:21 +0000 | [diff] [blame] | 178 | sources += skia_codec_core |
| 179 | sources += skia_codec_decode_bmp |
Kevin Lubick | f5756d3 | 2023-03-03 16:33:48 +0000 | [diff] [blame] | 180 | sources += skia_encode_srcs |
| 181 | sources += skia_encode_png_srcs |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 182 | sources += [ |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 183 | "//third_party/skia/src/fonts/SkFontMgr_indirect.cpp", |
| 184 | "//third_party/skia/src/fonts/SkRemotableFontMgr.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 185 | "//third_party/skia/src/ports/SkGlobalInitialization_default.cpp", |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 186 | "//third_party/skia/src/ports/SkImageGenerator_none.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 187 | "//third_party/skia/src/ports/SkOSFile_stdio.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 188 | "//third_party/skia/src/sfnt/SkOTTable_name.cpp", |
| 189 | "//third_party/skia/src/sfnt/SkOTUtils.cpp", |
| 190 | |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 191 | #pdfium |
| 192 | "//third_party/skia/src/ports/SkDiscardableMemory_none.cpp", |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 193 | "//third_party/skia/src/ports/SkMemory_malloc.cpp", |
| 194 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 195 | |
| 196 | # This and skia_opts are really the same conceptual target so share headers. |
| 197 | allow_circular_includes_from = [ ":skia_opts" ] |
| 198 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 199 | # GPU |
Kevin Lubick | 7f2d281 | 2023-03-13 18:07:28 +0000 | [diff] [blame] | 200 | if (skia_use_ganesh_backend) { |
Kevin Lubick | fe247d3 | 2023-01-11 18:48:21 +0000 | [diff] [blame] | 201 | sources += skia_gpu_public |
Kevin Lubick | 469cc8f | 2023-03-28 15:49:01 +0000 | [diff] [blame] | 202 | sources += skia_ganesh_private |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 203 | sources += skia_null_gpu_sources |
Alan Screen | c498827 | 2021-12-01 16:37:36 +0000 | [diff] [blame] | 204 | sources += skia_shared_gpu_sources |
Lei Zhang | a7070ff | 2019-12-05 21:43:44 +0000 | [diff] [blame] | 205 | if (skia_use_gl) { |
Kevin Lubick | fe247d3 | 2023-01-11 18:48:21 +0000 | [diff] [blame] | 206 | sources += skia_gpu_gl_public |
| 207 | sources += skia_gpu_gl_private |
Lei Zhang | a7070ff | 2019-12-05 21:43:44 +0000 | [diff] [blame] | 208 | } |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Lei Zhang | 65a2192 | 2017-04-15 21:30:32 -0700 | [diff] [blame] | 211 | # Remove unused util files include in utils.gni |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 212 | sources -= [ |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 213 | "//third_party/skia/src/utils/SkCamera.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 214 | "//third_party/skia/src/utils/SkParsePath.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 215 | ] |
| 216 | |
K. Moon | 505438b | 2023-06-30 22:20:28 +0000 | [diff] [blame] | 217 | if (is_win) { |
| 218 | libs = [ "fontsub.lib" ] |
| 219 | } |
| 220 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 221 | # need separate win section to handle chromes auto gn filter |
| 222 | # (build/config/BUILDCONFIG.gn) |
| 223 | if (is_win) { |
| 224 | sources -= [ |
| 225 | #windows |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 226 | "//third_party/skia/src/utils/win/SkWGL_win.cpp", |
| 227 | ] |
| 228 | } |
| 229 | |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 230 | # Select Skia ports. |
| 231 | |
| 232 | # FreeType is needed everywhere (except on iOS), on Linux and Android as main |
| 233 | # font backend, on Windows and Mac as fallback backend for Variations. |
| 234 | if (!is_ios) { |
| 235 | sources += [ |
| 236 | "//third_party/skia/src/ports/SkFontHost_FreeType.cpp", |
| 237 | "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 238 | ] |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | if (is_win) { |
| 242 | sources += [ |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 243 | "//third_party/skia/src/ports/SkFontHost_win.cpp", |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 244 | |
| 245 | # TODO(crbug.com/pdfium/1830) Consider using SkFontMgr_win_dw_factory |
| 246 | # instead of SkFontMgr_custom_empty (which is what the embedder test |
| 247 | # hashes are based upon). |
| 248 | "//third_party/skia/src/ports/SkFontMgr_custom.cpp", |
| 249 | "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp", |
| 250 | "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 251 | "//third_party/skia/src/ports/SkFontMgr_win_dw.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 252 | "//third_party/skia/src/ports/SkOSFile_win.cpp", |
| 253 | "//third_party/skia/src/ports/SkRemotableFontMgr_win_dw.cpp", |
| 254 | "//third_party/skia/src/ports/SkScalerContext_win_dw.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 255 | "//third_party/skia/src/ports/SkTypeface_win_dw.cpp", |
| 256 | ] |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 257 | } else { |
Kevin Lubick | 18021e7 | 2022-08-19 20:12:49 +0000 | [diff] [blame] | 258 | sources += [ "//third_party/skia/src/ports/SkOSFile_posix.cpp" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 259 | } |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 260 | |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 261 | frameworks = [] |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 262 | if (is_apple) { |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 263 | sources += [ |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 264 | # TODO(crbug.com/pdfium/1830) Consider using SkFontMgr_mac_ct instead of |
| 265 | # SkFontMgr_custom_empty (which is what the embedder test hashes are |
| 266 | # based upon). |
| 267 | "//third_party/skia/src/ports/SkFontMgr_custom.cpp", |
| 268 | "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp", |
| 269 | "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 270 | "//third_party/skia/src/ports/SkScalerContext_mac_ct.cpp", |
| 271 | "//third_party/skia/src/ports/SkScalerContext_mac_ct.h", |
| 272 | "//third_party/skia/src/ports/SkTypeface_mac_ct.cpp", |
| 273 | "//third_party/skia/src/ports/SkTypeface_mac_ct.h", |
| 274 | ] |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 275 | frameworks += [ |
| 276 | "CoreFoundation.framework", |
| 277 | "CoreGraphics.framework", |
| 278 | "CoreText.framework", |
| 279 | ] |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | if (is_linux || is_chromeos) { |
| 283 | sources += [ |
| 284 | "//third_party/skia/src/ports/SkFontConfigInterface.cpp", |
| 285 | "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp", |
| 286 | "//third_party/skia/src/ports/SkFontConfigInterface_direct_factory.cpp", |
| 287 | "//third_party/skia/src/ports/SkFontMgr_FontConfigInterface.cpp", |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 288 | "//third_party/skia/src/ports/SkFontMgr_custom.cpp", |
| 289 | "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp", |
| 290 | "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 291 | ] |
| 292 | } |
| 293 | |
Lei Zhang | 95656f9 | 2022-03-01 17:32:21 +0000 | [diff] [blame] | 294 | if (is_android) { |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 295 | sources += [ |
Lei Zhang | 95656f9 | 2022-03-01 17:32:21 +0000 | [diff] [blame] | 296 | # Unlike Chromium, standalone PDFium on Linux and Chrome OS does not |
| 297 | # require these files, since PDFium does not perform Android emulation. |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 298 | # Note that this requires expat. |
| 299 | "//third_party/skia/src/ports/SkFontMgr_android.cpp", |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 300 | "//third_party/skia/src/ports/SkFontMgr_android_factory.cpp", |
Lei Zhang | b8928e4 | 2020-08-06 05:15:47 +0000 | [diff] [blame] | 301 | "//third_party/skia/src/ports/SkFontMgr_android_parser.cpp", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 302 | ] |
| 303 | } |
| 304 | |
Lei Zhang | 31bc914 | 2023-04-05 18:42:27 +0000 | [diff] [blame] | 305 | if (is_fuchsia) { |
| 306 | sources += [ |
| 307 | # TODO(crbug.com/pdfium/2019): Consider using SkFontMgr_fuchsia.cpp |
| 308 | # instead of SkFontMgr_custom_empty.cpp. |
| 309 | "//third_party/skia/src/ports/SkFontMgr_custom.cpp", |
| 310 | "//third_party/skia/src/ports/SkFontMgr_custom_empty.cpp", |
| 311 | "//third_party/skia/src/ports/SkFontMgr_custom_empty_factory.cpp", |
| 312 | ] |
| 313 | deps += [ |
| 314 | "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.fonts:fuchsia.fonts_hlcpp", |
| 315 | "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.io:fuchsia.io_hlcpp", |
| 316 | "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sys:fuchsia.sys_hlcpp", |
| 317 | "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", |
| 318 | "//third_party/fuchsia-sdk/sdk/pkg/zx", |
| 319 | "//third_party/icu:icuuc", |
| 320 | ] |
| 321 | } |
| 322 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 323 | if (is_clang && !is_nacl) { |
| 324 | # Skia won't compile with some of the more strict clang warnings. |
| 325 | # e.g. it does: |
| 326 | # SkASSERT(!"sk_out_of_memory"); |
| 327 | configs -= [ "//build/config/clang:extra_warnings" ] |
| 328 | } |
| 329 | |
| 330 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 331 | configs += [ |
| 332 | ":skia_config", |
| 333 | ":skia_library_config", |
| 334 | "//build/config/compiler:no_chromium_code", |
| 335 | ] |
| 336 | public_configs = [ ":skia_config" ] |
| 337 | |
Lei Zhang | 31bc914 | 2023-04-05 18:42:27 +0000 | [diff] [blame] | 338 | deps += [ |
Lei Zhang | 742f5b2 | 2018-10-31 16:41:24 +0000 | [diff] [blame] | 339 | ":skcms", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 340 | ":skia_opts", |
K. Moon | f446aae | 2022-11-16 18:15:11 +0000 | [diff] [blame] | 341 | "../third_party:png", |
Miklos Vajna | 2df760f | 2017-05-06 01:54:54 +0200 | [diff] [blame] | 342 | "../third_party:zlib", |
Lei Zhang | eb39cdb | 2017-03-31 12:26:15 -0700 | [diff] [blame] | 343 | "//:freetype_common", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 344 | ] |
Lei Zhang | 40f9d72 | 2020-01-24 00:18:11 +0000 | [diff] [blame] | 345 | public_deps = [ ":skia_core_and_effects" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 346 | |
Lei Zhang | 2f5f955 | 2020-08-05 18:51:25 +0000 | [diff] [blame] | 347 | if (is_linux || is_chromeos) { |
Lei Zhang | e4e6d58 | 2022-03-01 17:48:00 +0000 | [diff] [blame] | 348 | deps += [ |
| 349 | "//third_party:fontconfig", |
| 350 | "//third_party/icu:icuuc", |
| 351 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | if (is_android) { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 355 | deps += [ |
Hui Yingst | 6c11351 | 2023-06-02 01:08:28 +0000 | [diff] [blame] | 356 | "//third_party/cpu_features:ndk_compat", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 357 | "//third_party/expat", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 358 | ] |
| 359 | } |
| 360 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 361 | if (is_android && !is_debug) { |
| 362 | configs -= [ "//build/config/compiler:default_optimization" ] |
| 363 | configs += [ "//build/config/compiler:optimize_max" ] |
| 364 | } |
| 365 | |
| 366 | if (is_ios) { |
Alan Screen | 19e4ef4 | 2022-05-06 21:57:15 +0000 | [diff] [blame] | 367 | frameworks += [ "ImageIO.framework" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 368 | } |
Lei Zhang | 79263ca | 2018-10-31 16:40:24 +0000 | [diff] [blame] | 369 | |
| 370 | if (skia_support_pdf) { |
| 371 | deps += [ "//third_party/sfntly" ] |
| 372 | sources += skia_pdf_sources |
| 373 | } else { |
| 374 | sources += [ "//third_party/skia/src/pdf/SkDocument_PDF_None.cpp" ] |
| 375 | } |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 378 | # Template for things that are logically part of :skia, but need to be split out |
| 379 | # so custom compile flags can be applied. |
| 380 | # |
| 381 | # These are all opted out of check_includes, due to (logically) being part of |
| 382 | # skia. |
| 383 | template("skia_source_set") { |
| 384 | source_set(target_name) { |
| 385 | forward_variables_from(invoker, "*") |
| 386 | |
| 387 | check_includes = false |
| 388 | |
| 389 | if (!is_debug) { |
| 390 | configs -= [ "//build/config/compiler:default_optimization" ] |
| 391 | configs += [ "//build/config/compiler:optimize_max" ] |
| 392 | } |
| 393 | |
| 394 | configs -= [ "//build/config/compiler:chromium_code" ] |
| 395 | configs += [ |
| 396 | ":skia_config", |
| 397 | ":skia_library_config", |
| 398 | "//build/config/compiler:no_chromium_code", |
| 399 | ] |
| 400 | public_configs = [ ":skia_config" ] |
Lei Zhang | f02c8c9 | 2019-12-05 19:14:23 +0000 | [diff] [blame] | 401 | |
| 402 | if (is_win) { |
| 403 | cflags_cc = [ |
Lei Zhang | 95cf31b | 2020-04-23 16:42:38 +0000 | [diff] [blame] | 404 | "/wd5041", # out-of-line definition for constexpr static data member is |
| 405 | # not needed and is deprecated in C++17 |
Lei Zhang | f02c8c9 | 2019-12-05 19:14:23 +0000 | [diff] [blame] | 406 | ] |
Lei Zhang | f02c8c9 | 2019-12-05 19:14:23 +0000 | [diff] [blame] | 407 | } |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 408 | } |
| 409 | } |
| 410 | |
| 411 | skia_source_set("skia_core_and_effects") { |
Kevin Lubick | 0fb4f6a | 2022-08-15 20:56:25 +0000 | [diff] [blame] | 412 | defines = [] |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 413 | sources = skia_core_sources |
| 414 | sources += skia_effects_sources |
Kevin Lubick | 53dcf78 | 2023-05-31 20:37:36 +0000 | [diff] [blame] | 415 | sources += skia_colorfilters_sources |
Hui Yingst | 4b06202 | 2023-06-27 00:42:15 +0000 | [diff] [blame] | 416 | sources += skia_colorfilters_sksl_sources |
Lei Zhang | ed08652 | 2018-11-01 14:58:49 +0000 | [diff] [blame] | 417 | sources += skia_effects_imagefilter_sources |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 418 | |
| 419 | visibility = [ ":skia" ] |
| 420 | } |
| 421 | |
K. Moon | b33a5a6 | 2022-11-02 18:53:06 +0000 | [diff] [blame] | 422 | # Bits that involve special vector-y hardware. |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 423 | if (current_cpu == "x86" || current_cpu == "x64") { |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 424 | skia_source_set("skia_opts_sse3") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 425 | sources = skia_opts.ssse3_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 426 | if (!is_win || is_clang) { |
| 427 | cflags = [ "-mssse3" ] |
| 428 | } |
| 429 | if (is_win) { |
| 430 | defines = [ "SK_CPU_SSE_LEVEL=31" ] |
| 431 | } |
| 432 | visibility = [ ":skia_opts" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 433 | } |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 434 | skia_source_set("skia_opts_avx") { |
brettw | 784548a | 2016-09-06 11:39:46 -0700 | [diff] [blame] | 435 | sources = skia_opts.avx_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 436 | if (!is_win) { |
| 437 | cflags = [ "-mavx" ] |
| 438 | } |
| 439 | if (is_win) { |
| 440 | cflags = [ "/arch:AVX" ] |
| 441 | } |
| 442 | visibility = [ ":skia_opts" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 443 | } |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 444 | skia_source_set("skia_opts_hsw") { |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 445 | sources = skia_opts.hsw_sources |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 446 | if (!is_win) { |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 447 | cflags = [ |
| 448 | "-mavx2", |
| 449 | "-mbmi", |
| 450 | "-mbmi2", |
| 451 | "-mf16c", |
| 452 | "-mfma", |
| 453 | ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 454 | } |
| 455 | if (is_win) { |
| 456 | cflags = [ "/arch:AVX2" ] |
| 457 | } |
| 458 | visibility = [ ":skia_opts" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 459 | } |
| 460 | } |
Lei Zhang | bd91edf | 2018-10-16 20:34:03 +0000 | [diff] [blame] | 461 | |
| 462 | skia_source_set("skia_opts") { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 463 | cflags = [] |
| 464 | defines = [] |
| 465 | |
| 466 | if (current_cpu == "x86" || current_cpu == "x64") { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 467 | deps = [ |
| 468 | ":skia_opts_avx", |
caryclark | 429a9ff | 2016-10-04 06:32:58 -0700 | [diff] [blame] | 469 | ":skia_opts_hsw", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 470 | ":skia_opts_sse3", |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 471 | ] |
| 472 | } else if (current_cpu == "arm") { |
| 473 | # The assembly uses the frame pointer register (r7 in Thumb/r11 in |
| 474 | # ARM), the compiler doesn't like that. |
| 475 | cflags += [ "-fomit-frame-pointer" ] |
| 476 | |
| 477 | if (arm_version >= 7) { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 478 | if (arm_use_neon || arm_optionally_use_neon) { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 479 | # Root build config sets -mfpu=$arm_fpu, which we expect to be neon |
| 480 | # when running this. |
| 481 | if (!arm_use_neon) { |
| 482 | configs -= [ "//build/config/compiler:compiler_arm_fpu" ] |
| 483 | cflags += [ "-mfpu=neon" ] |
| 484 | } |
| 485 | } |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 486 | } |
| 487 | } else if (current_cpu == "arm64") { |
Brian Osman | 8172e30 | 2023-05-23 22:24:54 +0000 | [diff] [blame] | 488 | # Conditional and empty body needed to avoid assert below |
Kevin Lubick | e6e3ca0 | 2022-09-15 18:48:40 +0000 | [diff] [blame] | 489 | } else if (current_cpu == "mipsel" || current_cpu == "mips64el") { |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 490 | cflags += [ "-fomit-frame-pointer" ] |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 491 | } else { |
Kevin Lubick | e6e3ca0 | 2022-09-15 18:48:40 +0000 | [diff] [blame] | 492 | assert(false, "Unsupported target CPU " + current_cpu) |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | if (is_android && !is_debug) { |
| 496 | configs -= [ "//build/config/compiler:default_optimization" ] |
| 497 | configs += [ "//build/config/compiler:optimize_max" ] |
| 498 | } |
| 499 | |
dsinclair | 11988d7 | 2016-05-04 10:17:00 -0700 | [diff] [blame] | 500 | visibility = [ ":skia" ] |
| 501 | } |