Bug 1309272, part 1 - Add an --enable-skia-pdf configuration option. r=lsalzman
authorJonathan Watt <jwatt@jwatt.org>
Wed, 26 Oct 2016 19:23:07 +0100
changeset 320099 89304c2622668a206897b66c51cd8f048b9106a3
parent 320098 c109df706fa422b3d4fe5656e20e8c1e3cc21060
child 320100 c974afea821bdd83ebedd3adeefe0bbe87cb1fb5
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslsalzman
bugs1309272
milestone52.0a1
Bug 1309272, part 1 - Add an --enable-skia-pdf configuration option. r=lsalzman
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
toolkit/moz.configure
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -212,17 +212,16 @@ def generate_separated_sources(platform_
     'SkLite',
     'codec',
     'SkWGL',
     'SkMemory_malloc',
     'SkOpts_',
     'opts_check_x86',
     'third_party',
     # unused in skia/src/utils
-    'SkBitSet',
     'SkBoundaryPatch',
     'SkCamera',
     'SkCanvasStack',
     'SkCanvasStateUtils',
     'SkCurveMeasure',
     'SkDeferredCanvas',
     'SkDumpCanvas',
     'SkFrontBufferedStream',
@@ -284,16 +283,17 @@ def generate_separated_sources(platform_
     },
     'arm': {
       'skia/src/core/SkUtilsArm.cpp',
     },
     'neon': {
       'skia/src/opts/SkOpts_neon.cpp',
     },
     'none': set(),
+    'pdf': set(),
     'gpu': set()
   })
 
   for plat in platform_sources.keys():
     for value in platform_sources[plat]:
       if isblacklisted(value):
         continue
 
