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 cfi = true 144 cfi_cross_dso = true 145 cfi_vcall_icall_only = true 146 debug = false 147 } 148 } 149 sources = [ 150 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/abstract_exif_metadata_accessor.cpp", 151 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/buffer_metadata_stream.cpp", 152 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/data_buf.cpp", 153 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/dng_exif_metadata_accessor.cpp", 154 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata.cpp", 155 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/exif_metadata_formatter.cpp", 156 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/file_metadata_stream.cpp", 157 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/heif_exif_metadata_accessor.cpp", 158 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/jpeg_exif_metadata_accessor.cpp", 159 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/metadata_accessor_factory.cpp", 160 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_exif_metadata_accessor.cpp", 161 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/png_image_chunk_utils.cpp", 162 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/tiff_parser.cpp", 163 "$image_subsystem/frameworks/innerkitsimpl/accessor/src/webp_exif_metadata_accessor.cpp", 164 "src/ext_decoder.cpp", 165 "src/ext_encoder.cpp", 166 "src/ext_pixel_convert.cpp", 167 "src/ext_stream.cpp", 168 "src/ext_wstream.cpp", 169 "src/hdr/hdr_helper.cpp", 170 "src/hdr/jpeg_mpf_parser.cpp", 171 "src/jpeg_yuv_decoder/jpeg_decoder_yuv.cpp", 172 "src/jpeg_yuv_decoder/jpeg_yuvdata_converter.cpp", 173 "src/plugin_export.cpp", 174 "src/texture_encode/astc_codec.cpp", 175 ] 176 if (enable_jpeg_hw_decode) { 177 sources += [ "src/hardware/jpeg_hw_decoder.cpp" ] 178 } 179 configs = [ 180 ":plugins_includes", 181 ":third_part_includes", 182 ] 183 include_dirs = [ 184 "include", 185 "include/hdr", 186 "include/heif_impl/heif_parser", 187 "include/texture_encode", 188 "include/jpeg_yuv_decoder", 189 "${image_subsystem}/interfaces/innerkits/include", 190 "${image_subsystem}/frameworks/innerkitsimpl/utils/include", 191 "${image_subsystem}/frameworks/innerkitsimpl/accessor/include", 192 "${image_subsystem}/plugins/common/libs/image/formatagentplugin/include", 193 "${image_subsystem}/frameworks/innerkitsimpl/pixelconverter/include", 194 ] 195 if (use_mingw_win) { 196 configs += [ ":win_config" ] 197 deps = [ 198 ":heifparser", 199 "${graphic_root}/ide/libs/skia:skia", 200 "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils_static", 201 "${image_subsystem}/mock/native:log_mock_static", 202 "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent", 203 "${image_subsystem}/plugins/manager:pluginmanager_static", 204 ] 205 deps += skia_core 206 } else if (use_clang_mac) { 207 configs += [ ":mac_config" ] 208 deps = [ 209 ":heifparser", 210 "${graphic_root}/ide/libs/skia:skia", 211 "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils_static", 212 "${image_subsystem}/mock/native:log_mock_static", 213 "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent", 214 "${image_subsystem}/plugins/manager:pluginmanager_static", 215 "${third_party_root}/bounds_checking_function:libsec_static", 216 ] 217 } else { 218 public_configs = [ ":ext_public_config" ] 219 defines = [] 220 deps = [ 221 ":exifhelper", 222 ":heifimpl", 223 ":heifparser", 224 "${image_subsystem}//frameworks/innerkitsimpl/pixelconverter:pixelconvertadapter", 225 "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils", 226 "${image_subsystem}/interfaces/innerkits:image_native", 227 "${image_subsystem}/plugins/common/libs/image/formatagentplugin:imageformatagent", 228 "${image_subsystem}/plugins/manager:pluginmanager", 229 ] 230 231 external_deps = [ 232 "astc-encoder:astc_encoder_shared", 233 "c_utils:utils", 234 "drivers_interface_display:libdisplay_commontype_proxy_1.0", 235 "drivers_peripheral_display:hdi_gralloc_client", 236 "ffmpeg:libohosffmpeg", 237 "ffrt:libffrt", 238 "graphic_2d:color_manager", 239 "graphic_surface:surface", 240 "hilog:libhilog", 241 "hisysevent:libhisysevent", 242 "libexif:libexif", 243 "libjpeg-turbo:turbojpeg", 244 "skia:libjpeg", 245 "skia:skia_canvaskit", 246 "zlib:libz", 247 ] 248 249 if (defined(global_parts_info) && 250 defined(global_parts_info.open_source_libyuv)) { 251 defines += [ "ENABLE_ASTC_ENCODE_BASED_GPU" ] 252 deps += [ ":textureEncoderCL" ] 253 external_deps += [ "opencl-headers:libcl" ] 254 } 255 256 if (defined(global_parts_info) && 257 defined(global_parts_info.graphic_graphic_2d_ext)) { 258 defines += [ "SUT_ENCODE_ENABLE" ] 259 } 260 261 if (enable_jpeg_hw_decode) { 262 external_deps += [ 263 "drivers_interface_codec:libimage_proxy_2.0", 264 "drivers_interface_display:libdisplay_buffer_hdi_impl", 265 "drivers_interface_display:libdisplay_buffer_proxy_1.0", 266 "drivers_interface_display:libdisplay_composer_hdi_impl", 267 "drivers_interface_display:libdisplay_composer_proxy_1.0", 268 "hdf_core:libhdf_utils", 269 "hdf_core:libhdi", 270 "ipc:ipc_single", 271 ] 272 defines += [ "JPEG_HW_DECODE_ENABLE" ] 273 } 274 275 if (enable_heif_hw_decode) { 276 defines += [ "HEIF_HW_DECODE_ENABLE" ] 277 include_dirs += [ "include/heif_impl/heif_parser" ] 278 external_deps += [ 279 "drivers_interface_codec:libcodec_proxy_3.0", 280 "drivers_peripheral_codec:libcodec_hdi_omx_client", 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.0" ] 288 } 289 } 290 cflags = [ 291 "-DIMAGE_COLORSPACE_FLAG", 292 "-O3", 293 ] 294 cflags_cc = [ "-O3" ] 295 innerapi_tags = [ "platformsdk" ] 296 297 external_deps += [ "zlib:libz" ] 298 299 subsystem_name = "multimedia" 300 part_name = "image_framework" 301} 302 303ohos_prebuilt_etc("extpluginmetadata") { 304 source = "extplugin.pluginmeta" 305 relative_install_dir = "multimediaplugin/image" 306 subsystem_name = "multimedia" 307 part_name = "image_framework" 308} 309 310if (is_arkui_x) { 311 ohos_source_set("heifparser") { 312 if (!use_clang_android && !use_clang_ios) { 313 sanitize = { 314 cfi = true 315 cfi_cross_dso = true 316 cfi_vcall_icall_only = true 317 debug = false 318 } 319 } 320 321 remove_configs = [ "//build/config/compiler:no_rtti" ] 322 323 configs = [ "//build/config/compiler:rtti" ] 324 325 include_dirs = [ 326 "include/heif_impl/heif_parser", 327 "${image_subsystem}/frameworks/innerkitsimpl/utils/include", 328 ] 329 330 sources = [ 331 "src/heif_impl/heif_parser/box/basic_box.cpp", 332 "src/heif_impl/heif_parser/box/heif_box.cpp", 333 "src/heif_impl/heif_parser/box/item_data_box.cpp", 334 "src/heif_impl/heif_parser/box/item_info_box.cpp", 335 "src/heif_impl/heif_parser/box/item_property_aux_box.cpp", 336 "src/heif_impl/heif_parser/box/item_property_basic_box.cpp", 337 "src/heif_impl/heif_parser/box/item_property_box.cpp", 338 "src/heif_impl/heif_parser/box/item_property_color_box.cpp", 339 "src/heif_impl/heif_parser/box/item_property_display_box.cpp", 340 "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp", 341 "src/heif_impl/heif_parser/box/item_property_transform_box.cpp", 342 "src/heif_impl/heif_parser/box/item_ref_box.cpp", 343 "src/heif_impl/heif_parser/heif_image.cpp", 344 "src/heif_impl/heif_parser/heif_parser.cpp", 345 "src/heif_impl/heif_parser/heif_stream.cpp", 346 "src/heif_impl/heif_parser/heif_utils.cpp", 347 ] 348 349 external_deps = [ "c_utils:utils" ] 350 351 subsystem_name = "multimedia" 352 deps = [ "//third_party/bounds_checking_function:libsec_static" ] 353 part_name = "image_framework" 354 } 355} else { 356 ohos_shared_library("heifparser") { 357 if (!use_clang_android && !use_clang_ios) { 358 branch_protector_ret = "pac_ret" 359 sanitize = { 360 cfi = true 361 cfi_cross_dso = true 362 cfi_vcall_icall_only = true 363 debug = false 364 } 365 } 366 367 remove_configs = [ "//build/config/compiler:no_rtti" ] 368 369 configs = [ "//build/config/compiler:rtti" ] 370 371 include_dirs = [ 372 "include/heif_impl/heif_parser", 373 "${image_subsystem}/frameworks/innerkitsimpl/utils/include", 374 ] 375 376 sources = [ 377 "src/heif_impl/heif_parser/box/basic_box.cpp", 378 "src/heif_impl/heif_parser/box/heif_box.cpp", 379 "src/heif_impl/heif_parser/box/item_data_box.cpp", 380 "src/heif_impl/heif_parser/box/item_info_box.cpp", 381 "src/heif_impl/heif_parser/box/item_property_aux_box.cpp", 382 "src/heif_impl/heif_parser/box/item_property_basic_box.cpp", 383 "src/heif_impl/heif_parser/box/item_property_box.cpp", 384 "src/heif_impl/heif_parser/box/item_property_color_box.cpp", 385 "src/heif_impl/heif_parser/box/item_property_display_box.cpp", 386 "src/heif_impl/heif_parser/box/item_property_hvcc_box.cpp", 387 "src/heif_impl/heif_parser/box/item_property_transform_box.cpp", 388 "src/heif_impl/heif_parser/box/item_ref_box.cpp", 389 "src/heif_impl/heif_parser/heif_image.cpp", 390 "src/heif_impl/heif_parser/heif_parser.cpp", 391 "src/heif_impl/heif_parser/heif_stream.cpp", 392 "src/heif_impl/heif_parser/heif_utils.cpp", 393 ] 394 395 external_deps = [ "c_utils:utils" ] 396 397 subsystem_name = "multimedia" 398 innerapi_tags = [ "platformsdk_indirect" ] 399 part_name = "image_framework" 400 } 401} 402 403config("heif_hw_decoder_cfg") { 404 cflags_cc = [ "-fexceptions" ] 405} 406 407ohos_shared_library("heifimpl") { 408 if (!use_clang_android && !use_clang_ios) { 409 branch_protector_ret = "pac_ret" 410 sanitize = { 411 cfi = true 412 cfi_cross_dso = true 413 cfi_vcall_icall_only = true 414 debug = false 415 } 416 } 417 418 defines = [] 419 if (build_variant == "root") { 420 defines += [ "BUILD_ENG_VERSION" ] 421 } 422 if (enable_heif_hw_decode) { 423 defines += [ "HEIF_HW_DECODE_ENABLE" ] 424 } 425 426 configs = [] 427 if (enable_heif_hw_decode) { 428 configs += [ ":heif_hw_decoder_cfg" ] 429 } 430 431 include_dirs = [ 432 "include", 433 "include/heif_impl", 434 "include/heif_impl/heif_parser", 435 "${image_subsystem}/frameworks/innerkitsimpl/utils/include", 436 "${image_subsystem}/interfaces/innerkits/include", 437 ] 438 439 sources = [ "src/heif_impl/HeifDecoderImpl.cpp" ] 440 441 if (enable_heif_hw_decode) { 442 sources += [ 443 "src/hardware/heif_hw_decoder.cpp", 444 "src/hardware/imagecodec/codec_state.cpp", 445 "src/hardware/imagecodec/format.cpp", 446 "src/hardware/imagecodec/image_codec.cpp", 447 "src/hardware/imagecodec/image_codec_buffer.cpp", 448 "src/hardware/imagecodec/image_codec_dfx.cpp", 449 "src/hardware/imagecodec/image_codec_list.cpp", 450 "src/hardware/imagecodec/image_decoder.cpp", 451 "src/hardware/imagecodec/msg_handle_loop.cpp", 452 "src/hardware/imagecodec/state_machine.cpp", 453 "src/hardware/imagecodec/type_converter.cpp", 454 ] 455 } 456 457 deps = [ 458 ":heifparser", 459 "${image_subsystem}/frameworks/innerkitsimpl/utils:image_utils", 460 ] 461 462 external_deps = [ 463 "ffrt:libffrt", 464 "graphic_2d:color_manager", 465 "graphic_surface:surface", 466 "hilog:libhilog", 467 ] 468 469 if (enable_heif_hw_decode) { 470 external_deps += [ 471 "c_utils:utils", 472 "drivers_interface_codec:libcodec_proxy_3.0", 473 "drivers_peripheral_codec:libcodec_hdi_omx_client", 474 "ffmpeg:libohosffmpeg", 475 "hdf_core:libhdi", 476 "init:libbegetutil", 477 "ipc:ipc_core", 478 "openmax:libopenmax_static", 479 "qos_manager:qos", 480 ] 481 } 482 483 if (enable_heif_hw_decode && build_variant == "root") { 484 external_deps += [ "hitrace:hitrace_meter" ] 485 } 486 487 subsystem_name = "multimedia" 488 innerapi_tags = [ "platformsdk_indirect" ] 489 part_name = "image_framework" 490} 491