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