summaryrefslogtreecommitdiffstats
path: root/skia/BUILD.gn
blob: 904e8b85d1edca486fc9241098199a42e9305e06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# 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")
if (cpu_arch == "arm") {
  import("//build/config/arm.gni")
}

skia_support_gpu = !is_ios
skia_support_pdf = !is_ios && enable_printing != 0

# The list of Skia files is kept in skia_gn_files.gypi. Read it.
gypi_values = exec_script(
    "//build/gypi_to_gn.py",
    [ rebase_path("skia_gn_files.gypi"),
      "--replace=<(skia_include_path)=//third_party/skia/include",
      "--replace=<(skia_src_path)=//third_party/skia/src" ]
    "scope",
    [ "skia_gn_files.gypi" ])

# External-facing config for dependent code.
config("skia_config") {
  include_dirs = [
    "config",
    "ext",
    "//third_party/skia/include/config",
    "//third_party/skia/include/core",
    "//third_party/skia/include/effects",
    "//third_party/skia/include/images",
    "//third_party/skia/include/lazy",
    "//third_party/skia/include/pathops",
    "//third_party/skia/include/pdf",
    "//third_party/skia/include/pipe",
    "//third_party/skia/include/ports",
    "//third_party/skia/include/utils",
    "//third_party/skia/src/core",
    "//third_party/skia/src/image",
    "//third_party/skia/src/opts",
    "//third_party/skia/src/ports",
    "//third_party/skia/src/sfnt",
    "//third_party/skia/src/utils",
    "//third_party/skia/src/lazy",
  ]

  defines = gypi_values.skia_feature_defines

  if (component_mode == "shared_library") {
    defines += [ "SKIA_DLL" ]
  }

  if (skia_support_gpu) {
    include_dirs += [
      "//third_party/skia/include/gpu",
      "//third_party/skia/src/gpu",
    ]
    defines += [ "SK_SUPPORT_GPU=1" ]
  } else {
    defines += [ "SK_SUPPORT_GPU=0" ]
  }

  # For POSIX platforms, prefer the Mutex implementation provided by Skia
  # since it does not generate static initializers.
  if (is_posix) {
    defines += [ "SK_USE_POSIX_THREADS" ]
  }

  if (is_android) {
    defines += [
      "SK_BUILD_FOR_ANDROID",
      "USE_CHROMIUM_SKIA",
    ]
  }
}

config("skia_dependent_config") {
}

# Internal-facing config for Skia library code.
config("skia_library_config") {
  defines = [
    #skia_export_defines ???) TODO

    # skia uses static initializers to initialize the serialization logic
    # of its "pictures" library. This is currently not used in chrome; if
    # it ever gets used the processes that use it need to call
    # SkGraphics::Init().
    "SK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0",

    # Disable this check because it is too strict for some Chromium-specific
    # subclasses of SkPixelRef. See bug: crbug.com/171776.
    "SK_DISABLE_PIXELREF_LOCKCOUNT_BALANCE_CHECK",

    "IGNORE_ROT_AA_RECT_OPT",

    # Forces Skia not to use typographic metrics with GDI.
    "SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS",
  ]

  # Settings for text blitting, chosen to approximate the system browser.
  if (is_linux) {
    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) {
    include_dirs = [
      "//third_party/skia/include/utils/win",
      "//third_party/skia/src/utils/win",
    ]

    defines += [ "SK_FONTHOST_USES_FONTMGR" ]

    cflags = [
      # TODO(brettw) comment what these are.
      "/wd4244",
      "/wd4267",
      "/wd4341",
      "/wd4345",
      "/wd4390",
      "/wd4554",
      "/wd4748",
      "/wd4800",
    ]
  }
}

