• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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() {
7  skia_use_system_libjpeg_turbo = is_official_build
8}
9
10import("//build/ohos_var.gni")
11import("../third_party.gni")
12
13config("libjpeg-turbo-inline") {
14  cflags = [
15    "-mllvm",
16    "-inline-threshold=325",
17  ]
18}
19
20if (skia_use_system_libjpeg_turbo) {
21  system("libjpeg") {
22    libs = [ "jpeg" ]
23  }
24} else {
25  third_party("libjpeg") {
26    if (is_ohos && is_clang && (target_cpu == "arm" || target_cpu == "arm64") &&
27        enhanced_opt) {
28      configs = [ ":libjpeg-turbo-inline" ]
29    }
30    public_include_dirs = [
31      ".",
32      "../externals/libjpeg-turbo",
33    ]
34
35    defines = [
36      "TURBO_FOR_WINDOWS",
37
38      # Add support for arithmetic encoding (C_) and decoding (D_).
39      # This matches Android. Note that such JPEGs are likely rare, given lack of
40      # support by major browsers.
41      "C_ARITH_CODING_SUPPORTED=1",
42      "D_ARITH_CODING_SUPPORTED=1",
43    ]
44
45    if (!is_win || is_clang) {
46      defines += [ "USE_CLZ_INTRINSIC" ]  # Cuts a 64K table.
47    }
48
49    if (is_ohos) {
50      defines += [ "SK_ENABLE_HI_JPEG" ]
51    }
52
53    sources = [
54      "../externals/libjpeg-turbo/jaricom.c",
55      "../externals/libjpeg-turbo/jcapimin.c",
56      "../externals/libjpeg-turbo/jcapistd.c",
57      "../externals/libjpeg-turbo/jcarith.c",
58      "../externals/libjpeg-turbo/jccoefct.c",
59      "../externals/libjpeg-turbo/jccolor.c",
60      "../externals/libjpeg-turbo/jcdctmgr.c",
61      "../externals/libjpeg-turbo/jchuff.c",
62      "../externals/libjpeg-turbo/jcinit.c",
63      "../externals/libjpeg-turbo/jcmainct.c",
64      "../externals/libjpeg-turbo/jcmarker.c",
65      "../externals/libjpeg-turbo/jcmaster.c",
66      "../externals/libjpeg-turbo/jcomapi.c",
67      "../externals/libjpeg-turbo/jcparam.c",
68      "../externals/libjpeg-turbo/jcphuff.c",
69      "../externals/libjpeg-turbo/jcprepct.c",
70      "../externals/libjpeg-turbo/jcsample.c",
71      "../externals/libjpeg-turbo/jdapimin.c",
72      "../externals/libjpeg-turbo/jdapistd.c",
73      "../externals/libjpeg-turbo/jdarith.c",
74      "../externals/libjpeg-turbo/jdcoefct.c",
75      "../externals/libjpeg-turbo/jdcolor.c",
76      "../externals/libjpeg-turbo/jddctmgr.c",
77      "../externals/libjpeg-turbo/jdinput.c",
78      "../externals/libjpeg-turbo/jdmainct.c",
79      "../externals/libjpeg-turbo/jdmarker.c",
80      "../externals/libjpeg-turbo/jdmaster.c",
81      "../externals/libjpeg-turbo/jdmerge.c",
82      "../externals/libjpeg-turbo/jdphuff.c",
83      "../externals/libjpeg-turbo/jdpostct.c",
84      "../externals/libjpeg-turbo/jdsample.c",
85      "../externals/libjpeg-turbo/jerror.c",
86      "../externals/libjpeg-turbo/jfdctflt.c",
87      "../externals/libjpeg-turbo/jfdctfst.c",
88      "../externals/libjpeg-turbo/jfdctint.c",
89      "../externals/libjpeg-turbo/jidctflt.c",
90      "../externals/libjpeg-turbo/jidctfst.c",
91      "../externals/libjpeg-turbo/jidctint.c",
92      "../externals/libjpeg-turbo/jidctred.c",
93      "../externals/libjpeg-turbo/jmemmgr.c",
94      "../externals/libjpeg-turbo/jmemnobs.c",
95      "../externals/libjpeg-turbo/jpeg_nbits_table.c",
96      "../externals/libjpeg-turbo/jquant1.c",
97      "../externals/libjpeg-turbo/jquant2.c",
98      "../externals/libjpeg-turbo/jutils.c",
99    ]
100
101    # OH ISSUE: jpeg optimize
102    if (target_platform == "pc") {
103      defines += [ "HUFF_DECODE_OPT" ]
104      sources += [ "../externals/libjpeg-turbo/jdhuff_opt.c" ]
105    } else {
106      sources += [ "../externals/libjpeg-turbo/jdhuff.c" ]
107    }
108
109    if (!is_win && (current_cpu == "arm" || current_cpu == "arm64")) {
110      defines += [ "NEON_INTRINSICS" ]
111      sources += [
112        "../externals/libjpeg-turbo/simd/arm/jccolor-neon.c",
113        "../externals/libjpeg-turbo/simd/arm/jcgray-neon.c",
114        "../externals/libjpeg-turbo/simd/arm/jcphuff-neon.c",
115        "../externals/libjpeg-turbo/simd/arm/jcsample-neon.c",
116        "../externals/libjpeg-turbo/simd/arm/jdcolor-neon.c",
117        "../externals/libjpeg-turbo/simd/arm/jdmerge-neon.c",
118        "../externals/libjpeg-turbo/simd/arm/jdsample-neon.c",
119        "../externals/libjpeg-turbo/simd/arm/jfdctfst-neon.c",
120        "../externals/libjpeg-turbo/simd/arm/jfdctint-neon.c",
121        "../externals/libjpeg-turbo/simd/arm/jidctfst-neon.c",
122        "../externals/libjpeg-turbo/simd/arm/jidctint-neon.c",
123        "../externals/libjpeg-turbo/simd/arm/jidctred-neon.c",
124        "../externals/libjpeg-turbo/simd/arm/jquanti-neon.c",
125      ]
126      include_dirs = [ "../externals/libjpeg-turbo/simd/arm" ]
127      if (current_cpu == "arm") {
128        sources += [
129          "../externals/libjpeg-turbo/simd/arm/aarch32/jchuff-neon.c",
130          "../externals/libjpeg-turbo/simd/arm/aarch32/jsimd.c",
131        ]
132      } else if (current_cpu == "arm64") {
133        sources += [
134          "../externals/libjpeg-turbo/simd/arm/aarch64/jchuff-neon.c",
135          "../externals/libjpeg-turbo/simd/arm/aarch64/jsimd.c",
136        ]
137      }
138    } else {
139      sources += [ "../externals/libjpeg-turbo/jsimd_none.c" ]
140    }
141  }
142}
143