• 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("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    defines += [ "CROSS_PLATFORM" ]
77    include_dirs += [
78      "${image_subsystem}/mock/native/include",
79      "${image_subsystem}/mock/native/include/secure",
80      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/codec",
81      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config",
82      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config/win",
83      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/core",
84    ]
85  }
86}
87config("mac_config") {
88  if (use_clang_mac) {
89    defines = image_decode_mac_defines
90    defines += [ "CROSS_PLATFORM" ]
91    include_dirs += [
92      "${image_subsystem}/mock/native/include",
93      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/codec",
94      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/core",
95      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config/mac",
96      "${asdk_dir}/static_library/${target_os}_${target_cpu}/include/external/skia/include/config",
97      "${third_party_root}/bounds_checking_function/include",
98    ]
99  }
100}
101config("ext_public_config") {
102  include_dirs = [ "${image_subsystem}/plugins/manager/include" ]
103}
104
105ohos_shared_library("textureEncoderCL") {
106  if (!use_clang_android && !use_clang_ios) {
107    branch_protector_ret = "pac_ret"
108    sanitize = {
109      cfi = true
110      cfi_cross_dso = true
111      cfi_vcall_icall_only = true
112      debug = false
113    }
114  }
115  sources = [ "src/texture_encode/image_compressor.cpp" ]
116  include_dirs = [
117    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
118    "${image_subsystem}/interfaces/innerkits/include",
119    "include/texture_encode",
120  ]
121  if (use_mingw_win) {
122    configs += [ ":win_config" ]
123  } else if (use_clang_mac) {
124    configs += [ ":mac_config" ]
125  } else {
126    external_deps = [
127      "c_utils:utils",
128      "hilog:libhilog",
129      "opencl-headers:libcl",
130    ]
131  }
132  cflags = [ "-O3" ]
133  cflags_cc = [ "-O3" ]
134  innerapi_tags = [ "platformsdk" ]
135  subsystem_name = "multimedia"
136  part_name = "image_framework"
137}
138
139ohos_shared_library("extplugin") {
140  if (!use_clang_android && !use_clang_ios) {
141    branch_protector_ret = "pac_ret"
142    sanitize = {
143      boundary_sanitizer = true
144      cfi = true
145      cfi_cross_dso = true
146      cfi_vcall_icall_only = true
147      debug = false
148      integer_overflow = true
149      ubsan = true
150    }
151  }
152  sources = [
153    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/abstract_exif_metadata_accessor.cpp",
154    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/buffer_metadata_stream.cpp",
155    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/data_buf.cpp",
156    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/dng_exif_metadata_accessor.cpp",
157    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata.cpp",
158    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata_formatter.cpp",
159    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/file_metadata_stream.cpp",
160    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/heif_exif_metadata_accessor.cpp",
161    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/jpeg_exif_metadata_accessor.cpp",
162    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/metadata_accessor_factory.cpp",
163    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_exif_metadata_accessor.cpp",
164    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_image_chunk_utils.cpp",
165    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/tiff_parser.cpp",
166    "$image_subsystem/frameworks/innerkitsimpl/accessor/src/webp_exif_metadata_accessor.cpp",
167    "src/ext_decoder.cpp",
168    "src/ext_encoder.cpp",
169    "src/ext_pixel_convert.cpp",
170    "src/ext_stream.cpp",
171    "src/ext_wstream.cpp",
172    "src/hdr/hdr_helper.cpp",
173    "src/hdr/jpeg_mpf_parser.cpp",
174    "src/jpeg_yuv_decoder/jpeg_decoder_yuv.cpp",
175    "src/jpeg_yuv_decoder/jpeg_yuvdata_converter.cpp",
176    "src/plugin_export.cpp",
177    "src/texture_encode/astc_codec.cpp",
178  ]
179  if (enable_jpeg_hw_decode) {
180    sources += [ "src/hardware/jpeg_hw_decoder.cpp" ]
181  }
182  configs = [
183    ":plugins_includes",
184    ":third_part_includes",
185  ]
186  include_dirs = [
187    "include",
188    "include/hdr",
189    "include/heif_impl/heif_parser",
190    "include/texture_encode",
191    "include/jpeg_yuv_decoder",
192    "${image_subsystem}/interfaces/innerkits/include",
193    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
194    "${image_subsystem}/frameworks/innerkitsimpl/accessor/include",
195    "${image_subsystem}/plugins/common/libs/image/formatagentplugin/include",
196    "${image_subsystem}/frameworks/innerkitsimpl/pixelconverter/include",
197  ]
198  if (use_mingw_win) {
199    configs += [ ":win_config" ]
200    deps = [
201      ":heifparser",
202      "${graphic_root}/ide/libs/skia:skia",
203      "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils_static",
204      "${image_subsystem}/mock/native:log_mock_static",
205      "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent",
206      "${image_subsystem}/plugins/manager:pluginmanager_static",
207    ]
208    deps += skia_core
209  } else if (use_clang_mac) {
210    configs += [ ":mac_config" ]
211    deps = [
212      ":heifparser",
213      "${graphic_root}/ide/libs/skia:skia",
214      "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils_static",
215      "${image_subsystem}/mock/native:log_mock_static",
216      "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent",
217      "${image_subsystem}/plugins/manager:pluginmanager_static",
218      "${third_party_root}/bounds_checking_function:libsec_static",
219    ]
220  } else {
221    public_configs = [ ":ext_public_config" ]
222    defines = []
223    deps = [
224      ":exifhelper",
225      ":heifimpl",
226      ":heifparser",
227      "${image_subsystem}//frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter",
228      "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
229      "${image_subsystem}/interfaces/innerkits:image_native",
230      "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent",
231      "${image_subsystem}/plugins/manager:pluginmanager",
232    ]
233
234    external_deps = [
235      "astc-encoder:astc_encoder_shared",
236      "c_utils:utils",
237      "drivers_interface_display:libdisplay_commontype_proxy_1.0",
238      "drivers_peripheral_display:hdi_gralloc_client",
239      "ffmpeg:libohosffmpeg",
240      "ffrt:libffrt",
241      "graphic_2d:color_manager",
242      "graphic_surface:surface",
243      "hilog:libhilog",
244      "hisysevent:libhisysevent",
245      "libexif:libexif",
246      "libjpeg-turbo:turbojpeg",
247      "skia:libjpeg",
248      "skia:skia_canvaskit",
249      "zlib:libz",
250    ]
251
252    if (defined(global_parts_info) &&
253        defined(global_parts_info.open_source_libyuv)) {
254      defines += [ "ENABLE_ASTC_ENCODE_BASED_GPU" ]
255      deps += [ ":textureEncoderCL" ]
256      external_deps += [ "opencl-headers:libcl" ]
257    }
258
259    if (defined(global_parts_info) &&
260        defined(global_parts_info.graphic_graphic_2d_ext)) {
261      defines += [ "SUT_ENCODE_ENABLE" ]
262      if (target_cpu == "arm64" || is_emulator) {
263        defines += [ "SUT_PATH_X64" ]
264      }
265    }
266
267    if (enable_jpeg_hw_decode) {
268      external_deps += [
269        "drivers_interface_codec:libimage_proxy_2.0",
270        "drivers_interface_display:libdisplay_buffer_hdi_impl",
271        "drivers_interface_display:libdisplay_buffer_proxy_1.0",
272        "drivers_interface_display:libdisplay_composer_hdi_impl_1.2",
273        "drivers_interface_display:libdisplay_composer_proxy_1.0",
274        "hdf_core:libhdf_utils",
275        "hdf_core:libhdi",
276        "ipc:ipc_single",
277      ]
278      defines += [ "JPEG_HW_DECODE_ENABLE" ]
279    }
280
281    if (enable_heif_hw_decode) {
282      defines += [ "HEIF_HW_DECODE_ENABLE" ]
283      include_dirs += [ "include/heif_impl/heif_parser" ]
284      external_deps += [
285        "drivers_interface_codec:libcodec_proxy_3.0",
286        "drivers_peripheral_codec:libcodec_hdi_omx_client",
287        "openmax:libopenmax_static",
288      ]
289    }
290
291    if (enable_heif_hw_encode) {
292      defines += [ "HEIF_HW_ENCODE_ENABLE" ]
293      external_deps += [ "drivers_interface_codec:libimage_proxy_2.0" ]
294    }
295  }
296  if (is_ohos) {
297    sources += [ "src/sk_ohoscodec.cpp" ]
298    defines += [ "SK_ENABLE_OHOS_CODEC" ]
299  }
300  cflags = [
301    "-DIMAGE_COLORSPACE_FLAG",
302    "-O3",
303    "-fstack-protector-strong",
304  ]
305  cflags_cc = [ "-O3" ]
306  innerapi_tags = [ "platformsdk" ]
307
308  external_deps += [ "zlib:libz" ]
309
310  subsystem_name = "multimedia"
311  part_name = "image_framework"
312}
313
314ohos_prebuilt_etc("extpluginmetadata") {
315  source = "extplugin.pluginmeta"
316  relative_install_dir = "multimediaplugin/image"
317  subsystem_name = "multimedia"
318  part_name = "image_framework"
319}
320
321if (is_arkui_x) {
322  ohos_source_set("heifparser") {
323    if (!use_clang_android && !use_clang_ios) {
324      sanitize = {
325        cfi = true
326        cfi_cross_dso = true
327        cfi_vcall_icall_only = true
328        debug = false
329      }
330    }
331
332    remove_configs = [ "//build/config/compiler:no_rtti" ]
333
334    configs = [ "//build/config/compiler:rtti" ]
335
336    include_dirs = [
337      "include/heif_impl/heif_parser",
338      "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
339    ]
340
341    sources = [
342      "src/heif_impl/heif_parser/box/basic_box.cpp",
343      "src/heif_impl/heif_parser/box/heif_box.cpp",
344      "src/heif_impl/heif_parser/box/item_data_box.cpp",
345      "src/heif_impl/heif_parser/box/item_info_box.cpp",
346      "src/heif_impl/heif_parser/box/item_movie_box.cpp",
347      "src/heif_impl/heif_parser/box/item_property_aux_box.cpp",
348      "src/heif_impl/heif_parser/box/item_property_basic_box.cpp",
349      "src/heif_impl/heif_parser/box/item_property_box.cpp",
350      "src/heif_impl/heif_parser/box/item_property_color_box.cpp",
351      "src/heif_impl/heif_parser/box/item_property_display_box.cpp",
352      "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp",
353      "src/heif_impl/heif_parser/box/item_property_transform_box.cpp",
354      "src/heif_impl/heif_parser/box/item_ref_box.cpp",
355      "src/heif_impl/heif_parser/heif_image.cpp",
356      "src/heif_impl/heif_parser/heif_parser.cpp",
357      "src/heif_impl/heif_parser/heif_stream.cpp",
358      "src/heif_impl/heif_parser/heif_utils.cpp",
359    ]
360
361    external_deps = [ "c_utils:utils" ]
362
363    subsystem_name = "multimedia"
364    deps = [ "//third_party/bounds_checking_function:libsec_static" ]
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    ]
387
388    sources = [
389      "src/heif_impl/heif_parser/box/basic_box.cpp",
390      "src/heif_impl/heif_parser/box/heif_box.cpp",
391      "src/heif_impl/heif_parser/box/item_data_box.cpp",
392      "src/heif_impl/heif_parser/box/item_info_box.cpp",
393      "src/heif_impl/heif_parser/box/item_movie_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 = [ "c_utils:utils" ]
409
410    subsystem_name = "multimedia"
411    innerapi_tags = [ "platformsdk_indirect" ]
412    part_name = "image_framework"
413  }
414}
415
416config("heif_hw_decoder_cfg") {
417  cflags_cc = [ "-fexceptions" ]
418}
419
420ohos_shared_library("heifimpl") {
421  if (!use_clang_android && !use_clang_ios) {
422    branch_protector_ret = "pac_ret"
423    sanitize = {
424      cfi = true
425      cfi_cross_dso = true
426      cfi_vcall_icall_only = true
427      debug = false
428    }
429  }
430
431  defines = []
432  if (build_variant == "root") {
433    defines += [ "BUILD_ENG_VERSION" ]
434  }
435  if (enable_heif_hw_decode) {
436    defines += [ "HEIF_HW_DECODE_ENABLE" ]
437  }
438
439  configs = []
440  if (enable_heif_hw_decode) {
441    configs += [ ":heif_hw_decoder_cfg" ]
442  }
443
444  include_dirs = [
445    "include",
446    "include/heif_impl",
447    "include/heif_impl/heif_parser",
448    "${image_subsystem}/frameworks/innerkitsimpl/utils/include",
449    "${image_subsystem}/interfaces/innerkits/include",
450  ]
451
452  sources = [ "src/heif_impl/HeifDecoderImpl.cpp" ]
453
454  if (enable_heif_hw_decode) {
455    sources += [
456      "src/hardware/heif_hw_decoder.cpp",
457      "src/hardware/imagecodec/codec_state.cpp",
458      "src/hardware/imagecodec/format.cpp",
459      "src/hardware/imagecodec/image_codec.cpp",
460      "src/hardware/imagecodec/image_codec_buffer.cpp",
461      "src/hardware/imagecodec/image_codec_dfx.cpp",
462      "src/hardware/imagecodec/image_codec_list.cpp",
463      "src/hardware/imagecodec/image_decoder.cpp",
464      "src/hardware/imagecodec/msg_handle_loop.cpp",
465      "src/hardware/imagecodec/state_machine.cpp",
466      "src/hardware/imagecodec/type_converter.cpp",
467    ]
468  }
469
470  deps = [
471    ":heifparser",
472    "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils",
473  ]
474
475  external_deps = [
476    "ffrt:libffrt",
477    "graphic_2d:color_manager",
478    "graphic_surface:surface",
479    "hilog:libhilog",
480  ]
481
482  if (enable_heif_hw_decode) {
483    external_deps += [
484      "c_utils:utils",
485      "drivers_interface_codec:libcodec_proxy_3.0",
486      "drivers_peripheral_codec:libcodec_hdi_omx_client",
487      "ffmpeg:libohosffmpeg",
488      "hdf_core:libhdi",
489      "hitrace:hitrace_meter",
490      "init:libbegetutil",
491      "ipc:ipc_core",
492      "openmax:libopenmax_static",
493      "qos_manager:qos",
494    ]
495  }
496
497  subsystem_name = "multimedia"
498  innerapi_tags = [ "platformsdk_indirect" ]
499  part_name = "image_framework"
500}
501