# Copyright 2018 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/freetype/freetype.gni")
import("../../pdfium.gni")
import("../../testing/test.gni")

source_set("fxge") {
  sources = [
    "agg/cfx_agg_bitmapcomposer.cpp",
    "agg/cfx_agg_bitmapcomposer.h",
    "agg/cfx_agg_cliprgn.cpp",
    "agg/cfx_agg_cliprgn.h",
    "agg/cfx_agg_devicedriver.cpp",
    "agg/cfx_agg_devicedriver.h",
    "agg/cfx_agg_imagerenderer.cpp",
    "agg/cfx_agg_imagerenderer.h",
    "calculate_pitch.cpp",
    "calculate_pitch.h",
    "cfx_color.cpp",
    "cfx_color.h",
    "cfx_defaultrenderdevice.cpp",
    "cfx_defaultrenderdevice.h",
    "cfx_drawutils.cpp",
    "cfx_drawutils.h",
    "cfx_face.cpp",
    "cfx_face.h",
    "cfx_fillrenderoptions.h",
    "cfx_folderfontinfo.cpp",
    "cfx_folderfontinfo.h",
    "cfx_font.cpp",
    "cfx_font.h",
    "cfx_fontcache.cpp",
    "cfx_fontcache.h",
    "cfx_fontmapper.cpp",
    "cfx_fontmapper.h",
    "cfx_fontmgr.cpp",
    "cfx_fontmgr.h",
    "cfx_gemodule.cpp",
    "cfx_gemodule.h",
    "cfx_glyphbitmap.cpp",
    "cfx_glyphbitmap.h",
    "cfx_glyphcache.cpp",
    "cfx_glyphcache.h",
    "cfx_graphstate.cpp",
    "cfx_graphstate.h",
    "cfx_graphstatedata.cpp",
    "cfx_graphstatedata.h",
    "cfx_path.cpp",
    "cfx_path.h",
    "cfx_renderdevice.cpp",
    "cfx_renderdevice.h",
    "cfx_substfont.cpp",
    "cfx_substfont.h",
    "cfx_textrenderoptions.h",
    "cfx_unicodeencoding.cpp",
    "cfx_unicodeencoding.h",
    "dib/blend.cpp",
    "dib/blend.h",
    "dib/cfx_bitmapstorer.cpp",
    "dib/cfx_bitmapstorer.h",
    "dib/cfx_cmyk_to_srgb.cpp",
    "dib/cfx_cmyk_to_srgb.h",
    "dib/cfx_dibbase.cpp",
    "dib/cfx_dibbase.h",
    "dib/cfx_dibitmap.cpp",
    "dib/cfx_dibitmap.h",
    "dib/cfx_imagestretcher.cpp",
    "dib/cfx_imagestretcher.h",
    "dib/cfx_imagetransformer.cpp",
    "dib/cfx_imagetransformer.h",
    "dib/cfx_scanlinecompositor.cpp",
    "dib/cfx_scanlinecompositor.h",
    "dib/cstretchengine.cpp",
    "dib/cstretchengine.h",
    "dib/fx_dib.cpp",
    "dib/fx_dib.h",
    "dib/scanlinecomposer_iface.h",
    "fontdata/chromefontdata/FoxitDingbats.cpp",
    "fontdata/chromefontdata/FoxitFixed.cpp",
    "fontdata/chromefontdata/FoxitFixedBold.cpp",
    "fontdata/chromefontdata/FoxitFixedBoldItalic.cpp",
    "fontdata/chromefontdata/FoxitFixedItalic.cpp",
    "fontdata/chromefontdata/FoxitSans.cpp",
    "fontdata/chromefontdata/FoxitSansBold.cpp",
    "fontdata/chromefontdata/FoxitSansBoldItalic.cpp",
    "fontdata/chromefontdata/FoxitSansItalic.cpp",
    "fontdata/chromefontdata/FoxitSansMM.cpp",
    "fontdata/chromefontdata/FoxitSerif.cpp",
    "fontdata/chromefontdata/FoxitSerifBold.cpp",
    "fontdata/chromefontdata/FoxitSerifBoldItalic.cpp",
    "fontdata/chromefontdata/FoxitSerifItalic.cpp",
    "fontdata/chromefontdata/FoxitSerifMM.cpp",
    "fontdata/chromefontdata/FoxitSymbol.cpp",
    "fontdata/chromefontdata/chromefontdata.h",
    "freetype/fx_freetype.cpp",
    "freetype/fx_freetype.h",
    "fx_font.cpp",
    "fx_font.h",
    "fx_fontencoding.h",
    "render_defines.h",
    "renderdevicedriver_iface.cpp",
    "renderdevicedriver_iface.h",
    "scoped_font_transform.cpp",
    "scoped_font_transform.h",
    "systemfontinfo_iface.h",
    "text_char_pos.cpp",
    "text_char_pos.h",
    "text_glyph_pos.cpp",
    "text_glyph_pos.h",
  ]

  configs += [
    "../../:pdfium_strict_config",
    "../../:pdfium_noshorten_config",
  ]

  deps = [
    "../../third_party:fx_agg",
    "../fxcrt",
  ]

  public_deps = []

  if (is_component_build || use_system_freetype) {
    # ft_adobe_glyph_list is not exported from the Freetype shared library so we
    # need it defined in component builds and builds using system freetype.
    defines = [ "DEFINE_PS_TABLES_DATA" ]
  }

  if (pdf_enable_xfa) {
    sources += [
      "cfx_unicodeencodingex.cpp",
      "cfx_unicodeencodingex.h",
    ]
  }

  if (pdf_use_skia) {
    sources += [
      "skia/cfx_dibbase_skia.cpp",
      "skia/fx_skia_device.cpp",
    ]
    public_deps += [ "//skia" ]
  }

  if (is_android) {
    sources += [
      "android/cfpf_skiadevicemodule.cpp",
      "android/cfpf_skiadevicemodule.h",
      "android/cfpf_skiafont.cpp",
      "android/cfpf_skiafont.h",
      "android/cfpf_skiafontmgr.cpp",
      "android/cfpf_skiafontmgr.h",
      "android/cfpf_skiapathfont.cpp",
      "android/cfpf_skiapathfont.h",
      "android/cfx_androidfontinfo.cpp",
      "android/cfx_androidfontinfo.h",
      "android/fx_android_impl.cpp",
    ]
  }

  if (is_linux || is_chromeos) {
    sources += [ "linux/fx_linux_impl.cpp" ]
  }

  if (is_mac) {
    sources += [
      "apple/fx_apple_impl.cpp",
      "apple/fx_apple_platform.cpp",
      "apple/fx_apple_platform.h",
      "apple/fx_quartz_device.cpp",
      "apple/fx_quartz_device.h",
    ]
    frameworks = [ "CoreGraphics.framework" ]
  }

  if (is_win) {
    sources += [
      "cfx_windowsrenderdevice.cpp",
      "cfx_windowsrenderdevice.h",
      "win32/cfx_psfonttracker.cpp",
      "win32/cfx_psfonttracker.h",
      "win32/cfx_psrenderer.cpp",
      "win32/cfx_psrenderer.h",
      "win32/cgdi_device_driver.cpp",
      "win32/cgdi_device_driver.h",
      "win32/cgdi_display_driver.cpp",
      "win32/cgdi_display_driver.h",
      "win32/cgdi_plus_ext.cpp",
      "win32/cgdi_plus_ext.h",
      "win32/cgdi_printer_driver.cpp",
      "win32/cgdi_printer_driver.h",
      "win32/cps_printer_driver.cpp",
      "win32/cps_printer_driver.h",
      "win32/cpsoutput.cpp",
      "win32/cpsoutput.h",
      "win32/ctext_only_printer_driver.cpp",
      "win32/ctext_only_printer_driver.h",
      "win32/cwin32_platform.cpp",
      "win32/cwin32_platform.h",
    ]
    configs -= [ "//build/config/win:lean_and_mean" ]
  }

  visibility = [ "../../*" ]
}

