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