blob: 5abeef92c5488d252b0fd928dfb2c4b3fd27e35c [file] [log] [blame]
mtklein7d10b9f2016-07-27 11:17:18 -07001# Copyright 2016 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6declare_args() {
Mike Kleine459afd2017-03-03 09:21:30 -05007 skia_use_system_libjpeg_turbo = is_official_build
mtklein7d10b9f2016-07-27 11:17:18 -07008}
9
10import("../third_party.gni")
11
Mike Klein10d665d2016-11-01 11:46:10 -040012if (skia_use_system_libjpeg_turbo) {
13 system("libjpeg") {
14 libs = [ "jpeg" ]
15 }
16} else {
17 third_party("libjpeg") {
Leon Scroggins III4f498fc2017-12-06 16:21:01 -050018 public_include_dirs = [
19 ".",
20 "../externals/libjpeg-turbo",
21 ]
mtklein7d10b9f2016-07-27 11:17:18 -070022
Leon Scroggins III21706f12020-08-14 16:58:20 -040023 defines = [
24 "TURBO_FOR_WINDOWS",
25
26 # Add support for arithmetic encoding (C_) and decoding (D_).
27 # This matches Android. Note that such JPEGs are likely rare, given lack of
28 # support by major browsers.
29 "C_ARITH_CODING_SUPPORTED=1",
30 "D_ARITH_CODING_SUPPORTED=1",
31 ]
32
Mike Kleind2da6a72020-01-02 11:39:40 -060033 if (!is_win || is_clang) {
34 defines += [ "USE_CLZ_INTRINSIC" ] # Cuts a 64K table.
35 }
mtklein7a1f45f2016-08-04 06:19:33 -070036
Mike Klein10d665d2016-11-01 11:46:10 -040037 sources = [
Matt Sarett9119de62017-02-10 17:47:51 -050038 "../externals/libjpeg-turbo/jaricom.c",
Mike Klein10d665d2016-11-01 11:46:10 -040039 "../externals/libjpeg-turbo/jcapimin.c",
40 "../externals/libjpeg-turbo/jcapistd.c",
Matt Sarett9119de62017-02-10 17:47:51 -050041 "../externals/libjpeg-turbo/jcarith.c",
Mike Klein10d665d2016-11-01 11:46:10 -040042 "../externals/libjpeg-turbo/jccoefct.c",
43 "../externals/libjpeg-turbo/jccolor.c",
44 "../externals/libjpeg-turbo/jcdctmgr.c",
45 "../externals/libjpeg-turbo/jchuff.c",
46 "../externals/libjpeg-turbo/jcinit.c",
47 "../externals/libjpeg-turbo/jcmainct.c",
48 "../externals/libjpeg-turbo/jcmarker.c",
49 "../externals/libjpeg-turbo/jcmaster.c",
50 "../externals/libjpeg-turbo/jcomapi.c",
51 "../externals/libjpeg-turbo/jcparam.c",
52 "../externals/libjpeg-turbo/jcphuff.c",
53 "../externals/libjpeg-turbo/jcprepct.c",
54 "../externals/libjpeg-turbo/jcsample.c",
55 "../externals/libjpeg-turbo/jdapimin.c",
56 "../externals/libjpeg-turbo/jdapistd.c",
Matt Sarett9119de62017-02-10 17:47:51 -050057 "../externals/libjpeg-turbo/jdarith.c",
Mike Klein10d665d2016-11-01 11:46:10 -040058 "../externals/libjpeg-turbo/jdcoefct.c",
59 "../externals/libjpeg-turbo/jdcolor.c",
60 "../externals/libjpeg-turbo/jddctmgr.c",
61 "../externals/libjpeg-turbo/jdhuff.c",
62 "../externals/libjpeg-turbo/jdinput.c",
63 "../externals/libjpeg-turbo/jdmainct.c",
64 "../externals/libjpeg-turbo/jdmarker.c",
65 "../externals/libjpeg-turbo/jdmaster.c",
66 "../externals/libjpeg-turbo/jdmerge.c",
67 "../externals/libjpeg-turbo/jdphuff.c",
68 "../externals/libjpeg-turbo/jdpostct.c",
69 "../externals/libjpeg-turbo/jdsample.c",
70 "../externals/libjpeg-turbo/jerror.c",
71 "../externals/libjpeg-turbo/jfdctflt.c",
72 "../externals/libjpeg-turbo/jfdctfst.c",
73 "../externals/libjpeg-turbo/jfdctint.c",
74 "../externals/libjpeg-turbo/jidctflt.c",
75 "../externals/libjpeg-turbo/jidctfst.c",
76 "../externals/libjpeg-turbo/jidctint.c",
77 "../externals/libjpeg-turbo/jidctred.c",
78 "../externals/libjpeg-turbo/jmemmgr.c",
79 "../externals/libjpeg-turbo/jmemnobs.c",
Leon Scroggins III21706f12020-08-14 16:58:20 -040080 "../externals/libjpeg-turbo/jpeg_nbits_table.c",
Mike Klein10d665d2016-11-01 11:46:10 -040081 "../externals/libjpeg-turbo/jquant1.c",
82 "../externals/libjpeg-turbo/jquant2.c",
Mike Klein10d665d2016-11-01 11:46:10 -040083 "../externals/libjpeg-turbo/jutils.c",
84 ]
Mike Kleine7bd81d2016-11-13 08:52:07 -050085
Mike Klein07fea192021-02-02 11:34:22 -060086 if (current_cpu == "arm" && !is_win) {
Mike Kleine7bd81d2016-11-13 08:52:07 -050087 sources += [
Leon Scroggins III21706f12020-08-14 16:58:20 -040088 "../externals/libjpeg-turbo/simd/arm/arm/jsimd.c",
89 "../externals/libjpeg-turbo/simd/arm/arm/jsimd_neon.S",
90 "../externals/libjpeg-turbo/simd/arm/common/jcsample-neon.c",
91 "../externals/libjpeg-turbo/simd/arm/common/jdcolor-neon.c",
92 "../externals/libjpeg-turbo/simd/arm/common/jdmerge-neon.c",
93 "../externals/libjpeg-turbo/simd/arm/common/jdsample-neon.c",
94 "../externals/libjpeg-turbo/simd/arm/common/jidctfst-neon.c",
95 "../externals/libjpeg-turbo/simd/arm/common/jidctint-neon.c",
96 "../externals/libjpeg-turbo/simd/arm/common/jidctred-neon.c",
Mike Kleine7bd81d2016-11-13 08:52:07 -050097 ]
Mike Klein07fea192021-02-02 11:34:22 -060098 } else if (current_cpu == "arm64" && !is_win) {
Mike Kleine7bd81d2016-11-13 08:52:07 -050099 sources += [
Leon Scroggins III21706f12020-08-14 16:58:20 -0400100 "../externals/libjpeg-turbo/simd/arm/arm64/jsimd.c",
101 "../externals/libjpeg-turbo/simd/arm/arm64/jsimd_neon.S",
102 "../externals/libjpeg-turbo/simd/arm/common/jcsample-neon.c",
103 "../externals/libjpeg-turbo/simd/arm/common/jdcolor-neon.c",
104 "../externals/libjpeg-turbo/simd/arm/common/jdmerge-neon.c",
105 "../externals/libjpeg-turbo/simd/arm/common/jdsample-neon.c",
106 "../externals/libjpeg-turbo/simd/arm/common/jidctfst-neon.c",
107 "../externals/libjpeg-turbo/simd/arm/common/jidctint-neon.c",
108 "../externals/libjpeg-turbo/simd/arm/common/jidctred-neon.c",
Mike Kleine7bd81d2016-11-13 08:52:07 -0500109 ]
110 } else {
111 sources += [ "../externals/libjpeg-turbo/jsimd_none.c" ]
112 }
Mike Klein10d665d2016-11-01 11:46:10 -0400113 }
mtklein7d10b9f2016-07-27 11:17:18 -0700114}