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("skia_includes") {
63  include_dirs = [
64    "${skia_root}/skia",
65    "${skia_root}/skia/include/codec",
66    "${skia_root}/skia/include/core",
67    "${skia_root}/skia/third_party/skcms",
68  ]
69}
70config("third_part_includes") {
71  include_dirs = [ "../libjpegplugin/include" ]
72}
73config("win_config") {
74  if (use_mingw_win) {
75    defines = image_decode_windows_defines
76    include_dirs += [
77      "${image_subsystem}/mock/native/include",
78      "${image_subsystem}/mock/native/include/secure",
79      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/codec",
80      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config",
81      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config/win",
82      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/core",
83    ]
84  }
85}
86config("mac_config") {
87  if (use_clang_mac) {
88    defines = image_decode_mac_defines
89    include_dirs += [
90      "${image_subsystem}/mock/native/include",
91      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/codec",
92      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/core",
93      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config/mac",
94      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config",
95      "${third_party_root}/bounds_checking_function/include",
96    ]
97  }
98}
99config("ext_public_config") {
100  include_dirs = [ "${image_subsystem}/plugins/manager/include" ]
101}
102
103ohos_shared_library("textureEncoderCL") {
104  if (!use_clang_android && !use_clang_ios) {
105    branch_protector_ret = "pac_ret"
106    sanitize = {
107      cfi = true
108      cfi_cross_dso = true
109      cfi_vcall_icall_only = true
110      debug = false
111    }
112  }
113  sources = [ "src/texture_encode/image_compressor.cpp" ]
114  include_dirs = [
115    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
116    "${image_subsystem}/interfaces/innerkits/include",
117    "include/texture_encode",
118  ]
119  if (use_mingw_win) {
120    configs += [ ":win_config" ]
121  } else if (use_clang_mac) {
122    configs += [ ":mac_config" ]
123  } else {
124    external_deps = [
125      "c_utils:utils",
126      "hilog:libhilog",
127      "opencl-headers:libcl",
128    ]
129  }
130  cflags = [ "-O3" ]
131  cflags_cc = [ "-O3" ]
132  innerapi_tags = [ "platformsdk" ]
133  subsystem_name = "multimedia"
134  part_name = "image_framework"
135}
136
137ohos_shared_library("extplugin") {
138  if (!use_clang_android && !use_clang_ios) {
139    branch_protector_ret = "pac_ret"
140    sanitize = {
141      cfi = true
142      cfi_cross_dso = true
143      cfi_vcall_icall_only = true
144      debug = false
145    }
146  }
147  sources = [
148    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/abstract_exif_metadata_accessor.cpp",
149    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/buffer_metadata_stream.cpp",
150    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/data_buf.cpp",
151    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/dng_exif_metadata_accessor.cpp",
152    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata.cpp",
153    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata_formatter.cpp",
154    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/file_metadata_stream.cpp",
155    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/heif_exif_metadata_accessor.cpp",
156    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/jpeg_exif_metadata_accessor.cpp",
157    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/metadata_accessor_factory.cpp",
158    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_exif_metadata_accessor.cpp",
159    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_image_chunk_utils.cpp",
160    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/tiff_parser.cpp",
161    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/webp_exif_metadata_accessor.cpp",
162    "src/ext_decoder.cpp",
163    "src/ext_encoder.cpp",
164    "src/ext_pixel_convert.cpp",
165    "src/ext_stream.cpp",
166    "src/ext_wstream.cpp",
167    "src/hdr/hdr_helper.cpp",
168    "src/hdr/jpeg_mpf_parser.cpp",
169    "src/jpeg_yuv_decoder/jpeg_decoder_yuv.cpp",
170    "src/jpeg_yuv_decoder/jpeg_yuvdata_converter.cpp",
171    "src/plugin_export.cpp",
172    "src/texture_encode/astc_codec.cpp",
173  ]
174  if (enable_jpeg_hw_decode) {
175    sources += [ "src/hardware/jpeg_hw_decoder.cpp" ]
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      "drivers_peripheral_display:hdi_gralloc_client",
234      "ffmpeg:libohosffmpeg",
235      "ffrt:libffrt",
236      "graphic_2d:color_manager",
237      "graphic_surface:surface",
238      "hilog:libhilog",
239      "hisysevent:libhisysevent",
240      "libexif:libexif",
241      "libjpeg-turbo:turbojpeg",
242      "skia:libjpeg",
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    }
258
259    if (enable_jpeg_hw_decode) {
260      external_deps += [
261        "drivers_interface_codec:libimage_proxy_2.0",
262        "drivers_interface_display:libdisplay_buffer_hdi_impl",
263        "drivers_interface_display:libdisplay_buffer_proxy_1.0",
264        "drivers_interface_display:libdisplay_composer_hdi_impl",
265        "drivers_interface_display:libdisplay_composer_proxy_1.0",
266        "hdf_core:libhdf_utils",
267        "hdf_core:libhdi",
268        "ipc:ipc_single",
269      ]
270      defines += [ "JPEG_HW_DECODE_ENABLE" ]
271    }
272
273    if (enable_heif_hw_decode) {
274      defines += [ "HEIF_HW_DECODE_ENABLE" ]
275      include_dirs += [ "include/heif_impl/heif_parser" ]
276      external_deps += [
277        "drivers_interface_codec:libcodec_proxy_3.0",
278        "drivers_peripheral_codec:libcodec_hdi_omx_client",
279        "openmax:libopenmax_static",
280      ]
281    }
282
283    if (enable_heif_hw_encode) {
284      defines += [ "HEIF_HW_ENCODE_ENABLE" ]
285      external_deps += [ "drivers_interface_codec:libimage_proxy_2.0" ]
286    }
287  }
288  cflags = [
289    "-DIMAGE_COLORSPACE_FLAG",
290    "-O3",
291  ]
292  cflags_cc = [ "-O3" ]
293  innerapi_tags = [ "platformsdk" ]
294
295  external_deps += [ "zlib:libz" ]
296
297  subsystem_name = "multimedia"
298  part_name = "image_framework"
299}
300
301ohos_prebuilt_etc("extpluginmetadata") {
302  source = "extplugin.pluginmeta"
303  relative_install_dir = "multimediaplugin/image"
304  subsystem_name = "multimedia"
305  part_name = "image_framework"
306}
307
308if (is_arkui_x) {
309  ohos_source_set("heifparser") {
310    if (!use_clang_android && !use_clang_ios) {
311      sanitize = {
312        cfi = true
313        cfi_cross_dso = true
314        cfi_vcall_icall_only = true
315        debug = false
316      }
317    }
318
319    remove_configs = [ "//build/config/compiler:no_rtti" ]
320
321    configs = [ "//build/config/compiler:rtti" ]
322
323    include_dirs = [
324      "include/heif_impl/heif_parser",
325      "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
326    ]
327
328    sources = [
329      "src/heif_impl/heif_parser/box/basic_box.cpp",
330      "src/heif_impl/heif_parser/box/heif_box.cpp",
331      "src/heif_impl/heif_parser/box/item_data_box.cpp",
332      "src/heif_impl/heif_parser/box/item_info_box.cpp",
333      "src/heif_impl/heif_parser/box/item_property_aux_box.cpp",
334      "src/heif_impl/heif_parser/box/item_property_basic_box.cpp",
335      "src/heif_impl/heif_parser/box/item_property_box.cpp",
336      "src/heif_impl/heif_parser/box/item_property_color_box.cpp",
337      "src/heif_impl/heif_parser/box/item_property_display_box.cpp",
338      "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp",
339      "src/heif_impl/heif_parser/box/item_property_transform_box.cpp",
340      "src/heif_impl/heif_parser/box/item_ref_box.cpp",
341      "src/heif_impl/heif_parser/heif_image.cpp",
342      "src/heif_impl/heif_parser/heif_parser.cpp",
343      "src/heif_impl/heif_parser/heif_stream.cpp",
344      "src/heif_impl/heif_parser/heif_utils.cpp",
345    ]
346
347    external_deps = [ "c_utils:utils" ]
348
349    subsystem_name = "multimedia"
350    deps = [ "//third_party/bounds_checking_function:libsec_static" ]
351    part_name = "image_framework"
352  }
353} else {
354  ohos_shared_library("heifparser") {
355    if (!use_clang_android && !use_clang_ios) {
356      branch_protector_ret = "pac_ret"
357      sanitize = {
358        cfi = true
359        cfi_cross_dso = true
360        cfi_vcall_icall_only = true
361        debug = false
362      }
363    }
364
365    remove_configs = [ "//build/config/compiler:no_rtti" ]
366
367    configs = [ "//build/config/compiler:rtti" ]
368
369    include_dirs = [
370      "include/heif_impl/heif_parser",
371      "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
372    ]
373
374    sources = [
375      "src/heif_impl/heif_parser/box/basic_box.cpp",
376      "src/heif_impl/heif_parser/box/heif_box.cpp",
377      "src/heif_impl/heif_parser/box/item_data_box.cpp",
378      "src/heif_impl/heif_parser/box/item_info_box.cpp",
379      "src/heif_impl/heif_parser/box/item_property_aux_box.cpp",
380      "src/heif_impl/heif_parser/box/item_property_basic_box.cpp",
381      "src/heif_impl/heif_parser/box/item_property_box.cpp",
382      "src/heif_impl/heif_parser/box/item_property_color_box.cpp",
383      "src/heif_impl/heif_parser/box/item_property_display_box.cpp",
384      "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp",
385      "src/heif_impl/heif_parser/box/item_property_transform_box.cpp",
386      "src/heif_impl/heif_parser/box/item_ref_box.cpp",
387      "src/heif_impl/heif_parser/heif_image.cpp",
388      "src/heif_impl/heif_parser/heif_parser.cpp",
389      "src/heif_impl/heif_parser/heif_stream.cpp",
390      "src/heif_impl/heif_parser/heif_utils.cpp",
391    ]
392
393    external_deps = [ "c_utils:utils" ]
394
395    subsystem_name = "multimedia"
396    innerapi_tags = [ "platformsdk_indirect" ]
397    part_name = "image_framework"
398  }
399}
400
401config("heif_hw_decoder_cfg") {
402  cflags_cc = [ "-fexceptions" ]
403}
404
405ohos_shared_library("heifimpl") {
406  if (!use_clang_android && !use_clang_ios) {
407    branch_protector_ret = "pac_ret"
408    sanitize = {
409      cfi = true
410      cfi_cross_dso = true
411      cfi_vcall_icall_only = true
412      debug = false
413    }
414  }
415
416  defines = []
417  if (build_variant == "root") {
418    defines += [ "BUILD_ENG_VERSION" ]
419  }
420  if (enable_heif_hw_decode) {
421    defines += [ "HEIF_HW_DECODE_ENABLE" ]
422  }
423
424  configs = []
425  if (enable_heif_hw_decode) {
426    configs += [ ":heif_hw_decoder_cfg" ]
427  }
428
429  include_dirs = [
430    "include",
431    "include/heif_impl",
432    "include/heif_impl/heif_parser",
433    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
434    "${image_subsystem}/interfaces/innerkits/include",
435  ]
436
437  sources = [ "src/heif_impl/HeifDecoderImpl.cpp" ]
438
439  if (enable_heif_hw_decode) {
440    sources += [
441      "src/hardware/heif_hw_decoder.cpp",
442      "src/hardware/imagecodec/codec_state.cpp",
443      "src/hardware/imagecodec/format.cpp",
444      "src/hardware/imagecodec/image_codec.cpp",
445      "src/hardware/imagecodec/image_codec_buffer.cpp",
446      "src/hardware/imagecodec/image_codec_dfx.cpp",
447      "src/hardware/imagecodec/image_codec_list.cpp",
448      "src/hardware/imagecodec/image_decoder.cpp",
449      "src/hardware/imagecodec/msg_handle_loop.cpp",
450      "src/hardware/imagecodec/state_machine.cpp",
451      "src/hardware/imagecodec/type_converter.cpp",
452    ]
453  }
454
455  deps = [
456    ":heifparser",
457    "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
458  ]
459
460  external_deps = [
461    "ffrt:libffrt",
462    "graphic_2d:color_manager",
463    "graphic_surface:surface",
464    "hilog:libhilog",
465  ]
466
467  if (enable_heif_hw_decode) {
468    external_deps += [
469      "c_utils:utils",
470      "drivers_interface_codec:libcodec_proxy_3.0",
471      "drivers_peripheral_codec:libcodec_hdi_omx_client",
472      "ffmpeg:libohosffmpeg",
473      "hdf_core:libhdi",
474      "init:libbegetutil",
475      "ipc:ipc_core",
476      "openmax:libopenmax_static",
477      "qos_manager:qos",
478    ]
479  }
480
481  if (enable_heif_hw_decode && build_variant == "root") {
482    external_deps += [ "hitrace:hitrace_meter" ]
483  }
484
485  subsystem_name = "multimedia"
486  innerapi_tags = [ "platformsdk_indirect" ]
487  part_name = "image_framework"
488}
489