@@ -313,16 +313,24 @@ def generate_separated_sources(platform_
       elif 'gpu' in value or 'Gpu' in value:
         key = 'gpu'
       elif all(value in platform_sources.get(p, {})
                for p in platforms if p != plat):
         key = 'common'
 
       separated[key].add(value)
 
+  if os.system("cd skia && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=linux -D host_os=linux -R pdf gyp/pdf.gyp") != 0:
+    print 'Failed to generate sources for Skia PDF'
+  else:
+    f = open('skia/sources.json');
+    separated['pdf'].add('skia/src/core/SkMD5.cpp');
+    separated['pdf'].update(filter(lambda x: 'pdf' in x, set(v.replace('../', 'skia/') for v in json.load(f))));
+    f.close()
+
   return separated
 
 def uniq(seq):
   seen = set()
   seen_add = seen.add
   return [ x for x in seq if x not in seen and not seen_add(x)]
 
 def write_cflags(f, values, subsearch, cflag, indent):
@@ -368,16 +376,17 @@ unified_blacklist = [
   'SkAdvancedTypefaceMetrics',
   'SkBitmapProcState_matrixProcs.cpp',
   'SkBlitter_A8.cpp',
   'SkBlitter_ARGB32.cpp',
   'SkBlitter_RGB16.cpp',
   'SkBlitter_Sprite.cpp',
   'SkScan_Antihair.cpp',
   'SkParse.cpp',
+  'SkPDFFont.cpp',
   'SkPictureData.cpp',
   'GrDrawContext',
   'GrResourceCache',
   'GrAA',
   'GrGL',
   'GrBatchAtlas.cpp',
   'GrMSAAPathRenderer.cpp',
   'GrNonAAFillRect',
@@ -435,16 +444,19 @@ def write_mozbuild(sources):
   filename = 'moz.build'
   f = open(filename, 'w')
 
   f.write(header)
 
   write_sources(f, sources['common'], 0)
   write_cflags(f, sources['common'], opt_whitelist, 'skia_opt_flags', 0)
 
+  f.write("if CONFIG['MOZ_ENABLE_SKIA_PDF']:\n")
+  write_sources(f, sources['pdf'], 4)
+
   f.write("if CONFIG['MOZ_ENABLE_SKIA_GPU']:\n")
   write_sources(f, sources['gpu'], 4)
 
   f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android'):\n")
   write_sources(f, sources['android'], 4)
 
   f.write("if CONFIG['MOZ_WIDGET_TOOLKIT'] in {'cocoa', 'uikit'}:\n")
   write_sources(f, sources['mac'], 4)
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -302,16 +302,40 @@ SOURCES['skia/src/core/SkBlitter_ARGB32.
 SOURCES['skia/src/core/SkBlitter_PM4f.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkBlitter_RGB16.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkBlitter_Sprite.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkMatrix.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkOpts.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkSpriteBlitter4f.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkSpriteBlitter_ARGB32.cpp'].flags += skia_opt_flags
 SOURCES['skia/src/core/SkSpriteBlitter_RGB16.cpp'].flags += skia_opt_flags
+if CONFIG['MOZ_ENABLE_SKIA_PDF']:
+    UNIFIED_SOURCES += [
+        'skia/src/core/SkMD5.cpp',
+        'skia/src/pdf/SkDeflate.cpp',
+        'skia/src/pdf/SkJpegInfo.cpp',
+        'skia/src/pdf/SkPDFBitmap.cpp',
+        'skia/src/pdf/SkPDFCanon.cpp',
+        'skia/src/pdf/SkPDFCanvas.cpp',
+        'skia/src/pdf/SkPDFConvertType1FontStream.cpp',
+        'skia/src/pdf/SkPDFDevice.cpp',
+        'skia/src/pdf/SkPDFDocument.cpp',
+        'skia/src/pdf/SkPDFFormXObject.cpp',
+        'skia/src/pdf/SkPDFGraphicState.cpp',
+        'skia/src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp',
+        'skia/src/pdf/SkPDFMakeToUnicodeCmap.cpp',
+        'skia/src/pdf/SkPDFMetadata.cpp',
+        'skia/src/pdf/SkPDFResourceDict.cpp',
+        'skia/src/pdf/SkPDFShader.cpp',
+        'skia/src/pdf/SkPDFTypes.cpp',
+        'skia/src/pdf/SkPDFUtils.cpp',
+    ]
+    SOURCES += [
+        'skia/src/pdf/SkPDFFont.cpp',
+    ]
 if CONFIG['MOZ_ENABLE_SKIA_GPU']:
     UNIFIED_SOURCES += [
         'skia/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp',
         'skia/src/gpu/batches/GrAnalyticRectBatch.cpp',
         'skia/src/gpu/batches/GrAtlasTextBatch.cpp',
         'skia/src/gpu/batches/GrBatch.cpp',
         'skia/src/gpu/batches/GrCopySurfaceBatch.cpp',
         'skia/src/gpu/batches/GrDashLinePathRenderer.cpp',
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -785,16 +785,31 @@ def skia_gpu(value, skia, target):
     elif value and not skia:
         die('Cannot enable Skia-GPU without enabling Skia')
     if skia and value:
         return True
 
 set_config('MOZ_ENABLE_SKIA_GPU', skia_gpu)
 set_define('USE_SKIA_GPU', skia_gpu)
 
+option('--enable-skia-pdf', help='Enable Skia PDF')
+
+@depends('--enable-skia-pdf', skia, target)
+def skia_pdf(value, skia, target):
+    if value.origin == 'default':
+        if not skia:
+            return None
+    elif value and not skia:
+        die('Cannot enable Skia PDF without enabling Skia')
+    if skia and value:
+        return True
+
+set_config('MOZ_ENABLE_SKIA_PDF', skia_pdf)
+set_define('MOZ_ENABLE_SKIA_PDF', skia_pdf)
+
 @depends(skia, skia_gpu)
 def skia_includes(skia, skia_gpu):
     includes = []
     if skia:
         includes += [
             '/gfx/skia',
             '/gfx/skia/skia/include/config',
             '/gfx/skia/skia/include/core',