Home | History | Annotate | Download | only in skia
      1 # Copyright 2013 The Chromium Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 
      6 # This gyp file contains the platform-specific optimizations for Skia
      7 {
      8   'targets': [
      9     # Due to an unfortunate intersection of lameness between gcc and gyp,
     10     # we have to build the *_SSE2.cpp files in a separate target.  The
     11     # gcc lameness is that, in order to compile SSE2 intrinsics code, it
     12     # must be passed the -msse2 flag.  However, with this flag, it may
     13     # emit SSE2 instructions even for scalar code, such as the CPUID
     14     # test used to test for the presence of SSE2.  So that, and all other
     15     # code must be compiled *without* -msse2.  The gyp lameness is that it
     16     # does not allow file-specific CFLAGS, so we must create this extra
     17     # target for those files to be compiled with -msse2.
     18     #
     19     # This is actually only a problem on 32-bit Linux (all Intel Macs have
     20     # SSE2, Linux x86_64 has SSE2 by definition, and MSC will happily emit
     21     # SSE2 from instrinsics, which generating plain ol' 386 for everything
     22     # else).  However, to keep the .gyp file simple and avoid platform-specific
     23     # build breakage, we do this on all platforms.
     24 
     25     # For about the same reason, we need to compile the ARM opts files
     26     # separately as well.
     27     {
     28       'target_name': 'skia_opts',
     29       'type': 'static_library',
     30       'includes': [
     31         'skia_common.gypi',
     32         '../build/android/increase_size_for_speed.gypi',
     33       ],
     34       'include_dirs': [
     35         '../third_party/skia/include/core',
     36         '../third_party/skia/include/effects',
     37         '../third_party/skia/src/core',
     38         '../third_party/skia/src/opts',
     39         '../third_party/skia/src/utils',
     40       ],
     41       'conditions': [
     42         [ 'os_posix == 1 and OS != "mac" and OS != "android" and \
     43            target_arch != "arm" and target_arch != "arm64" and \
     44            target_arch != "mipsel" and target_arch != "mips64el"', {
     45           'cflags': [
     46             '-msse2',
     47           ],
     48         }],
     49         [ 'target_arch != "arm" and target_arch != "mipsel" and \
     50            target_arch != "arm64" and target_arch != "mips64el"', {
     51           'sources': [
     52             '../third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp',
     53             '../third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp',
     54             '../third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp',
     55             '../third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp',
     56             '../third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp',
     57             '../third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp',
     58             '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
     59             '../third_party/skia/src/opts/SkUtils_opts_SSE2.cpp',
     60             '../third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp',
     61           ],
     62           'dependencies': [
     63             'skia_opts_ssse3',
     64             'skia_opts_sse4',
     65           ],
     66         }],
     67         [ 'target_arch == "arm"', {
     68           'conditions': [
     69             [ 'arm_version >= 7 and (arm_neon == 1 or arm_neon_optional == 1)', {
     70               'dependencies': [
     71                 'skia_opts_neon',
     72               ]
     73            }],
     74           ],
     75           # The assembly uses the frame pointer register (r7 in Thumb/r11 in
     76           # ARM), the compiler doesn't like that. Explicitly remove the
     77           # -fno-omit-frame-pointer flag for Android, as that gets added to all
     78           # targets via common.gypi.
     79           'cflags!': [
     80             '-fno-omit-frame-pointer',
     81             '-marm',
     82             '-mapcs-frame',
     83           ],
     84           'cflags': [
     85             '-fomit-frame-pointer',
     86           ],
     87           'sources': [
     88             '../third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp',
     89           ],
     90         }],
     91         [ 'target_arch == "arm" and (arm_version < 7 or arm_neon == 0)', {
     92           'sources': [
     93             '../third_party/skia/src/opts/memset.arm.S',
     94           ],
     95         }],
     96         [ 'target_arch == "arm" and arm_version < 6', {
     97           'sources': [
     98             '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
     99             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    100             '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
    101             '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
    102             '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
    103             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    104             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    105           ],
    106         }],
    107         [ 'target_arch == "arm" and arm_version >= 6', {
    108           'sources': [
    109             '../third_party/skia/src/opts/SkBlitMask_opts_arm.cpp',
    110             '../third_party/skia/src/opts/SkBlitRow_opts_arm.cpp',
    111             '../third_party/skia/src/opts/SkBlitRow_opts_arm.h',
    112             '../third_party/skia/src/opts/SkBlurImage_opts_arm.cpp',
    113             '../third_party/skia/src/opts/SkMorphology_opts_arm.cpp',
    114             '../third_party/skia/src/opts/SkTextureCompression_opts_arm.cpp',
    115             '../third_party/skia/src/opts/SkUtils_opts_arm.cpp',
    116             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    117           ],
    118         }],
    119         [ 'target_arch == "mipsel" or target_arch == "mips64el"',{
    120           'cflags': [
    121             '-fomit-frame-pointer',
    122           ],
    123           'sources': [
    124             '../third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp',
    125             '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
    126             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    127             '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
    128             '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
    129             '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
    130             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    131             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    132           ],
    133         }],
    134         [ 'target_arch == "arm64"', {
    135           'sources': [
    136             '../third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp',
    137             '../third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
    138             '../third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp',
    139             '../third_party/skia/src/opts/SkBlitMask_opts_arm.cpp',
    140             '../third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
    141             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    142             '../third_party/skia/src/opts/SkBlurImage_opts_arm.cpp',
    143             '../third_party/skia/src/opts/SkBlurImage_opts_neon.cpp',
    144             '../third_party/skia/src/opts/SkMorphology_opts_arm.cpp',
    145             '../third_party/skia/src/opts/SkMorphology_opts_neon.cpp',
    146             '../third_party/skia/src/opts/SkTextureCompression_opts_arm.cpp',
    147             '../third_party/skia/src/opts/SkTextureCompression_opts_neon.cpp',
    148             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    149             '../third_party/skia/src/opts/SkXfermode_opts_arm.cpp',
    150             '../third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp',
    151           ],
    152         }],
    153       ],
    154     },
    155     # For the same lame reasons as what is done for skia_opts, we have to
    156     # create another target specifically for SSSE3 code as we would not want
    157     # to compile the SSE2 code with -mssse3 which would potentially allow
    158     # gcc to generate SSSE3 code.
    159     {
    160       'target_name': 'skia_opts_ssse3',
    161       'type': 'static_library',
    162       'includes': [
    163         'skia_common.gypi',
    164         '../build/android/increase_size_for_speed.gypi',
    165       ],
    166       'include_dirs': [
    167         '../third_party/skia/include/core',
    168         '../third_party/skia/include/effects',
    169         '../third_party/skia/src/core',
    170       ],
    171       'conditions': [
    172         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
    173           'cflags': [
    174             '-mssse3',
    175           ],
    176         }],
    177         [ 'OS == "mac"', {
    178           'xcode_settings': {
    179             'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS': 'YES',
    180           },
    181         }],
    182         [ 'OS == "win" and clang == 1', {
    183           # cl.exe's /arch flag doesn't have a setting for SSSE3, and cl.exe
    184           # doesn't need it for intrinsics. clang-cl does need it, though.
    185           'msvs_settings': {
    186             'VCCLCompilerTool': { 'AdditionalOptions': [ '-mssse3' ] },
    187           },
    188         }],
    189         [ 'OS == "win"', {
    190           'include_dirs': [
    191             'config/win',
    192           ],
    193           'direct_dependent_settings': {
    194             'include_dirs': [
    195               'config/win',
    196             ],
    197           },
    198           'defines' : [
    199             'SK_CPU_SSE_LEVEL=31'
    200           ],
    201         }],
    202         [ 'target_arch != "arm" and target_arch != "arm64" and \
    203            target_arch != "mipsel" and target_arch != "mips64el"', {
    204           'sources': [
    205             '../third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp',
    206           ],
    207         }],
    208       ],
    209     },
    210     # For the same lame reasons as what is done for skia_opts, we also have to
    211     # create another target specifically for SSE4 code as we would not want
    212     # to compile the SSE2 code with -msse4 which would potentially allow
    213     # gcc to generate SSE4 code.
    214     {
    215       'target_name': 'skia_opts_sse4',
    216       'type': 'static_library',
    217       'includes': [
    218         'skia_common.gypi',
    219         '../build/android/increase_size_for_speed.gypi',
    220       ],
    221       'include_dirs': [
    222         '../third_party/skia/include/core',
    223         '../third_party/skia/src/core',
    224       ],
    225       'sources': [
    226         '../third_party/skia/src/opts/SkBlurImage_opts_SSE4.cpp',
    227       ],
    228       'conditions': [
    229         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
    230           'cflags': [
    231             '-msse4.1',
    232           ],
    233         }],
    234         [ 'OS == "mac"', {
    235           'xcode_settings': {
    236             'GCC_ENABLE_SSE41_EXTENSIONS': 'YES',
    237           },
    238         }],
    239         [ 'OS == "win" and clang == 1', {
    240           # cl.exe's /arch flag doesn't have a setting for SSE4.1, and cl.exe
    241           # doesn't need it for intrinsics. clang-cl does need it, though.
    242           'msvs_settings': {
    243             'VCCLCompilerTool': { 'AdditionalOptions': [ '-msse4.1' ] },
    244           },
    245         }],
    246         [ 'OS == "win"', {
    247           'defines' : [
    248             'SK_CPU_SSE_LEVEL=41'
    249           ],
    250         }],
    251         [ 'target_arch == "x64"', {
    252           'sources': [
    253             '../third_party/skia/src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
    254           ],
    255         }],
    256         [ 'target_arch == "ia32"', {
    257           'sources': [
    258             '../third_party/skia/src/opts/SkBlitRow_opts_SSE4_asm.S',
    259           ],
    260         }],
    261       ],
    262     },
    263     {
    264       'target_name': 'skia_opts_none',
    265       'type': 'static_library',
    266       'includes': [
    267         'skia_common.gypi',
    268         '../build/android/increase_size_for_speed.gypi',
    269       ],
    270       'include_dirs': [
    271         '../third_party/skia/include/core',
    272         '../third_party/skia/include/effects',
    273         '../third_party/skia/src/core',
    274         '../third_party/skia/src/utils',
    275       ],
    276       'sources': [
    277         '../third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp',
    278         '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
    279         '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    280         '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
    281         '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
    282         '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
    283         '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    284         '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    285       ],
    286     },
    287   ],
    288   'conditions': [
    289     # NEON code must be compiled with -mfpu=neon which also affects scalar
    290     # code. To support dynamic NEON code paths, we need to build all
    291     # NEON-specific sources in a separate static library. The situation
    292     # is very similar to the SSSE3 one.
    293     ['target_arch == "arm" and (arm_neon == 1 or arm_neon_optional == 1)', {
    294       'targets': [
    295         {
    296           'target_name': 'skia_opts_neon',
    297           'type': 'static_library',
    298           'includes': [
    299             'skia_common.gypi',
    300             '../build/android/increase_size_for_speed.gypi',
    301           ],
    302           'include_dirs': [
    303             '../third_party/skia/include/core',
    304             '../third_party/skia/include/effects',
    305             '../third_party/skia/src/core',
    306             '../third_party/skia/src/opts',
    307             '../third_party/skia/src/utils',
    308           ],
    309           'cflags!': [
    310             '-fno-omit-frame-pointer',
    311             '-mfpu=vfp',  # remove them all, just in case.
    312             '-mfpu=vfpv3',
    313             '-mfpu=vfpv3-d16',
    314           ],
    315           'cflags': [
    316             '-mfpu=neon',
    317             '-fomit-frame-pointer',
    318           ],
    319           'ldflags': [
    320             '-march=armv7-a',
    321             '-Wl,--fix-cortex-a8',
    322           ],
    323           'sources': [
    324             '../third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp',
    325             '../third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
    326             '../third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h',
    327             '../third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h',
    328             '../third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
    329             '../third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp',
    330             '../third_party/skia/src/opts/SkBlurImage_opts_neon.cpp',
    331             '../third_party/skia/src/opts/SkMorphology_opts_neon.cpp',
    332             '../third_party/skia/src/opts/SkTextureCompression_opts_neon.cpp',
    333             '../third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp',
    334             '../third_party/skia/src/opts/memset16_neon.S',
    335             '../third_party/skia/src/opts/memset32_neon.S',
    336           ],
    337         },
    338       ],
    339     }],
    340   ],
    341 }
    342