component("skia") {
  sources = [
    # Chrome sources.
    "ext/analysis_canvas.cc",
    "ext/analysis_canvas.h",
    "ext/benchmarking_canvas.cc",
    "ext/benchmarking_canvas.h",
    "ext/bitmap_platform_device.h",
    "ext/bitmap_platform_device_cairo.cc",
    "ext/bitmap_platform_device_cairo.h",
    "ext/bitmap_platform_device_mac.cc",
    "ext/bitmap_platform_device_mac.h",
    #"ext/bitmap_platform_device_skia.cc",
    #"ext/bitmap_platform_device_skia.h",
    "ext/bitmap_platform_device_win.cc",
    "ext/bitmap_platform_device_win.h",
    "ext/convolver.cc",
    "ext/convolver.h",
    "ext/event_tracer_impl.cc",
    "ext/event_tracer_impl.h",
    "ext/google_logging.cc",
    "ext/image_operations.cc",
    "ext/image_operations.h",
    "ext/lazy_pixel_ref.cc",
    "ext/lazy_pixel_ref.h",
    "ext/SkThread_chrome.cc",
    "ext/opacity_draw_filter.cc",
    "ext/opacity_draw_filter.h",
    "ext/paint_simplifier.cc",
    "ext/paint_simplifier.h",
    "ext/pixel_ref_utils.cc",
    "ext/pixel_ref_utils.h",
    "ext/platform_canvas.cc",
    "ext/platform_canvas.h",
    "ext/platform_device.cc",
    "ext/platform_device.h",
    "ext/platform_device_linux.cc",
    "ext/platform_device_mac.cc",
    "ext/platform_device_win.cc",
    "ext/recursive_gaussian_convolution.cc",
    "ext/recursive_gaussian_convolution.h",
    "ext/refptr.h",
    "ext/SkDiscardableMemory_chrome.h",
    "ext/SkDiscardableMemory_chrome.cc",
    "ext/SkMemory_new_handler.cpp",
    "ext/skia_trace_shim.h",
    "ext/skia_utils_base.cc",
    "ext/skia_utils_base.h",
    "ext/skia_utils_ios.mm",
    "ext/skia_utils_ios.h",
    "ext/skia_utils_mac.mm",
    "ext/skia_utils_mac.h",
    "ext/skia_utils_win.cc",
    "ext/skia_utils_win.h",
    "ext/vector_canvas.h",
    "ext/vector_platform_device_emf_win.cc",
    "ext/vector_platform_device_emf_win.h",
    "ext/vector_platform_device_skia.cc",
    "ext/vector_platform_device_skia.h",
  ]

  # The skia gypi values are relative to the skia_dir, so we need to rebase.
  sources += gypi_values.skia_core_sources
  sources += gypi_values.skia_effects_sources
  sources += gypi_values.skia_pdf_sources
  sources += gypi_values.skia_library_sources

  # GPU
  if (skia_support_gpu) {
    sources += gypi_values.skia_gpu_sources
  }

  # Fixup Chrome sources.
  if (is_posix) {
    sources -= [ "ext/SkThread_chrome.cc" ]
  }
  if (is_ios) {
    sources -= [ "ext/vector_platform_device_skia.cc" ]
  }
  if (is_win) {
    sources -= [ "ext/SkThread_chrome.cc" ]
  }
  if (is_android && enable_printing == 0) {
    sources -= [
      "ext/skia_utils_base.cc",
      "ext/vector_platform_device_skia.cc"
    ]
  }

  # Fixup skia library sources.
  if (is_win) {
    sources -= [
      "//third_party/skia/src/ports/SkOSFile_posix.cpp",
      "//third_party/skia/src/ports/SkTime_Unix.cpp",
      "//third_party/skia/src/ports/SkTLS_pthread.cpp",
      "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
      "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
    ]
  } else {
    sources -= [
      "//third_party/skia/src/ports/SkFontHost_win.cpp",
      "//third_party/skia/src/ports/SkFontHost_win_dw.cpp",
      "//third_party/skia/src/ports/SkFontMgr_default_gdi.cpp",
      "//third_party/skia/src/ports/SkOSFile_win.cpp",
      "//third_party/skia/src/ports/SkTLS_win.cpp",
      "//third_party/skia/src/utils/SkThreadUtils_win.cpp",
    ]
  }
  if (!is_android) {
    sources -= [
      "//third_party/skia/src/ports/SkFontConfigInterface_android.cpp",
      "//third_party/skia/src/ports/SkFontConfigParser_android.cpp",
    ]
  }
  if (!is_mac) {
    sources -= [
      "//third_party/skia/src/ports/SkFontHost_mac.cpp",
      "//third_party/skia/src/utils/SkThreadUtils_pthread_mach.cpp",
    ]
  }
  if (!is_linux) {
    sources -= [
      "//third_party/skia/src/ports/SkFontHost_FreeType.cpp",
      "//third_party/skia/src/ports/SkFontHost_FreeType_common.cpp",
      "//third_party/skia/src/ports/SkFontHost_fontconfig.cpp",
      "//third_party/skia/src/ports/SkFontHost_linux.cpp",
      "//third_party/skia/src/utils/SkThreadUtils_pthread_linux.cpp",
    ]
  } else if (!is_android) {
    sources -= [
      "//third_party/skia/src/ports/SkFontConfigInterface_direct.cpp",
      "//third_party/skia/src/fonts/SkFontMgr_fontconfig.cpp",
    ]
  }
  if (!is_posix) {
    sources -= [
      "//third_party/skia/src/utils/SkThreadUtils_pthread.cpp",
    ]
  }

  if (!use_cairo) {
    sources -= [
      "ext/bitmap_platform_device_cairo.cc",
      "ext/bitmap_platform_device_cairo.h",
    ]
  }

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    ":skia_library_config",
    "//build/config/compiler:no_chromium_code"
  ]
  direct_dependent_configs = [ ":skia_config" ]

  deps = [
    ":skia_opts",
    "//base",
    "//base/third_party/dynamic_annotations",
    "//third_party/zlib",
  ]

  if (component_mode == "shared_library") {
    defines = [ "SKIA_IMPLEMENTATION=1" ]
  }

  if (is_linux) {
    configs += [
      "//build/config/linux:fontconfig",
      "//build/config/linux:freetype2",
      "//build/config/linux:pangocairo",
    ]
    deps += [
      "//third_party/icu:icuuc",
    ]
  }

  if (skia_support_pdf) {
    deps += [ "//third_party/sfntly" ]
  }
}

# Separated out so it can be compiled with different flags for SSE.
source_set("skia_opts") {
  if (cpu_arch == "x86" || cpu_arch == "x64") {
    sources = [
      # SSE 2
      "//third_party/skia/src/opts/opts_check_SSE2.cpp",
      "//third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkUtils_opts_SSE2.cpp",
      "//third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp",

      # SSE 3
      "//third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp",

      # Chrome-specific.
      "ext/convolver_SSE2.cc",
    ]

    if (is_linux || is_mac) {
      cflags = [ "-mssse3" ]  # Note third 's'.
    }
  } else {
    assert(false, "Need to port ARM/MIPS stuff from skia_library_opts.gyp")
  }

  configs -= [ "//build/config/compiler:chromium_code" ]
  configs += [
    ":skia_config",
    "//build/config/compiler:no_chromium_code"
  ]

  # TODO(brettw) uncomment when visibility is supported.
  #visibility = ":skia"
}