mozilla-skia-bmo1136958.patch
changeset 841 d8a3e976dfba
parent 838 d560fce2b8a3
child 842 b199b6c7d84a
equal deleted inserted replaced
837:a1f740acf68e 841:d8a3e976dfba
       
     1 From 8dc9e73b80ec33fe1a1c855829ef1438301a5de1 Mon Sep 17 00:00:00 2001
       
     2 From: Mike Hommey <mh+mozilla@glandium.org>
       
     3 Date: Thu, 26 Feb 2015 14:14:02 +0900
       
     4 Subject: [PATCH 1/2] Bug 1136958 - Remove duplicate
       
     5  SkDiscardableMemory_none.cpp from gfx/skia/moz.build
       
     6 
       
     7 And to do so, cleanup gfx/skia/generate_mozbuild.py a little.
       
     8 ---
       
     9  gfx/skia/generate_mozbuild.py | 53 ++++++++++++++++---------------------------
       
    10  gfx/skia/moz.build            |  1 -
       
    11  2 files changed, 20 insertions(+), 34 deletions(-)
       
    12 
       
    13 diff --git a/configure.in b/configure.in
       
    14 --- a/configure.in
       
    15 +++ b/configure.in
       
    16 @@ -7941,39 +7941,16 @@ if test -z "${GLIB_GMODULE_LIBS}" \
       
    17  fi
       
    18  
       
    19  AC_SUBST_LIST(GLIB_GMODULE_LIBS)
       
    20  
       
    21  dnl ========================================================
       
    22  dnl Graphics checks.
       
    23  dnl ========================================================
       
    24  
       
    25 -if test "${OS_TARGET}" = "WINNT" -o \
       
    26 -        "${OS_ARCH}" = "Darwin" -o \
       
    27 -        "${MOZ_WIDGET_TOOLKIT}" = "android" -o \
       
    28 -        "${MOZ_WIDGET_TOOLKIT}" = "gonk" -o \
       
    29 -        "${MOZ_WIDGET_TOOLKIT}" = "gtk2" -o \
       
    30 -        "${MOZ_WIDGET_TOOLKIT}" = "gtk3"; then
       
    31 -    case "${target_cpu}" in
       
    32 -    i*86*|x86_64|arm)
       
    33 -        MOZ_ENABLE_SKIA=1
       
    34 -        ;;
       
    35 -    *)
       
    36 -        MOZ_ENABLE_SKIA=
       
    37 -        ;;
       
    38 -    esac
       
    39 -else
       
    40 -MOZ_ENABLE_SKIA=
       
    41 -fi
       
    42 -
       
    43 -MOZ_ARG_ENABLE_BOOL(skia,
       
    44 -[  --enable-skia   Enable use of Skia],
       
    45 -MOZ_ENABLE_SKIA=1,
       
    46 -MOZ_ENABLE_SKIA=)
       
    47 -
       
    48  MOZ_ARG_DISABLE_BOOL(skia-gpu,
       
    49  [  --disable-skia-gpu  Disable use of Skia-GPU],
       
    50  MOZ_DISABLE_SKIA_GPU=1,
       
    51  MOZ_DISABLE_SKIA_GPU=)
       
    52  
       
    53  if test "$USE_FC_FREETYPE"; then
       
    54      if test "$COMPILE_ENVIRONMENT"; then
       
    55          dnl ========================================================
       
    56 @@ -8191,30 +8168,26 @@ AC_SUBST(MOZ_TREE_CAIRO)
       
    57  AC_SUBST_LIST(MOZ_CAIRO_CFLAGS)
       
    58  AC_SUBST_LIST(MOZ_CAIRO_LIBS)
       
    59  AC_SUBST_LIST(MOZ_CAIRO_OSLIBS)
       
    60  AC_SUBST(MOZ_TREE_PIXMAN)
       
    61  
       
    62  dnl ========================================================
       
    63  dnl Skia
       
    64  dnl ========================================================
       
    65 -if test "$MOZ_ENABLE_SKIA"; then
       
    66 -  AC_DEFINE(MOZ_ENABLE_SKIA)
       
    67 -  AC_DEFINE(USE_SKIA)
       
    68 -  if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
       
    69 -    AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
       
    70 -  fi
       
    71 -
       
    72 -  if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" -a -z "$MOZ_DISABLE_SKIA_GPU" ; then
       
    73 -    MOZ_ENABLE_SKIA_GPU=1
       
    74 -    AC_DEFINE(USE_SKIA_GPU)
       
    75 -    AC_SUBST(MOZ_ENABLE_SKIA_GPU)
       
    76 -  fi
       
    77 -fi
       
    78 -AC_SUBST(MOZ_ENABLE_SKIA)
       
    79 +AC_DEFINE(USE_SKIA)
       
    80 +if test "${MOZ_WIDGET_TOOLKIT}" = "android" -o x"$MOZ_WIDGET_TOOLKIT" = x"gonk"; then
       
    81 +  AC_DEFINE(SK_BUILD_FOR_ANDROID_NDK)
       
    82 +fi
       
    83 +
       
    84 +if test "${CPU_ARCH}" != "ppc" -a "${CPU_ARCH}" != "ppc64" -a "${CPU_ARCH}" != "sparc" -a -z "$MOZ_DISABLE_SKIA_GPU" ; then
       
    85 +  MOZ_ENABLE_SKIA_GPU=1
       
    86 +  AC_DEFINE(USE_SKIA_GPU)
       
    87 +  AC_SUBST(MOZ_ENABLE_SKIA_GPU)
       
    88 +fi
       
    89  
       
    90  dnl ========================================================
       
    91  dnl Check for nss-shared-helper
       
    92  dnl ========================================================
       
    93  
       
    94    PKG_CHECK_MODULES(NSSHELPER, nss-shared-helper,
       
    95      [MOZ_ENABLE_NSSHELPER=1],
       
    96      [MOZ_ENABLE_NSSHELPER=])
       
    97 diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build
       
    98 --- a/gfx/2d/moz.build
       
    99 +++ b/gfx/2d/moz.build
       
   100 @@ -59,49 +59,44 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wi
       
   101          'ScaledFontDWrite.cpp',
       
   102          'ScaledFontWin.cpp',
       
   103          'SourceSurfaceD2D.cpp',
       
   104          'SourceSurfaceD2D1.cpp',
       
   105          'SourceSurfaceD2DTarget.cpp',
       
   106      ]
       
   107      DEFINES['WIN32'] = True
       
   108  
       
   109 -if CONFIG['MOZ_ENABLE_SKIA']:
       
   110 -    UNIFIED_SOURCES += [
       
   111 -        'convolver.cpp',
       
   112 -        'DrawTargetSkia.cpp',
       
   113 -        'PathSkia.cpp',
       
   114 -        'SourceSurfaceSkia.cpp',
       
   115 -    ]
       
   116 -    SOURCES += [
       
   117 -        'image_operations.cpp', # Uses _USE_MATH_DEFINES
       
   118 -    ]
       
   119 -    EXPORTS.mozilla.gfx += [
       
   120 -        'HelpersSkia.h',
       
   121 -    ]
       
   122 +UNIFIED_SOURCES += [
       
   123 +    'convolver.cpp',
       
   124 +    'DrawTargetSkia.cpp',
       
   125 +    'PathSkia.cpp',
       
   126 +    'SourceSurfaceSkia.cpp',
       
   127 +]
       
   128 +SOURCES += [
       
   129 +    'image_operations.cpp', # Uses _USE_MATH_DEFINES
       
   130 +]
       
   131 +EXPORTS.mozilla.gfx += [
       
   132 +    'HelpersSkia.h',
       
   133 +]
       
   134  
       
   135  # Are we targeting x86 or x64?  If so, build SSE2 files.
       
   136  if CONFIG['INTEL_ARCHITECTURE']:
       
   137      SOURCES += [
       
   138          'BlurSSE2.cpp',
       
   139 +        'convolverSSE2.cpp',
       
   140          'FilterProcessingSSE2.cpp',
       
   141          'ImageScalingSSE2.cpp',
       
   142      ]
       
   143 -    if CONFIG['MOZ_ENABLE_SKIA']:
       
   144 -        SOURCES += [
       
   145 -            'convolverSSE2.cpp',
       
   146 -        ]
       
   147      DEFINES['USE_SSE2'] = True
       
   148      # The file uses SSE2 intrinsics, so it needs special compile flags on some
       
   149      # compilers.
       
   150      SOURCES['BlurSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
       
   151      SOURCES['FilterProcessingSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
       
   152      SOURCES['ImageScalingSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
       
   153 -    if CONFIG['MOZ_ENABLE_SKIA']:
       
   154 -        SOURCES['convolverSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
       
   155 +    SOURCES['convolverSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
       
   156  
       
   157  UNIFIED_SOURCES += [
       
   158      'Blur.cpp',
       
   159      'DataSourceSurface.cpp',
       
   160      'DataSurfaceHelpers.cpp',
       
   161      'DrawEventRecorder.cpp',
       
   162      'DrawTarget.cpp',
       
   163      'DrawTargetCairo.cpp',
       
   164 diff --git a/gfx/moz.build b/gfx/moz.build
       
   165 --- a/gfx/moz.build
       
   166 +++ b/gfx/moz.build
       
   167 @@ -17,16 +17,15 @@ DIRS += [
       
   168      'layers',
       
   169      'graphite2/src',
       
   170      'harfbuzz/src',
       
   171      'ots/src',
       
   172      'thebes',
       
   173      'ipc',
       
   174  ]
       
   175  
       
   176 -if CONFIG['MOZ_ENABLE_SKIA']:
       
   177 -    DIRS += ['skia']
       
   178 +DIRS += ['skia']
       
   179  
       
   180  if CONFIG['ENABLE_TESTS']:
       
   181      DIRS += ['tests/gtest']
       
   182  
       
   183  TEST_DIRS += ['tests']
       
   184  
       
   185 diff --git a/gfx/skia/generate_mozbuild.py b/gfx/skia/generate_mozbuild.py
       
   186 --- a/gfx/skia/generate_mozbuild.py
       
   187 +++ b/gfx/skia/generate_mozbuild.py
       
   188 @@ -1,13 +1,14 @@
       
   189  #!/usr/bin/env python
       
   190  
       
   191  import os
       
   192  
       
   193  import locale
       
   194 +from collections import defaultdict
       
   195  locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
       
   196  
       
   197  header = """
       
   198  #
       
   199  #   #####   #######           #     #     #     #     #     #
       
   200  # ##     #  #     #          # #    #  #  #    # #     #   #
       
   201  # ##        #     #         #   #   #  #  #   #   #     # #
       
   202  # ##  ####  #     #        #     #  #  #  #  #     #     #
       
   203 @@ -187,17 +188,17 @@ def generate_platform_sources():
       
   204  
       
   205    for plat in platforms:
       
   206      if os.system("cd trunk && GYP_GENERATORS=dump_mozbuild ./gyp_skia -D OS=%s gyp/skia_lib.gyp" % plat) != 0:
       
   207        print 'Failed to generate sources for ' + plat
       
   208        continue
       
   209  
       
   210  
       
   211      f = open('trunk/sources.json');
       
   212 -    sources[plat] = set(json.load(f));
       
   213 +    sources[plat] = set(v.replace('../', 'trunk/') for v in json.load(f));
       
   214      f.close()
       
   215  
       
   216    return dict(sources.items() + generate_opt_sources().items())
       
   217  
       
   218  
       
   219  def generate_separated_sources(platform_sources):
       
   220    blacklist = [
       
   221      'ChromeUtils',
       
   222 @@ -232,17 +233,17 @@ def generate_separated_sources(platform_
       
   223  
       
   224    def isblacklisted(value):
       
   225      for item in blacklist:
       
   226        if value.find(item) >= 0:
       
   227          return True
       
   228  
       
   229      return False
       
   230  
       
   231 -  separated = {
       
   232 +  separated = defaultdict(set, {
       
   233      'common': {
       
   234        #'trunk/src/effects/gradients/SkGradientTileProc.cpp',
       
   235        'trunk/src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
       
   236        'trunk/src/ports/SkDiscardableMemory_none.cpp',
       
   237        'trunk/src/ports/SkImageDecoder_empty.cpp',
       
   238        'trunk/src/ports/SkMemory_mozalloc.cpp',
       
   239        # 'trunk/src/images/SkImages.cpp',
       
   240        # 'trunk/src/images/SkImageRef.cpp',
       
   241 @@ -277,69 +278,55 @@ def generate_separated_sources(platform_
       
   242        'trunk/src/core/SkUtilsArm.cpp',
       
   243      },
       
   244      'neon': {
       
   245        'trunk/src/opts/SkBitmapProcState_arm_neon.cpp',
       
   246      },
       
   247      'none': {
       
   248        'trunk/src/opts/SkUtils_opts_none.cpp',
       
   249      }
       
   250 -  }
       
   251 +  })
       
   252  
       
   253    for plat in platform_sources.keys():
       
   254 -    if not separated.has_key(plat):
       
   255 -      separated[plat] = set()
       
   256 -
       
   257      for value in platform_sources[plat]:
       
   258        if isblacklisted(value):
       
   259          continue
       
   260  
       
   261 -      if value.find('_SSE') > 0 or value.find('_SSSE') > 0 or value.find('_SSE4') > 0 : #lol
       
   262 -        separated['intel'].add(value)
       
   263 +      if value in separated['common']:
       
   264          continue
       
   265  
       
   266 -      if value.find('_neon') > 0:
       
   267 -        separated['neon'].add(value)
       
   268 -        continue
       
   269 +      key = plat
       
   270  
       
   271 -      if value.find('_arm') > 0:
       
   272 -        separated['arm'].add(value)
       
   273 -        continue
       
   274 +      if '_SSE' in value or '_SSSE' in value:
       
   275 +        key = 'intel'
       
   276 +      elif '_neon' in value:
       
   277 +        key = 'neon'
       
   278 +      elif '_arm' in value:
       
   279 +        key = 'arm'
       
   280 +      elif '_none' in value:
       
   281 +        key = 'none'
       
   282 +      elif all(value in platform_sources.get(p, {})
       
   283 +               for p in platforms if p != plat):
       
   284 +        key = 'common'
       
   285  
       
   286 -      if value.find('_none') > 0:
       
   287 -        separated['none'].add(value)
       
   288 -        continue
       
   289 -
       
   290 -      found = True
       
   291 -      for other in platforms:
       
   292 -        if other == plat or not platform_sources.has_key(other):
       
   293 -          continue
       
   294 -
       
   295 -        if not value in platform_sources[other]:
       
   296 -          found = False
       
   297 -          break;
       
   298 -
       
   299 -      if found:
       
   300 -        separated['common'].add(value)
       
   301 -      else:
       
   302 -        separated[plat].add(value)
       
   303 +      separated[key].add(value)
       
   304  
       
   305    return separated
       
   306  
       
   307  def uniq(seq):
       
   308    seen = set()
       
   309    seen_add = seen.add
       
   310    return [ x for x in seq if x not in seen and not seen_add(x)]
       
   311  
       
   312  def write_cflags(f, values, subsearch, cflag, indent):
       
   313    def write_indent(indent):
       
   314      for _ in range(indent):
       
   315          f.write(' ')
       
   316  
       
   317 -  val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
       
   318 +  val_list = uniq(sorted(values, key=lambda x: x.lower()))
       
   319  
       
   320    if len(val_list) == 0:
       
   321      return
       
   322  
       
   323    for val in val_list:
       
   324      if val.find(subsearch) > 0:
       
   325        write_indent(indent)
       
   326        f.write("SOURCES[\'" + val + "\'].flags += [\'" + cflag + "\']\n")
       
   327 @@ -391,17 +378,17 @@ def write_sources(f, values, indent):
       
   328    write_list(f, "UNIFIED_SOURCES", sources['unified'], indent)
       
   329    write_list(f, "SOURCES", sources['nonunified'], indent)
       
   330    
       
   331  def write_list(f, name, values, indent):
       
   332    def write_indent(indent):
       
   333      for _ in range(indent):
       
   334          f.write(' ')
       
   335  
       
   336 -  val_list = uniq(sorted(map(lambda val: val.replace('../', 'trunk/'), values), key=lambda x: x.lower()))
       
   337 +  val_list = uniq(sorted(values, key=lambda x: x.lower()))
       
   338  
       
   339    if len(val_list) == 0:
       
   340      return
       
   341  
       
   342    write_indent(indent)
       
   343    f.write(name + ' += [\n')
       
   344    for val in val_list:
       
   345      write_indent(indent + 4)
       
   346 diff --git a/gfx/skia/moz.build b/gfx/skia/moz.build
       
   347 --- a/gfx/skia/moz.build
       
   348 +++ b/gfx/skia/moz.build
       
   349 @@ -847,17 +847,16 @@ else:
       
   350          'trunk/src/opts/SkBitmapProcState_opts_none.cpp',
       
   351          'trunk/src/opts/SkBlitMask_opts_none.cpp',
       
   352          'trunk/src/opts/SkBlitRow_opts_none.cpp',
       
   353          'trunk/src/opts/SkBlurImage_opts_none.cpp',
       
   354          'trunk/src/opts/SkMorphology_opts_none.cpp',
       
   355          'trunk/src/opts/SkTextureCompression_opts_none.cpp',
       
   356          'trunk/src/opts/SkUtils_opts_none.cpp',
       
   357          'trunk/src/opts/SkXfermode_opts_none.cpp',
       
   358 -        'trunk/src/ports/SkDiscardableMemory_none.cpp',
       
   359      ]
       
   360  
       
   361  
       
   362  # can we find a better way of dealing with asm sources?
       
   363  
       
   364  # left out of UNIFIED_SOURCES for now; that's not C++ anyway, nothing else to unify it with
       
   365  if not CONFIG['INTEL_ARCHITECTURE'] and CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_CC']:
       
   366      SOURCES += [
       
   367 diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp
       
   368 --- a/image/src/RasterImage.cpp
       
   369 +++ b/image/src/RasterImage.cpp
       
   370 @@ -313,21 +313,16 @@ RasterImage::Init(const char* aMimeType,
       
   371  
       
   372    // Store initialization data
       
   373    mSourceDataMimeType.Assign(aMimeType);
       
   374    mDiscardable = !!(aFlags & INIT_FLAG_DISCARDABLE);
       
   375    mDecodeOnDraw = !!(aFlags & INIT_FLAG_DECODE_ON_DRAW);
       
   376    mTransient = !!(aFlags & INIT_FLAG_TRANSIENT);
       
   377    mDownscaleDuringDecode = !!(aFlags & INIT_FLAG_DOWNSCALE_DURING_DECODE);
       
   378  
       
   379 -#ifndef MOZ_ENABLE_SKIA
       
   380 -  // Downscale-during-decode requires Skia.
       
   381 -  mDownscaleDuringDecode = false;
       
   382 -#endif
       
   383 -
       
   384    // Lock this image's surfaces in the SurfaceCache if we're not discardable.
       
   385    if (!mDiscardable) {
       
   386      SurfaceCache::LockImage(ImageKey(this));
       
   387    }
       
   388  
       
   389    // Create the initial size decoder.
       
   390    nsresult rv = Decode(Nothing(), DECODE_FLAGS_DEFAULT);
       
   391    if (NS_FAILED(rv)) {
       
   392 @@ -1556,20 +1551,16 @@ RasterImage::RecoverFromLossOfFrames(con
       
   393    Decode(Some(aSize), aFlags);
       
   394  }
       
   395  
       
   396  bool
       
   397  RasterImage::CanScale(GraphicsFilter aFilter,
       
   398                        const nsIntSize& aSize,
       
   399                        uint32_t aFlags)
       
   400  {
       
   401 -#ifndef MOZ_ENABLE_SKIA
       
   402 -  // The high-quality scaler requires Skia.
       
   403 -  return false;
       
   404 -#else
       
   405    // Check basic requirements: HQ downscaling is enabled, we have all the source
       
   406    // data and know our size, the flags allow us to do it, and a 'good' filter is
       
   407    // being used. The flags may ask us not to scale because the caller isn't
       
   408    // drawing to the window. If we're drawing to something else (e.g. a canvas)
       
   409    // we usually have no way of updating what we've drawn, so HQ scaling is
       
   410    // useless.
       
   411    if (!gfxPrefs::ImageHQDownscalingEnabled() || !mHasSize || !mHasSourceData ||
       
   412        !(aFlags & imgIContainer::FLAG_HIGH_QUALITY_SCALING) ||
       
   413 @@ -1609,17 +1600,16 @@ RasterImage::CanScale(GraphicsFilter aFi
       
   414    // XXX(seth): It's not clear what this check buys us over
       
   415    // gfxPrefs::ImageHQUpscalingMaxSize().
       
   416    // The default value of this pref is 1000, which means that we never upscale.
       
   417    // If that's all it's getting us, I'd rather we just forbid that explicitly.
       
   418    gfx::Size scale(double(aSize.width) / mSize.width,
       
   419                    double(aSize.height) / mSize.height);
       
   420    gfxFloat minFactor = gfxPrefs::ImageHQDownscalingMinFactor() / 1000.0;
       
   421    return (scale.width < minFactor || scale.height < minFactor);
       
   422 -#endif
       
   423  }
       
   424  
       
   425  bool
       
   426  RasterImage::CanDownscaleDuringDecode(const nsIntSize& aSize, uint32_t aFlags)
       
   427  {
       
   428    // Check basic requirements: downscale-during-decode is enabled for this
       
   429    // image, we have all the source data and know our size, the flags allow us to
       
   430    // do it, and a 'good' filter is being used.