821168bc0326bbb75b1c8bed94b0591710c18586
[platform/framework/web/crosswalk.git] / src / skia / skia_library_opts.gyp
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         '../third_party/skia/src/utils',
39       ],
40       'conditions': [
41         [ 'os_posix == 1 and OS != "mac" and OS != "android" and \
42            target_arch != "arm" and target_arch != "arm64" and \
43            target_arch != "mipsel" and target_arch != "mips64el"', {
44           'cflags': [
45             '-msse2',
46           ],
47         }],
48         [ 'target_arch != "arm" and target_arch != "mipsel" and \
49            target_arch != "arm64" and target_arch != "mips64el"', {
50           'sources': [
51             '../third_party/skia/src/opts/SkBitmapFilter_opts_SSE2.cpp',
52             '../third_party/skia/src/opts/SkBitmapProcState_opts_SSE2.cpp',
53             '../third_party/skia/src/opts/SkBlitRect_opts_SSE2.cpp',
54             '../third_party/skia/src/opts/SkBlitRow_opts_SSE2.cpp',
55             '../third_party/skia/src/opts/SkBlurImage_opts_SSE2.cpp',
56             '../third_party/skia/src/opts/SkMorphology_opts_SSE2.cpp',
57             '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
58             '../third_party/skia/src/opts/SkUtils_opts_SSE2.cpp',
59             '../third_party/skia/src/opts/SkXfermode_opts_SSE2.cpp',
60           ],
61           'dependencies': [
62             'skia_opts_ssse3',
63             'skia_opts_sse4',
64           ],
65         }],
66         [ 'target_arch == "arm"', {
67           'conditions': [
68             [ 'arm_version >= 7 and (arm_neon == 1 or arm_neon_optional == 1)', {
69               'dependencies': [
70                 'skia_opts_neon',
71               ]
72            }],
73           ],
74           # The assembly uses the frame pointer register (r7 in Thumb/r11 in
75           # ARM), the compiler doesn't like that. Explicitly remove the
76           # -fno-omit-frame-pointer flag for Android, as that gets added to all
77           # targets via common.gypi.
78           'cflags!': [
79             '-fno-omit-frame-pointer',
80             '-marm',
81             '-mapcs-frame',
82           ],
83           'cflags': [
84             '-fomit-frame-pointer',
85           ],
86           'sources': [
87             '../third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp',
88           ],
89         }],
90         [ 'target_arch == "arm" and (arm_version < 7 or arm_neon == 0)', {
91           'sources': [
92             '../third_party/skia/src/opts/memset.arm.S',
93           ],
94         }],
95         [ 'target_arch == "arm" and arm_version < 6', {
96           'sources': [
97             '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
98             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
99             '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
100             '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
101             '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
102             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
103             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
104           ],
105         }],
106         [ 'target_arch == "arm" and arm_version >= 6', {
107           'sources': [
108             '../third_party/skia/src/opts/SkBlitMask_opts_arm.cpp',
109             '../third_party/skia/src/opts/SkBlitRow_opts_arm.cpp',
110             '../third_party/skia/src/opts/SkBlitRow_opts_arm.h',
111             '../third_party/skia/src/opts/SkBlurImage_opts_arm.cpp',
112             '../third_party/skia/src/opts/SkMorphology_opts_arm.cpp',
113             '../third_party/skia/src/opts/SkTextureCompression_opts_arm.cpp',
114             '../third_party/skia/src/opts/SkUtils_opts_arm.cpp',
115             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
116           ],
117         }],
118         [ 'target_arch == "mipsel" or target_arch == "mips64el"',{
119           'cflags': [
120             '-fomit-frame-pointer',
121           ],
122           'sources': [
123             '../third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp',
124             '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
125             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
126             '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
127             '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
128             '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
129             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
130             '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
131           ],
132         }],
133         [ 'target_arch == "arm64"', {
134           'sources': [
135             '../third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp',
136             '../third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
137             '../third_party/skia/src/opts/SkBitmapProcState_opts_arm.cpp',
138             '../third_party/skia/src/opts/SkBlitMask_opts_arm.cpp',
139             '../third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
140             '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
141             '../third_party/skia/src/opts/SkBlurImage_opts_arm.cpp',
142             '../third_party/skia/src/opts/SkBlurImage_opts_neon.cpp',
143             '../third_party/skia/src/opts/SkMorphology_opts_arm.cpp',
144             '../third_party/skia/src/opts/SkMorphology_opts_neon.cpp',
145             '../third_party/skia/src/opts/SkTextureCompression_opts_arm.cpp',
146             '../third_party/skia/src/opts/SkTextureCompression_opts_neon.cpp',
147             '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
148             '../third_party/skia/src/opts/SkXfermode_opts_arm.cpp',
149             '../third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp',
150           ],
151         }],
152       ],
153     },
154     # For the same lame reasons as what is done for skia_opts, we have to
155     # create another target specifically for SSSE3 code as we would not want
156     # to compile the SSE2 code with -mssse3 which would potentially allow
157     # gcc to generate SSSE3 code.
158     {
159       'target_name': 'skia_opts_ssse3',
160       'type': 'static_library',
161       'includes': [
162         'skia_common.gypi',
163       ],
164       'include_dirs': [
165         '../third_party/skia/include/core',
166         '../third_party/skia/include/effects',
167         '../third_party/skia/src/core',
168       ],
169       'conditions': [
170         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
171           'cflags': [
172             '-mssse3',
173           ],
174         }],
175         [ 'OS == "mac"', {
176           'xcode_settings': {
177             'GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS': 'YES',
178           },
179         }],
180         [ 'OS == "win" and clang == 1', {
181           # cl.exe's /arch flag doesn't have a setting for SSSE3, and cl.exe
182           # doesn't need it for intrinsics. clang-cl does need it, though.
183           'msvs_settings': {
184             'VCCLCompilerTool': { 'AdditionalOptions': [ '-mssse3' ] },
185           },
186         }],
187         [ 'OS == "win"', {
188           'include_dirs': [
189             'config/win',
190           ],
191           'direct_dependent_settings': {
192             'include_dirs': [
193               'config/win',
194             ],
195           },
196           'defines' : [
197             'SK_CPU_SSE_LEVEL=31'
198           ],
199         }],
200         [ 'target_arch != "arm" and target_arch != "arm64" and \
201            target_arch != "mipsel" and target_arch != "mips64el"', {
202           'sources': [
203             '../third_party/skia/src/opts/SkBitmapProcState_opts_SSSE3.cpp',
204           ],
205         }],
206       ],
207     },
208     # For the same lame reasons as what is done for skia_opts, we also have to
209     # create another target specifically for SSE4 code as we would not want
210     # to compile the SSE2 code with -msse4 which would potentially allow
211     # gcc to generate SSE4 code.
212     {
213       'target_name': 'skia_opts_sse4',
214       'type': 'static_library',
215       'includes': [
216         'skia_common.gypi',
217       ],
218       'include_dirs': [
219         '../third_party/skia/include/core',
220         '../third_party/skia/src/core',
221       ],
222       'sources': [
223         '../third_party/skia/src/opts/SkBlurImage_opts_SSE4.cpp',
224       ],
225       'conditions': [
226         [ 'OS in ["linux", "freebsd", "openbsd", "solaris", "android"]', {
227           'cflags': [
228             '-msse4.1',
229           ],
230         }],
231         [ 'OS == "mac"', {
232           'xcode_settings': {
233             'GCC_ENABLE_SSE41_EXTENSIONS': 'YES',
234           },
235         }],
236         [ 'OS == "win" and clang == 1', {
237           # cl.exe's /arch flag doesn't have a setting for SSE4.1, and cl.exe
238           # doesn't need it for intrinsics. clang-cl does need it, though.
239           'msvs_settings': {
240             'VCCLCompilerTool': { 'AdditionalOptions': [ '-msse4.1' ] },
241           },
242         }],
243         [ 'OS == "win"', {
244           'defines' : [
245             'SK_CPU_SSE_LEVEL=41'
246           ],
247         }],
248         [ 'target_arch == "x64"', {
249           'sources': [
250             '../third_party/skia/src/opts/SkBlitRow_opts_SSE4_x64_asm.S',
251           ],
252         }],
253         [ 'target_arch == "ia32"', {
254           'sources': [
255             '../third_party/skia/src/opts/SkBlitRow_opts_SSE4_asm.S',
256           ],
257        }],
258       ],
259     },
260     {
261       'target_name': 'skia_opts_none',
262       'type': 'static_library',
263       'includes': [
264         'skia_common.gypi',
265       ],
266       'include_dirs': [
267         '../third_party/skia/include/core',
268         '../third_party/skia/include/effects',
269         '../third_party/skia/src/core',
270         '../third_party/skia/src/utils',
271       ],
272       'sources': [
273         '../third_party/skia/src/opts/SkBitmapProcState_opts_none.cpp',
274         '../third_party/skia/src/opts/SkBlitMask_opts_none.cpp',
275         '../third_party/skia/src/opts/SkBlitRow_opts_none.cpp',
276         '../third_party/skia/src/opts/SkBlurImage_opts_none.cpp',
277         '../third_party/skia/src/opts/SkMorphology_opts_none.cpp',
278         '../third_party/skia/src/opts/SkTextureCompression_opts_none.cpp',
279         '../third_party/skia/src/opts/SkUtils_opts_none.cpp',
280         '../third_party/skia/src/opts/SkXfermode_opts_none.cpp',
281       ],
282     },
283   ],
284   'conditions': [
285     # NEON code must be compiled with -mfpu=neon which also affects scalar
286     # code. To support dynamic NEON code paths, we need to build all
287     # NEON-specific sources in a separate static library. The situation
288     # is very similar to the SSSE3 one.
289     ['target_arch == "arm" and (arm_neon == 1 or arm_neon_optional == 1)', {
290       'targets': [
291         {
292           'target_name': 'skia_opts_neon',
293           'type': 'static_library',
294           'includes': [
295             'skia_common.gypi',
296           ],
297           'include_dirs': [
298             '../third_party/skia/include/core',
299             '../third_party/skia/include/effects',
300             '../third_party/skia/src/core',
301             '../third_party/skia/src/opts',
302             '../third_party/skia/src/utils',
303           ],
304           'cflags!': [
305             '-fno-omit-frame-pointer',
306             '-mfpu=vfp',  # remove them all, just in case.
307             '-mfpu=vfpv3',
308             '-mfpu=vfpv3-d16',
309           ],
310           'cflags': [
311             '-mfpu=neon',
312             '-fomit-frame-pointer',
313           ],
314           'ldflags': [
315             '-march=armv7-a',
316             '-Wl,--fix-cortex-a8',
317           ],
318           'sources': [
319             '../third_party/skia/src/opts/SkBitmapProcState_arm_neon.cpp',
320             '../third_party/skia/src/opts/SkBitmapProcState_matrixProcs_neon.cpp',
321             '../third_party/skia/src/opts/SkBitmapProcState_matrix_clamp_neon.h',
322             '../third_party/skia/src/opts/SkBitmapProcState_matrix_repeat_neon.h',
323             '../third_party/skia/src/opts/SkBlitMask_opts_arm_neon.cpp',
324             '../third_party/skia/src/opts/SkBlitRow_opts_arm_neon.cpp',
325             '../third_party/skia/src/opts/SkBlurImage_opts_neon.cpp',
326             '../third_party/skia/src/opts/SkMorphology_opts_neon.cpp',
327             '../third_party/skia/src/opts/SkTextureCompression_opts_neon.cpp',
328             '../third_party/skia/src/opts/SkXfermode_opts_arm_neon.cpp',
329             '../third_party/skia/src/opts/memset16_neon.S',
330             '../third_party/skia/src/opts/memset32_neon.S',
331           ],
332         },
333       ],
334     }],
335   ],
336 }