1e9297d28Sopenharmony_ci# Copyright (c) 2024 Huawei Device Co., Ltd.. All rights reserved.
2e9297d28Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3e9297d28Sopenharmony_ci# you may not use this file except in compliance with the License.
4e9297d28Sopenharmony_ci# You may obtain a copy of the License at
5e9297d28Sopenharmony_ci#
6e9297d28Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7e9297d28Sopenharmony_ci#
8e9297d28Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9e9297d28Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10e9297d28Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11e9297d28Sopenharmony_ci# See the License for the specific language governing permissions and
12e9297d28Sopenharmony_ci# limitations under the License.
13e9297d28Sopenharmony_ci
14e9297d28Sopenharmony_ciimport("//build/ohos.gni")
15e9297d28Sopenharmony_ciimport("//foundation/graphic/graphic_2d/graphic_config.gni")
16e9297d28Sopenharmony_cieffect_root = "$graphic_2d_root/rosen/modules/effect"
17e9297d28Sopenharmony_cieffect_ndk_include_dir =
18e9297d28Sopenharmony_ci    "$graphic_2d_root/rosen/modules/effect/effect_ndk/include"
19e9297d28Sopenharmony_cieffect_ndk_src_dir = "$graphic_2d_root/rosen/modules/effect/effect_ndk/src"
20e9297d28Sopenharmony_ci
21e9297d28Sopenharmony_ciconfig("export_config") {
22e9297d28Sopenharmony_ci  include_dirs = [ "$effect_ndk_include_dir" ]
23e9297d28Sopenharmony_ci}
24e9297d28Sopenharmony_ci
25e9297d28Sopenharmony_citemplate("effect_ndk_source_set") {
26e9297d28Sopenharmony_ci  forward_variables_from(invoker, "*")
27e9297d28Sopenharmony_ci
28e9297d28Sopenharmony_ci  ohos_source_set(target_name) {
29e9297d28Sopenharmony_ci    defines += invoker.defines
30e9297d28Sopenharmony_ci    cflags_cc = []
31e9297d28Sopenharmony_ci
32e9297d28Sopenharmony_ci    sanitize = {
33e9297d28Sopenharmony_ci      cfi = true
34e9297d28Sopenharmony_ci      cfi_cross_dso = true
35e9297d28Sopenharmony_ci      cfi_vcall_icall_only = true
36e9297d28Sopenharmony_ci      debug = false
37e9297d28Sopenharmony_ci    }
38e9297d28Sopenharmony_ci
39e9297d28Sopenharmony_ci    external_deps = [
40e9297d28Sopenharmony_ci      "c_utils:utils",
41e9297d28Sopenharmony_ci      "hilog:libhilog",
42e9297d28Sopenharmony_ci      "image_framework:image",
43e9297d28Sopenharmony_ci    ]
44e9297d28Sopenharmony_ci
45e9297d28Sopenharmony_ci    public_deps = [
46e9297d28Sopenharmony_ci      "$effect_root//skia_effectChain:skeffectchain",
47e9297d28Sopenharmony_ci      "$effect_root/color_picker:color_picker",
48e9297d28Sopenharmony_ci    ]
49e9297d28Sopenharmony_ci    public_external_deps = [ "jsoncpp:jsoncpp" ]
50e9297d28Sopenharmony_ci
51e9297d28Sopenharmony_ci    configs = [ ":export_config" ]
52e9297d28Sopenharmony_ci    sources = [
53e9297d28Sopenharmony_ci      "$effect_ndk_src_dir/effect_filter.cpp",
54e9297d28Sopenharmony_ci      "$effect_ndk_src_dir/filter/filter.cpp",
55e9297d28Sopenharmony_ci    ]
56e9297d28Sopenharmony_ci
57e9297d28Sopenharmony_ci    if (is_arkui_x) {
58e9297d28Sopenharmony_ci      defines += [ "CROSS_PLATFORM" ]
59e9297d28Sopenharmony_ci    }
60e9297d28Sopenharmony_ci    if (rs_enable_gpu) {
61e9297d28Sopenharmony_ci      defines += [ "RS_ENABLE_GPU" ]
62e9297d28Sopenharmony_ci    }
63e9297d28Sopenharmony_ci    if (is_emulator) {
64e9297d28Sopenharmony_ci      defines += [ "ROSEN_EMULATOR" ]
65e9297d28Sopenharmony_ci    }
66e9297d28Sopenharmony_ci
67e9297d28Sopenharmony_ci    include_dirs = [
68e9297d28Sopenharmony_ci      "$graphic_2d_root/rosen/modules/render_service_base/include",
69e9297d28Sopenharmony_ci      "$graphic_2d_root/modules/2d_graphics/include",
70e9297d28Sopenharmony_ci    ]
71e9297d28Sopenharmony_ci
72e9297d28Sopenharmony_ci    if (platform == "ohos" || platform == "ohos_ng") {
73e9297d28Sopenharmony_ci      defines += [ "OHOS_PLATFORM" ]
74e9297d28Sopenharmony_ci      external_deps += [
75e9297d28Sopenharmony_ci        "bounds_checking_function:libsec_static",
76e9297d28Sopenharmony_ci        "image_framework:pixelmap",
77e9297d28Sopenharmony_ci        "image_framework:pixelmap_ndk",
78e9297d28Sopenharmony_ci      ]
79e9297d28Sopenharmony_ci      deps = [ "$graphic_2d_root/rosen/modules/render_service_base:librender_service_base" ]
80e9297d28Sopenharmony_ci      cflags = [ "-fstack-protector-strong" ]
81e9297d28Sopenharmony_ci      cflags_cc += [ "-fstack-protector-strong" ]
82e9297d28Sopenharmony_ci    } else {
83e9297d28Sopenharmony_ci      deps = []
84e9297d28Sopenharmony_ci      cflags = [ "-std=c++17" ]
85e9297d28Sopenharmony_ci
86e9297d28Sopenharmony_ci      if (!is_arkui_x) {
87e9297d28Sopenharmony_ci        deps += [ "$rosen_root/modules/platform:hilog" ]
88e9297d28Sopenharmony_ci      }
89e9297d28Sopenharmony_ci    }
90e9297d28Sopenharmony_ci    part_name = "graphic_2d"
91e9297d28Sopenharmony_ci    subsystem_name = "graphic"
92e9297d28Sopenharmony_ci  }
93e9297d28Sopenharmony_ci}
94e9297d28Sopenharmony_ci
95e9297d28Sopenharmony_cieffect_ndk_source_set("effect_ndk_source_ohos") {
96e9297d28Sopenharmony_ci  platform = "ohos"
97e9297d28Sopenharmony_ci  defines = []
98e9297d28Sopenharmony_ci}
99e9297d28Sopenharmony_ci
100e9297d28Sopenharmony_ciohos_shared_library("native_effect_ndk") {
101e9297d28Sopenharmony_ci  sanitize = {
102e9297d28Sopenharmony_ci    cfi = true
103e9297d28Sopenharmony_ci    cfi_cross_dso = true
104e9297d28Sopenharmony_ci    cfi_vcall_icall_only = true
105e9297d28Sopenharmony_ci    debug = false
106e9297d28Sopenharmony_ci  }
107e9297d28Sopenharmony_ci  platform = current_os
108e9297d28Sopenharmony_ci  if (platform == "mingw") {
109e9297d28Sopenharmony_ci    platform = "windows"
110e9297d28Sopenharmony_ci  }
111e9297d28Sopenharmony_ci  public_configs = [ ":export_config" ]
112e9297d28Sopenharmony_ci
113e9297d28Sopenharmony_ci  if (platform == "ohos") {
114e9297d28Sopenharmony_ci    deps = [ "$effect_root/effect_ndk:effect_ndk_source_ohos" ]
115e9297d28Sopenharmony_ci    symlink_target_name = [ "libnative_effect.so" ]
116e9297d28Sopenharmony_ci    innerapi_tags = [ "ndk" ]
117e9297d28Sopenharmony_ci  }
118e9297d28Sopenharmony_ci  part_name = "graphic_2d"
119e9297d28Sopenharmony_ci  subsystem_name = "graphic"
120e9297d28Sopenharmony_ci}
121