# 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.gni")
import("//foundation/graphic/graphic_2d/graphic_config.gni")

## Build libskeffectchain.so

config("effect_SKeffectChian_config") {
  cflags = [
    "-Wall",
    "-Werror",
    "-g3",
    "-Wall",
    "-Wno-pointer-arith",
    "-Wno-non-virtual-dtor",
    "-Wno-missing-field-initializers",
    "-Wno-c++11-narrowing",
  ]
  include_dirs =
      [ "$graphic_2d_root/rosen/modules/render_service_base/include" ]
}

config("effect_SKeffectChian_public_config") {
  include_dirs = [
    "../effectChain/include",
    "../egl/include",
    "$graphic_2d_root/utils/log",
    "include",
  ]

  if (is_arkui_x) {
    include_dirs += [
      "//foundation/graphic/graphic_2d/rosen/modules/2d_graphics/include",
      "//foundation/multimedia/image_framework/interfaces/innerkits/include",
      "//foundation/graphic/graphic_2d/utils/color_manager/export",
      "//base/hiviewdfx/hilog/interfaces/native/innerkits",
    ]
  }

  if (target_os == "ios") {
    include_dirs -= [ "../egl/include" ]
  }
}
if (is_arkui_x) {
  ohos_source_set("skeffectchain") {
    public_deps = [
      "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_${target_os}",
      "//foundation/arkui/ace_engine/adapter/${target_os}/build:libarkui_${target_os}",
    ]

    if (target_os == "android") {
      defines = [ "ANDROID_PLATFORM" ]
    } else if (target_os == "ios") {
      defines = [ "IOS_PLATFORM" ]
    }

    if (target_os == "android") {
      public_deps +=
          [ "$graphic_2d_root/rosen/modules/effect/egl:libegl_effect" ]

      if (rs_enable_gpu) {
        defines += gpu_defines
        public_deps += [
          "$graphic_2d_root/frameworks/opengl_wrapper:EGL",
          "$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
        ]
      }
    }

    public_external_deps = [
      "c_utils:utilsbase",
      "skia:skia_canvaskit_static",
    ]

    sources = [
      "src/sk_image_chain.cpp",
      "src/sk_image_filter_factory.cpp",
    ]

    configs = [ ":effect_SKeffectChian_config" ]

    public_configs = [ ":effect_SKeffectChian_public_config" ]

    cflags_cc = [ "-std=c++17" ]

    part_name = "graphic_2d"
    subsystem_name = "graphic"
  }
} else {
  ohos_shared_library("skeffectchain") {
    public_deps = [ "$graphic_2d_root/rosen/modules/effect/egl:libegl_effect" ]

    if (rs_enable_gpu) {
      defines = gpu_defines
      public_deps += [
        "$graphic_2d_root/frameworks/opengl_wrapper:EGL",
        "$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
      ]
    }

    public_external_deps = [
      "graphic_surface:surface",
      "skia:skia_canvaskit",
    ]

    external_deps = [
      "c_utils:utils",
      "hilog:libhilog",
      "hitrace:hitrace_meter",
      "image_framework:image",
      "image_framework:image_native",
      "image_framework:pixelconvertadapter",
      "init:libbegetutil",
      "ipc:ipc_core",
      "napi:ace_napi",
      "samgr:samgr_proxy",
    ]

    sources = [
      "src/sk_image_chain.cpp",
      "src/sk_image_filter_factory.cpp",
    ]

    configs = [ ":effect_SKeffectChian_config" ]

    public_configs = [ ":effect_SKeffectChian_public_config" ]

    deps = [ "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base" ]

    cflags_cc = [ "-std=c++17" ]

    install_enable = true
    part_name = "graphic_2d"
    subsystem_name = "graphic"
  }
}