• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//foundation/multimedia/image_framework/ide/image_decode_config.gni")
16if (use_mingw_win || use_clang_mac) {
17  graphic_root = "/${image_sep_f}${image_oundation}/${graphic_multimedia}"
18}
19if (use_clang_mac) {
20  third_party_dir = "/third_party"
21  third_party_root = "/${third_party_dir}"
22}
23
24ohos_static_library("exifhelper") {
25  if (!use_clang_android && !use_clang_ios) {
26    branch_protector_ret = "pac_ret"
27    sanitize = {
28      cfi = true
29      cfi_cross_dso = true
30      cfi_vcall_icall_only = true
31      debug = false
32    }
33  }
34  sources = [
35    "../libjpegplugin/src/exif_info.cpp",
36    "../libjpegplugin/src/exif_maker_note.cpp",
37  ]
38  include_dirs = [
39    "../libjpegplugin/include",
40    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
41    "${image_subsystem}/interfaces/innerkits/include",
42  ]
43
44  external_deps = [
45    "c_utils:utils",
46    "graphic_surface:surface",
47    "hilog:libhilog",
48    "hitrace:hitrace_meter",
49    "libexif:libexif",
50  ]
51  part_name = "image_framework"
52  subsystem_name = "multimedia"
53}
54
55config("plugins_includes") {
56  include_dirs = [
57    "${image_subsystem}/plugins/manager/include",
58    "${image_subsystem}/plugins/manager/include/image",
59    "${image_subsystem}/plugins/manager/include/pluginbase",
60  ]
61}
62config("third_part_includes") {
63  include_dirs = [ "../libjpegplugin/include" ]
64}
65config("win_config") {
66  if (use_mingw_win) {
67    defines = image_decode_windows_defines
68    defines += [ "CROSS_PLATFORM" ]
69    include_dirs += [
70      "${image_subsystem}/mock/native/include",
71      "${image_subsystem}/mock/native/include/secure",
72      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/codec",
73      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config",
74      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config/win",
75      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/core",
76    ]
77  }
78}
79config("mac_config") {
80  if (use_clang_mac) {
81    defines = image_decode_mac_defines
82    defines += [ "CROSS_PLATFORM" ]
83    include_dirs += [
84      "${image_subsystem}/mock/native/include",
85      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/codec",
86      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/core",
87      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config/mac",
88      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config",
89      "${third_party_root}/bounds_checking_function/include",
90    ]
91  }
92}
93config("ext_public_config") {
94  include_dirs = [ "${image_subsystem}/plugins/manager/include" ]
95}
96
97ohos_shared_library("textureEncoderCL") {
98  if (!use_clang_android && !use_clang_ios) {
99    branch_protector_ret = "pac_ret"
100    sanitize = {
101      cfi = true
102      cfi_cross_dso = true
103      cfi_vcall_icall_only = true
104      debug = false
105    }
106  }
107  sources = [ "src/texture_encode/image_compressor.cpp" ]
108  include_dirs = [
109    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
110    "${image_subsystem}/interfaces/innerkits/include",
111    "include/texture_encode",
112  ]
113  if (use_mingw_win) {
114    configs += [ ":win_config" ]
115  } else if (use_clang_mac) {
116    configs += [ ":mac_config" ]
117  } else {
118    external_deps = [
119      "c_utils:utils",
120      "hilog:libhilog",
121      "opencl-headers:libcl",
122    ]
123  }
124  cflags = [ "-O3" ]
125  cflags_cc = [ "-O3" ]
126  innerapi_tags = [ "platformsdk" ]
127  subsystem_name = "multimedia"
128  part_name = "image_framework"
129}
130
131ohos_shared_library("extplugin") {
132  if (!use_clang_android && !use_clang_ios) {
133    branch_protector_ret = "pac_ret"
134    sanitize = {
135      boundary_sanitizer = true
136      cfi = true
137      cfi_cross_dso = true
138      cfi_vcall_icall_only = true
139      debug = false
140      integer_overflow = true
141      ubsan = true
142    }
143  }
144  sources = [
145    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/abstract_exif_metadata_accessor.cpp",
146    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/buffer_metadata_stream.cpp",
147    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/data_buf.cpp",
148    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/dng_exif_metadata_accessor.cpp",
149    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata.cpp",
150    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata_formatter.cpp",
151    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/file_metadata_stream.cpp",
152    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/heif_exif_metadata_accessor.cpp",
153    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/jpeg_exif_metadata_accessor.cpp",
154    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/metadata_accessor_factory.cpp",
155    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_exif_metadata_accessor.cpp",
156    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_image_chunk_utils.cpp",
157    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/tiff_parser.cpp",
158    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/webp_exif_metadata_accessor.cpp",
159    "src/ext_decoder.cpp",
160    "src/ext_encoder.cpp",
161    "src/ext_pixel_convert.cpp",
162    "src/ext_stream.cpp",
163    "src/ext_wstream.cpp",
164    "src/hdr/hdr_helper.cpp",
165    "src/hdr/jpeg_mpf_parser.cpp",
166    "src/jpeg_yuv_decoder/jpeg_decoder_yuv.cpp",
167    "src/jpeg_yuv_decoder/jpeg_yuvdata_converter.cpp",
168    "src/plugin_export.cpp",
169    "src/texture_encode/astc_codec.cpp",
170  ]
171  if (enable_jpeg_hw_decode) {
172    sources += [
173      "src/hardware/jpeg_hw_decoder.cpp",
174      "src/hardware/jpeg_dma_pool.cpp"
175    ]
176  }
177  configs = [
178    ":plugins_includes",
179    ":third_part_includes",
180  ]
181  include_dirs = [
182    "include",
183    "include/hdr",
184    "include/heif_impl/heif_parser",
185    "include/texture_encode",
186    "include/jpeg_yuv_decoder",
187    "${image_subsystem}/interfaces/innerkits/include",
188    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
189    "${image_subsystem}/frameworks/innerkitsimpl/accessor/include",
190    "${image_subsystem}/plugins/common/libs/image/formatagentplugin/include",
191    "${image_subsystem}/frameworks/innerkitsimpl/pixelconverter/include",
192  ]
193  if (use_mingw_win) {
194    configs += [ ":win_config" ]
195    deps = [
196      ":heifparser",
197      "${graphic_root}/ide/libs/skia:skia",
198      "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils_static",
199      "${image_subsystem}/mock/native:log_mock_static",
200      "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent",
201      "${image_subsystem}/plugins/manager:pluginmanager_static",
202    ]
203    deps += skia_core
204  } else if (use_clang_mac) {
205    configs += [ ":mac_config" ]
206    deps = [
207      ":heifparser",
208      "${graphic_root}/ide/libs/skia:skia",
209      "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils_static",
210      "${image_subsystem}/mock/native:log_mock_static",
211      "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent",
212      "${image_subsystem}/plugins/manager:pluginmanager_static",
213      "${third_party_root}/bounds_checking_function:libsec_static",
214    ]
215  } else {
216    public_configs = [ ":ext_public_config" ]
217    defines = []
218    deps = [
219      ":exifhelper",
220      ":heifimpl",
221      ":heifparser",
222      "${image_subsystem}//frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter",
223      "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
224      "${image_subsystem}/interfaces/innerkits:image_native",
225      "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent",
226      "${image_subsystem}/plugins/manager:pluginmanager",
227    ]
228
229    external_deps = [
230      "astc-encoder:astc_encoder_shared",
231      "c_utils:utils",
232      "drivers_interface_display:libdisplay_commontype_proxy_1.0",
233      "ffmpeg:libohosffmpeg",
234      "ffrt:libffrt",
235      "graphic_2d:color_manager",
236      "graphic_surface:surface",
237      "hilog:libhilog",
238      "hisysevent:libhisysevent",
239      "libexif:libexif",
240      "libjpeg-turbo:turbojpeg",
241      "skia:libjpeg",
242      "skia:piex",
243      "skia:skia_canvaskit",
244      "zlib:libz",
245    ]
246
247    if (defined(global_parts_info) &&
248        defined(global_parts_info.open_source_libyuv)) {
249      defines += [ "ENABLE_ASTC_ENCODE_BASED_GPU" ]
250      deps += [ ":textureEncoderCL" ]
251      external_deps += [ "opencl-headers:libcl" ]
252    }
253
254    if (defined(global_parts_info) &&
255        defined(global_parts_info.graphic_graphic_2d_ext)) {
256      defines += [ "SUT_ENCODE_ENABLE" ]
257      if (target_cpu == "arm64" || is_emulator) {
258        defines += [ "SUT_PATH_X64" ]
259      }
260    }
261
262    if (enable_jpeg_hw_decode) {
263      external_deps += [
264        "drivers_interface_codec:libimage_proxy_2.1",
265        "drivers_interface_display:libdisplay_buffer_hdi_impl",
266        "drivers_interface_display:libdisplay_buffer_proxy_1.0",
267        "drivers_interface_display:libdisplay_composer_hdi_impl_1.2",
268        "drivers_interface_display:libdisplay_composer_proxy_1.0",
269        "hdf_core:libhdf_utils",
270        "hdf_core:libhdi",
271        "ipc:ipc_single",
272      ]
273      defines += [ "JPEG_HW_DECODE_ENABLE" ]
274    }
275
276    if (enable_heif_hw_decode) {
277      defines += [ "HEIF_HW_DECODE_ENABLE" ]
278      include_dirs += [ "include/heif_impl/heif_parser" ]
279      external_deps += [
280        "drivers_interface_codec:libcodec_proxy_4.0",
281        "openmax:libopenmax_static",
282      ]
283    }
284
285    if (enable_heif_hw_encode) {
286      defines += [ "HEIF_HW_ENCODE_ENABLE" ]
287      external_deps += [ "drivers_interface_codec:libimage_proxy_2.1" ]
288    }
289  }
290  if (is_ohos) {
291    sources += [ "src/sk_ohoscodec.cpp" ]
292    defines += [ "SK_ENABLE_OHOS_CODEC" ]
293  }
294  if (image_use_new_skia) {
295    defines += [ "USE_M133_SKIA" ]
296  }
297  cflags = [
298    "-DIMAGE_COLORSPACE_FLAG",
299    "-O3",
300    "-fstack-protector-strong",
301  ]
302  cflags_cc = [ "-O3" ]
303  innerapi_tags = [ "platformsdk" ]
304
305  external_deps += [ "zlib:libz" ]
306
307  subsystem_name = "multimedia"
308  part_name = "image_framework"
309}
310
311ohos_prebuilt_etc("extpluginmetadata") {
312  source = "extplugin.pluginmeta"
313  relative_install_dir = "multimediaplugin/image"
314  subsystem_name = "multimedia"
315  part_name = "image_framework"
316}
317
318if (is_arkui_x) {
319  ohos_source_set("heifparser") {
320    if (!use_clang_android && !use_clang_ios) {
321      sanitize = {
322        cfi = true
323        cfi_cross_dso = true
324        cfi_vcall_icall_only = true
325        debug = false
326      }
327    }
328
329    remove_configs = [ "//build/config/compiler:no_rtti" ]
330
331    configs = [ "//build/config/compiler:rtti" ]
332
333    include_dirs = [
334      "include/heif_impl/heif_parser",
335      "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
336      "${image_subsystem}/interfaces/innerkits/include",
337    ]
338
339    sources = [
340      "src/heif_impl/heif_parser/box/basic_box.cpp",
341      "src/heif_impl/heif_parser/box/heif_box.cpp",
342      "src/heif_impl/heif_parser/box/item_data_box.cpp",
343      "src/heif_impl/heif_parser/box/item_info_box.cpp",
344      "src/heif_impl/heif_parser/box/item_property_aux_box.cpp",
345      "src/heif_impl/heif_parser/box/item_property_basic_box.cpp",
346      "src/heif_impl/heif_parser/box/item_property_box.cpp",
347      "src/heif_impl/heif_parser/box/item_property_color_box.cpp",
348      "src/heif_impl/heif_parser/box/item_property_display_box.cpp",
349      "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp",
350      "src/heif_impl/heif_parser/box/item_property_transform_box.cpp",
351      "src/heif_impl/heif_parser/box/item_ref_box.cpp",
352      "src/heif_impl/heif_parser/heif_image.cpp",
353      "src/heif_impl/heif_parser/heif_parser.cpp",
354      "src/heif_impl/heif_parser/heif_stream.cpp",
355      "src/heif_impl/heif_parser/heif_utils.cpp",
356    ]
357
358    external_deps = [ "c_utils:utils" ]
359
360    subsystem_name = "multimedia"
361    deps = [
362      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${target_os}",
363      "//third_party/bounds_checking_function:libsec_static",
364    ]
365    part_name = "image_framework"
366  }
367} else {
368  ohos_shared_library("heifparser") {
369    if (!use_clang_android && !use_clang_ios) {
370      branch_protector_ret = "pac_ret"
371      sanitize = {
372        cfi = true
373        cfi_cross_dso = true
374        cfi_vcall_icall_only = true
375        debug = false
376      }
377    }
378
379    remove_configs = [ "//build/config/compiler:no_rtti" ]
380
381    configs = [ "//build/config/compiler:rtti" ]
382
383    include_dirs = [
384      "include/heif_impl/heif_parser",
385      "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
386      "${image_subsystem}/interfaces/innerkits/include",
387    ]
388
389    sources = [
390      "src/heif_impl/heif_parser/box/basic_box.cpp",
391      "src/heif_impl/heif_parser/box/heif_box.cpp",
392      "src/heif_impl/heif_parser/box/item_data_box.cpp",
393      "src/heif_impl/heif_parser/box/item_info_box.cpp",
394      "src/heif_impl/heif_parser/box/item_property_aux_box.cpp",
395      "src/heif_impl/heif_parser/box/item_property_basic_box.cpp",
396      "src/heif_impl/heif_parser/box/item_property_box.cpp",
397      "src/heif_impl/heif_parser/box/item_property_color_box.cpp",
398      "src/heif_impl/heif_parser/box/item_property_display_box.cpp",
399      "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp",
400      "src/heif_impl/heif_parser/box/item_property_transform_box.cpp",
401      "src/heif_impl/heif_parser/box/item_ref_box.cpp",
402      "src/heif_impl/heif_parser/heif_image.cpp",
403      "src/heif_impl/heif_parser/heif_parser.cpp",
404      "src/heif_impl/heif_parser/heif_stream.cpp",
405      "src/heif_impl/heif_parser/heif_utils.cpp",
406    ]
407
408    external_deps = [
409       "c_utils:utils",
410       "hilog:libhilog",
411    ]
412
413    subsystem_name = "multimedia"
414    innerapi_tags = [ "platformsdk_indirect" ]
415    part_name = "image_framework"
416  }
417}
418
419config("heif_hw_decoder_cfg") {
420  cflags_cc = [ "-fexceptions" ]
421}
422
423ohos_shared_library("heifimpl") {
424  if (!use_clang_android && !use_clang_ios) {
425    branch_protector_ret = "pac_ret"
426    sanitize = {
427      cfi = true
428      cfi_cross_dso = true
429      cfi_vcall_icall_only = true
430      debug = false
431    }
432  }
433
434  defines = []
435  if (build_variant == "root") {
436    defines += [ "BUILD_ENG_VERSION" ]
437  }
438  if (enable_heif_hw_decode) {
439    defines += [ "HEIF_HW_DECODE_ENABLE" ]
440  }
441
442  configs = []
443  if (enable_heif_hw_decode) {
444    configs += [ ":heif_hw_decoder_cfg" ]
445  }
446
447  include_dirs = [
448    "include",
449    "include/heif_impl",
450    "include/heif_impl/heif_parser",
451    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
452    "${image_subsystem}/interfaces/innerkits/include",
453  ]
454
455  sources = [ "src/heif_impl/HeifDecoderImpl.cpp" ]
456
457  deps = [
458    ":heifparser",
459    "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
460  ]
461
462  external_deps = [
463    "graphic_2d:color_manager",
464    "graphic_surface:surface",
465    "hilog:libhilog",
466  ]
467
468  if (enable_heif_hw_decode) {
469    external_deps += [
470      "c_utils:utils",
471      "drivers_interface_codec:libcodec_proxy_4.0",
472      "drivers_interface_codec:libimage_proxy_2.1",
473      "drivers_interface_display:display_commontype_idl_headers",
474      "hdf_core:libhdi",
475      "hitrace:hitrace_meter",
476      "init:libbegetutil",
477      "ipc:ipc_core",
478      "openmax:libopenmax_static",
479      "qos_manager:qos",
480    ]
481  }
482
483  subsystem_name = "multimedia"
484  innerapi_tags = [ "platformsdk_indirect" ]
485  part_name = "image_framework"
486}
487