# Copyright (C) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/ohos_var.gni")
import("//build/ohos.gni")

declare_args() {
  image_framework_feature_upgrade_skia = true
}

# source code for Windows.
use_mingw_win = "${current_os}_${current_cpu}" == "mingw_x86_64"
use_clang_mac = "${current_os}_${current_cpu}" == "mac_x64"
use_clang_ios = current_os == "ios" || current_os == "tvos"
use_clang_android = current_os == "android"

# Toolchain
windows_buildtool = "//build/toolchain/mingw:mingw_x86_64"
mac_buildtool = "//build/toolchain/mac:clang_x64"

# Defines
image_decode_windows_defines = [ "_WIN32" ]
image_decode_mac_defines = [ "_APPLE" ]
image_decode_ios_defines = [ "IOS_PLATFORM" ]
image_decode_android_defines = [ "ANDROID_PLATFORM" ]
image_sep_f = "/f"
image_sep_p = "/p"
image_oundation = "oundation"
image_lugins = "lugins"
image_multimedia = "multimedia"
image_dir = "image_framework"
image_subsystem = "/$image_sep_f$image_oundation/$image_multimedia/$image_dir"
ipc_subsystem = "/$image_sep_f$image_oundation"
graphic_multimedia = "graphic"
graphic_dir = "graphic_2d"
graphic_subsystem =
    "/$image_sep_f$image_oundation/$graphic_multimedia/$graphic_dir"
plugins_lib_root = "/$image_sep_p$image_lugins/libs"
comlib_sep_c = "/c"
comlib_ommonlibrary = "ommonlibrary"
commonlibrary_c_utils = "c_utils"
commonlibrary_subsystem =
    "/$comlib_sep_c$comlib_ommonlibrary/$commonlibrary_c_utils"
commonlibrary_memory_utils = "memory_utils"
comlibmemory_subsystem =
    "/$comlib_sep_c$comlib_ommonlibrary/$commonlibrary_memory_utils"
base_sep_b = "/b"
base_ase = "ase"
resource_management_subsystem =
    "/$base_sep_b$base_ase/global/resource_management"
graphic_surface_root = "//foundation/graphic/graphic_surface"

image_use_new_skia = image_framework_feature_upgrade_skia

skia_root = "//third_party"
skia_deps_root = skia_root
skia_core = [ "$skia_deps_root/skia:skia_core" ]
skia_skcms = [ "$skia_deps_root/skia:skcms" ]

exif_root = "//third_party"

if (image_use_new_skia) {
  third_party_skia_root = "//third_party/skia/m133"
} else {
  third_party_skia_root = "//third_party/skia"
}

if (use_clang_android) {
  skia_platform = [ "$skia_deps_root/skia:skia_android" ]
} else if (use_clang_ios) {
  skia_platform = [ "$skia_deps_root/skia:skia_ios" ]
} else if (use_mingw_win) {
  skia_platform = [ "$skia_deps_root/skia:skia_windows" ]
} else if (use_clang_mac) {
  skia_platform = [ "$skia_deps_root/skia:skia_mac" ]
} else {
  skia_platform = [ "$skia_deps_root/skia:skia_ohos" ]
}

# hw_decoder
declare_args() {
  enable_jpeg_hw_decode = true
  enable_heif_hw_decode = false
  enable_libexif = true
  enable_heif_hw_encode = false
  enable_picture = false
  enable_picture_ndk = false

  if (defined(global_parts_info) &&
      !defined(global_parts_info.hdf_drivers_interface_display)) {
    enable_jpeg_hw_decode = false
    enable_heif_hw_decode = false
    enable_heif_hw_encode = false
    enable_picture = false
    enable_picture_ndk = false
  }
  has_libtiff = true
  if (defined(global_parts_info) &&
      !defined(global_parts_info.thirdparty_libtiff)) {
    has_libtiff = false
  }
  has_dav1d = true
  if (defined(global_parts_info) &&
      !defined(global_parts_info.thirdparty_dav1d)) {
    has_dav1d = false
  }
}