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