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       ],
     33       'include_dirs': [
     34         '../third_party/skia/include/core',
     35         '../third_party/skia/src/core',
     36         '../third_party/skia/src/opts',
     37       ],
     38       'conditions': [
     39         [ 'os_posix == 1 and OS != "mac" and OS != "android" and \
     40            target_arch != "arm" and target_arch != "mipsel"', {
     41           'cflags': [
     42             '-msse2',
     43           ],
     44         }],
     45         [ 'target_arch != "arm" and target_arch != "mipsel"', {
     46           'sources': [
     47             '../third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp',
     48             '../third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp',
     49             '../third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp',
     50             '../third_party/skia/src/opts/SkUtils_opts_SSE2.cpp',
     51             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
     52             '../third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp',
     53             '../third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp',
     54             '../third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp',
     55           ],
     56           'dependencies': [
     57             'skia_opts_ssse3',
     58           ],
     59         }],
     60         [ 'target_arch == "arm"', {
     61           'conditions': [
     62             [ 'arm_version >= 7 and arm_neon == 1', {
     63               'defines': [
     64                 '__ARM_HAVE_NEON',
     65               ],
     66             }],
     67             [ 'arm_version >= 7 and arm_neon_optional == 1', {
     68               'defines': [
     69                 '__ARM_HAVE_OPTIONAL_NEON_SUPPORT',
     70               ],
     71             }],
     72             [ 'arm_version >= 7 and (arm_neon == 1 or arm_neon_optional == 1)', {
     73               'cflags': [
     74                 # The neon assembly contains conditional instructions which
     75                 # aren't enclosed in an IT block. The assembler complains
     76                 # without this option.
     77                 # See #86592.
     78                 '-Wa,-mimplicit-it=always',
     79               ],
     80               'dependencies': [
     81                 'skia_opts_neon',
     82               ]
     83            }],
     84           ],
     85           # The assembly uses the frame pointer register (r7 in Thumb/r11 in
     86           # ARM), the compiler doesn't like that. Explicitly remove the
     87           # -fno-omit-frame-pointer flag for Android, as that gets added to all
     88           # targets via common.gypi.
     89           'cflags!': [
     90             '-fno-omit-frame-pointer',
     91             '-marm',
     92             '-mapcs-frame',
     93           ],
     94           'cflags': [
     95             '-fomit-frame-pointer',
     96           ],
     97           'sources': [
     98             '../third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp',
     99           ],
    100         }],
    101         [ 'target_arch == "arm" and (arm_version < 7 or (arm_neon == 0 and arm_neon_optional == 1))', {
    102           'sources': [
    103             '../third_party/skia/src/opts/memset.arm.S',
    104           ],
    105         }],
    106         [ 'target_arch == "arm" and arm_version < 6', {
    107           'sources': [
    108             '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
    109             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    110             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    111             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    112             '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
    113             '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
    114           ],
    115         }],
    116         [ 'target_arch == "arm" and arm_version >= 6', {
    117           'sources': [
    118             '../third_party/skia/src/opts/SkBlitMask_opts_arm.cpp',
    119             '../third_party/skia/src/opts/SkBlitRow_opts_arm.cpp',
    120             '../third_party/skia/src/opts/SkBlitRow_opts_arm.h',
    121             '../third_party/skia/src/opts/opts_check_arm.cpp',
    122             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    123           ],
    124         }],
    125         [ 'target_arch == "mipsel"',{
    126           'cflags': [
    127             '-fomit-frame-pointer',
    128           ],
    129           'sources': [
    130             '../third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp',
    131             '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
    132             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    133             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    134             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    135             '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
    136             '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
    137           ],
    138         }],
    139       ],
    140     },
    141     # For the same lame reasons as what is done for skia_opts, we have to
    142     # create another target specifically for SSSE3 code as we would not want
    143     # to compile the SSE2 code with -mssse3 which would potentially allow
    144     # gcc to generate SSSE3 code.
    145     {
    146       'target_name': 'skia_opts_ssse3',
    147       'type': 'static_library',
    148       'includes': [
    149         'skia_common.gypi',
    150       ],
    151       'include_dirs': [
    152         '../third_party/skia/include/core',
    153         '../third_party/skia/src/core',
    154       ],
    155       'conditions': [
    156         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
    157           'cflags': [
    158             '-mssse3',
    159           ],
    160         }],
    161         [ 'OS == "mac"', {
    162           'xcode_settings': {
    163             'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS': 'YES',
    164           },
    165         }],
    166         [ 'OS == "win"', {
    167           'include_dirs': [
    168             'config/win',
    169           ],
    170           'direct_dependent_settings': {
    171             'include_dirs': [
    172               'config/win',
    173             ],
    174           },
    175         }],
    176         [ 'target_arch != "arm" and target_arch != "mipsel"', {
    177           'sources': [
    178             '../third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp',
    179           ],
    180         }],
    181       ],
    182     },
    183     {
    184       'target_name': 'skia_opts_none',
    185       'type': 'static_library',
    186       'includes': [
    187         'skia_common.gypi',
    188       ],
    189       'include_dirs': [
    190         '../third_party/skia/include/core',
    191         '../third_party/skia/src/core',
    192       ],
    193       'sources': [
    194         '../third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp',
    195         '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
    196         '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
    197         '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
    198         '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
    199         '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
    200         '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
    201       ],
    202     },
    203   ],
    204   'conditions': [
    205     # NEON code must be compiled with -mfpu=neon which also affects scalar
    206     # code. To support dynamic NEON code paths, we need to build all
    207     # NEON-specific sources in a separate static library. The situation
    208     # is very similar to the SSSE3 one.
    209     ['target_arch == "arm" and (arm_neon == 1 or arm_neon_optional == 1)', {
    210       'targets': [
    211         {
    212           'target_name': 'skia_opts_neon',
    213           'type': 'static_library',
    214           'includes': [
    215             'skia_common.gypi',
    216           ],
    217           'include_dirs': [
    218             '../third_party/skia/include/core',
    219             '../third_party/skia/src/core',
    220             '../third_party/skia/src/opts',
    221           ],
    222           'cflags!': [
    223             '-fno-omit-frame-pointer',
    224             '-mfpu=vfp',  # remove them all, just in case.
    225             '-mfpu=vfpv3',
    226             '-mfpu=vfpv3-d16',
    227           ],
    228           'cflags': [
    229             '-mfpu=neon',
    230             '-fomit-frame-pointer',
    231           ],
    232           'ldflags': [
    233             '-march=armv7-a',
    234             '-Wl,--fix-cortex-a8',
    235           ],
    236           'sources': [
    237             '../third_party/skia/src/opts/memset16_neon.S',
    238             '../third_party/skia/src/opts/memset32_neon.S',
    239             '../third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp',
    240             '../third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
    241             '../third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h',
    242             '../third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h',
    243             '../third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
    244             '../third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp',
    245             '../third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp',
    246             '../third_party/skia/src/opts/SkBlurImage_opts_neon.cpp',
    247             '../third_party/skia/src/opts/SkMorphology_opts_neon.cpp',
    248           ],
    249           'conditions': [
    250             ['arm_neon == 1', {
    251               'defines': [
    252                 '__ARM_HAVE_NEON',
    253               ],
    254             }],
    255             ['arm_neon_optional == 1', {
    256               'defines': [
    257                 '__ARM_HAVE_OPTIONAL_NEON_SUPPORT',
    258               ],
    259             }],
    260           ],
    261         },
    262       ],
    263     }],
    264   ],
    265 }
    266