pdfium_unittest_source_set("unittests") {
  sources = [
    "cfx_defaultrenderdevice_unittest.cpp",
    "cfx_folderfontinfo_unittest.cpp",
    "cfx_fontmapper_unittest.cpp",
    "cfx_path_unittest.cpp",
    "dib/blend_unittest.cpp",
    "dib/cfx_cmyk_to_srgb_unittest.cpp",
    "dib/cfx_dibbase_unittest.cpp",
    "dib/cfx_dibitmap_unittest.cpp",
    "dib/cfx_scanlinecompositor_unittest.cpp",
    "dib/cstretchengine_unittest.cpp",
    "dib/fx_dib_unittest.cpp",
    "fx_font_unittest.cpp",
  ]
  deps = [
    ":fxge",
    "../fpdfapi/page",
    "../fpdfapi/parser",
  ]
  pdfium_root_dir = "../../"

  if (is_win) {
    sources += [ "win32/cfx_psrenderer_unittest.cpp" ]
  }
}

pdfium_embeddertest_source_set("embeddertests") {
  sources = [ "fx_ge_text_embeddertest.cpp" ]
  deps = []
  pdfium_root_dir = "../../"

  if (pdf_use_skia) {
    sources += [ "skia/fx_skia_device_embeddertest.cpp" ]
    deps += [
      ":fxge",
      "../../fpdfsdk",
      "../fpdfapi/page",
      "../fpdfapi/render",
      "//skia",
    ]
  }

  if (is_win) {
    sources += [ "cfx_windowsrenderdevice_embeddertest.cpp" ]
    deps += [
      ":fxge",
      "../fxcodec",
    ]
  }
}
