1# Copyright (c) 2021 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/config/components/multimodalinput/cursor_config.gni")
15declare_args() {
16  graphic_2d_feature_product = "default"
17  graphic_2d_feature_enable_pgo = false
18  graphic_2d_feature_pgo_path = ""
19  graphic_2d_feature_bootanimation_enable = true
20  graphic_2d_feature_ace_enable_gpu = true
21  graphic_2d_feature_color_gamut_enable = false
22  graphic_2d_feature_rs_enable_eglimage = false
23  graphic_2d_feature_rs_enable_profiler = true
24  graphic_2d_feature_use_texgine = false
25  graphic_2d_feature_rs_enable_uni_render = false
26  graphic_2d_feature_wuji_enable = false
27  graphic_2d_feature_enable_afbc = false
28  graphic_2d_feature_freemem_enable = false
29  graphic_2d_feature_parallel_render_enable = true
30  graphic_2d_feature_enable_vulkan = false
31  graphic_2d_feature_enable_flutter_vulkan = false
32  graphic_2d_feature_enable_opengl = true
33  graphic_2d_feature_enable_ddgr = false
34  graphic_2d_feature_enable_opinc = false
35  graphic_2d_feature_enable_filter_cache = true
36  graphic_2d_feature_parallel_upload_enable = true
37  enable_text_gine = true
38  use_texgine = false
39  use_skia_txt = true
40  use_video_processing_engine = false
41  logger_enable_scope = false
42  texgine_enable_debug_log = false
43  player_framework_enable = true
44  graphic_2d_feature_drivers_interface_display_enable = true
45  graphic_2d_feature_tp_switch_enbale = false
46  graphic_2d_feature_enable_recording_dcl = true
47  graphic_2d_feature_use_igraphics_extend_hooks = false
48  graphic_2d_feature_use_aps_igameservice_func = false
49  graphic_2d_feature_enable_chipset_vsync = false
50  graphic_2d_feature_enable_rspipeline = true
51  graphic_2d_feature_enable_prefetch = true
52
53  if (defined(is_arkui_x) && is_arkui_x) {
54    is_cross_platform = true
55  } else {
56    is_cross_platform = false
57  }
58}
59
60declare_args() {
61  graphic_2d_feature_enable_stack_culling = false
62  graphic_2d_feature_vkqueue_priority_enable = false
63}
64
65if (graphic_2d_feature_product == "phone" ||
66    graphic_2d_feature_product == "pc" ||
67    graphic_2d_feature_product == "tablet" ||
68    graphic_2d_feature_product == "wearable") {
69  graphic_2d_feature_enable_vulkan = true
70  graphic_2d_feature_enable_ddgr = false
71  graphic_2d_feature_enable_stack_culling = true
72}
73
74if (graphic_2d_feature_product == "phone" ||
75    graphic_2d_feature_product == "tablet" ||
76    graphic_2d_feature_product == "wearable") {
77  graphic_2d_feature_enable_opinc = true
78}
79
80gpu_defines = []
81accessibility_defines = []
82if (enable_text_gine) {
83  gpu_defines += [ "USE_GRAPHIC_TEXT_GINE" ]
84}
85if (graphic_2d_feature_ace_enable_gpu) {
86  if (graphic_2d_feature_enable_flutter_vulkan) {
87    gpu_defines += [ "RS_ENABLE_OLD_VK" ]
88  }
89  if (graphic_2d_feature_enable_vulkan) {
90    gpu_defines += [
91      "ACE_ENABLE_VK",
92      "RS_ENABLE_VK",
93    ]
94    if (graphic_2d_feature_enable_ddgr) {
95      gpu_defines += [ "ENABLE_DDGR_OPTIMIZE" ]
96      import("//foundation/graphic/graphic_2d_ext/ddgr/config.gni")
97    }
98  }
99  if (graphic_2d_feature_enable_opengl) {
100    gpu_defines += [
101      "ACE_ENABLE_GL",
102      "RS_ENABLE_GL",
103    ]
104  }
105  if (graphic_2d_feature_enable_stack_culling) {
106    gpu_defines += [ "RS_ENABLE_STACK_CULLING" ]
107  }
108
109  if (graphic_2d_feature_enable_opinc) {
110    gpu_defines += [ "DDGR_ENABLE_FEATURE_OPINC" ]
111  }
112
113  if (graphic_2d_feature_enable_recording_dcl) {
114    rs_enable_recording_dcl = true
115    gpu_defines += [ "ENABLE_RECORDING_DCL" ]
116  } else {
117    rs_enable_recording_dcl = false
118  }
119  ace_enable_gpu = true
120  rs_enable_gpu = true
121  surface_enable_gpu = true
122
123  libvulkan = []
124  if (graphic_2d_feature_enable_vulkan) {
125    libvulkan += [ "//third_party/vulkan-loader:vulkan_loader" ]
126  }
127} else {
128  gpu_defines = [ "ACE_DISABLE_GL" ]
129  ace_enable_gpu = false
130  rs_enable_gpu = false
131  surface_enable_gpu = false
132  libvulkan = []
133}
134
135if (graphic_2d_feature_enable_vulkan &&
136    graphic_2d_feature_vkqueue_priority_enable) {
137  gpu_defines += [ "RS_ENABLE_VKQUEUE_PRIORITY" ]
138}
139
140if (graphic_2d_feature_parallel_upload_enable &&
141    graphic_2d_feature_rs_enable_uni_render &&
142    graphic_2d_feature_product == "phone") {
143  rs_enable_parallel_upload = true
144  gpu_defines += [ "RS_ENABLE_PARALLEL_UPLOAD" ]
145} else {
146  rs_enable_parallel_upload = false
147}
148
149if (graphic_2d_feature_rs_enable_eglimage || current_os == "android") {
150  gpu_defines += [
151    "RS_ENABLE_EGLIMAGE",
152    "RS_ENABLE_EGLQUERYSURFACE",
153  ]
154  rs_enable_eglimage = true
155} else {
156  gpu_defines += [ "RS_DISABLE_EGLIMAGE" ]
157  rs_enable_eglimage = false
158}
159
160# use_texgine = graphic_2d_feature_use_texgine
161
162if (graphic_2d_feature_rs_enable_uni_render) {
163  graphic_2d_feature_enable_dvsync = true
164  if (graphic_2d_feature_product == "phone") {
165    graphic_2d_feature_enable_chipset_vsync = true
166  }
167  gpu_defines += [ "RS_ENABLE_UNI_RENDER" ]
168} else {
169  graphic_2d_feature_enable_dvsync = false
170  graphic_2d_feature_enable_chipset_vsync = false
171}
172
173if (graphic_2d_feature_enable_afbc) {
174  gpu_defines += [ "RS_ENABLE_AFBC" ]
175}
176
177if (graphic_2d_feature_parallel_render_enable) {
178  rs_enable_parallel_render = true
179  gpu_defines += [ "RS_ENABLE_PARALLEL_RENDER" ]
180}
181
182if (graphic_2d_feature_enable_dvsync) {
183  gpu_defines += [ "RS_ENABLE_DVSYNC" ]
184}
185if (graphic_2d_feature_enable_chipset_vsync) {
186  gpu_defines += [ "RS_ENABLE_CHIPSET_VSYNC" ]
187}
188
189tp_defines = []
190tp_feature_enable = false
191if (graphic_2d_feature_tp_switch_enbale) {
192  tp_feature_enable = true
193  tp_defines = [ "TP_FEATURE_ENABLE" ]
194}
195
196check_graphic_ext_file_script = "//build/ohos/file_exists.py"
197
198check_ddgr_ext_file_args = [
199  "--filename",
200  rebase_path("//foundation/graphic/graphic_2d_ext/ddgr/ddgr_config.gni"),
201]
202check_igraphics_core_file_args = [
203  "--filename",
204  rebase_path(
205      "//vendor/huawei/foundation/graphics_game/gpu_turbo_x/EGL/config.gni"),
206]
207check_igameservice_core_file_args = [
208  "--filename",
209  rebase_path(
210      "//vendor/huawei/domains/game/gameservice_server/performance/graphics/report/config.gni"),
211]
212check_aps_core_file_args = [
213  "--filename",
214  rebase_path("//foundation/graphic/graphic_2d_ext/aps_manager/config.gni"),
215]
216check_delegator_ext_file_args = [
217  "--filename",
218  rebase_path("//foundation/graphic/graphic_2d_ext/delegator/config.gni"),
219]
220check_broker_ext_file_args = [
221  "--filename",
222  rebase_path(
223      "//foundation/graphic/graphic_2d_ext/ohcore/build/broker_config.gni"),
224]
225check_hgm_ext_file_args = [
226  "--filename",
227  rebase_path(
228      "//foundation/graphic/graphic_2d_ext/hgm_manager/build/hgm_config.gni"),
229]
230
231if (exec_script(check_graphic_ext_file_script,
232                check_ddgr_ext_file_args,
233                "string") == "True") {
234  ddgr_ext_configs = {
235    import("//foundation/graphic/graphic_2d_ext/ddgr/ddgr_config.gni")
236  }
237}
238if (exec_script(check_graphic_ext_file_script,
239                check_igraphics_core_file_args,
240                "string") == "True") {
241  graphic_2d_feature_use_igraphics_extend_hooks = true
242  import("//vendor/huawei/foundation/graphics_game/gpu_turbo_x/EGL/config.gni")
243}
244if (exec_script(check_graphic_ext_file_script,
245                check_aps_core_file_args,
246                "string") == "True" &&
247    exec_script(check_graphic_ext_file_script,
248                check_igameservice_core_file_args,
249                "string") == "True") {
250  graphic_2d_feature_use_aps_igameservice_func = true
251  import("//foundation/graphic/graphic_2d_ext/aps_manager/config.gni")
252  import(
253      "//vendor/huawei/domains/game/gameservice_server/performance/graphics/report/config.gni")
254}
255
256graphic_2d_delegator_configs = {
257}
258if (exec_script(check_graphic_ext_file_script,
259                check_delegator_ext_file_args,
260                "string") == "True") {
261  graphic_2d_delegator_configs = {
262    import("//foundation/graphic/graphic_2d_ext/delegator/config.gni")
263  }
264}
265
266graphic_2d_broker_configs = {
267}
268if (exec_script(check_graphic_ext_file_script,
269                check_broker_ext_file_args,
270                "string") == "True") {
271  graphic_2d_broker_configs = {
272    import("//foundation/graphic/graphic_2d_ext/ohcore/build/broker_config.gni")
273  }
274}
275
276graphic_2d_hgm_configs = {
277}
278if (exec_script(check_graphic_ext_file_script,
279                check_hgm_ext_file_args,
280                "string") == "True") {
281  graphic_2d_hgm_configs = {
282    import(
283        "//foundation/graphic/graphic_2d_ext/hgm_manager/build/hgm_config.gni")
284  }
285}
286
287check_platform_ext_file_args = [
288  "--filename",
289  rebase_path("//foundation/graphic/graphic_2d_ext/platform/config.gni"),
290]
291graphic_2d_platform_configs = {
292}
293if (exec_script(check_graphic_ext_file_script,
294                check_platform_ext_file_args,
295                "string") == "True") {
296  graphic_2d_platform_configs = {
297    import("//foundation/graphic/graphic_2d_ext/platform/config.gni")
298  }
299}
300
301flutter_root = "//third_party/flutter"
302ace_flutter_engine_root = "$flutter_root/build"
303graphic_2d_root = "//foundation/graphic/graphic_2d"
304graphic_2d_ext_root = "//foundation/graphic/graphic_2d_ext"
305hilog_root = "//base/hiviewdfx/hilog"
306window_base_path = "//foundation/window/window_manager"
307safwk_base = "//foundation/systemabilitymgr/safwk"
308skia_root_new = "//third_party/skia"
309graphic_surface_root = "//foundation/graphic/graphic_surface"
310memmgr_root = "//foundation/resourceschedule/memmgr"
311memmgr_plugin_root = "//foundation/resourceschedule/memmgr_override"
312fuzz_test_output_path = "graphic_2d/graphic_2d"
313video_processing_engine_root = "//foundation/multimedia/video_processing_engine"
314arkui_root = "//foundation/arkui"
315ace_root = "//foundation/arkui/ace_engine"
316bundlefwk_path = "//foundation/bundlemanager/bundle_framework"
317bundlefwk_inner_api_path = "${bundlefwk_path}/interfaces/inner_api"
318mindspore_root = "//third_party/mindspore"
319
320accessibility_enable = false
321if (defined(global_parts_info) &&
322    defined(global_parts_info.barrierfree_accessibility)) {
323  accessibility_enable = true
324  accessibility_defines = [ "ACCESSIBILITY_ENABLE" ]
325}
326
327if (defined(global_parts_info) &&
328    !defined(global_parts_info.multimedia_player_framework)) {
329  player_framework_enable = false
330}
331
332if (defined(global_parts_info) &&
333    defined(global_parts_info.multimedia_video_processing_engine)) {
334  use_video_processing_engine = true
335}
336
337if (defined(global_parts_info) &&
338    !defined(global_parts_info.hdf_drivers_interface_display)) {
339  graphic_2d_feature_drivers_interface_display_enable = false
340}
341
342use_memmgr_plugin = false
343if (defined(global_parts_info.resourceschedule_memmgr_override)) {
344  use_memmgr_plugin = true
345}
346use_memmgr = false
347if (defined(global_parts_info.resourceschedule_memmgr)) {
348  use_memmgr = true
349}
350
351_ace_adapter_dir = rebase_path("$ace_root/adapter", root_build_dir)
352_graphic_2d_adapter_dir =
353    rebase_path("$graphic_2d_root/adapter", root_build_dir)
354
355if (defined(is_arkui_x) && is_arkui_x) {
356  # In case of arkui-x compilation, copy android and ios adapters from ace_engine
357  exec_script("$graphic_2d_root/utils/build/copy_arkui_adapters.py",
358              [
359                _ace_adapter_dir,
360                _graphic_2d_adapter_dir,
361              ])
362}
363adapters = exec_script("$ace_root/build/search.py",
364                       [ _graphic_2d_adapter_dir ],
365                       "list lines")
366if (defined(use_clang_coverage) && use_clang_coverage) {
367  graphic_2d_feature_rs_enable_profiler = false
368  graphic_2d_feature_enable_recording_dcl = false
369}
370
371if (defined(input_ext_feature_magiccursor) && input_ext_feature_magiccursor) {
372  gpu_defines += [ "OHOS_BUILD_ENABLE_MAGICCURSOR" ]
373}
374
375if (defined(graphic_2d_feature_enable_prefetch)) {
376  gpu_defines += [ "RS_ENABLE_PREFETCH" ]
377}
378